mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
kadnode: add new package
Signed-off-by: Moritz Warning <moritzwarning@web.de>
This commit is contained in:
Executable
+58
@@ -0,0 +1,58 @@
|
||||
##
|
||||
## KadNode is a P2P DNS resolver to resolve domains using the BitTorrent network.
|
||||
##
|
||||
|
||||
config kadnode
|
||||
option enabled 1
|
||||
|
||||
|
||||
## ECC Key usage:
|
||||
## 1. Create public/secret key pair with `kadnode --bob-create-key /etc/kadnode_secret.pem`
|
||||
## 2. Put the secret key file on the router that you want to resolve to and use it for option bob_load_key.
|
||||
## 3. Use the public key hex output with .p2p attached on other devices to resovle to the router IP address via kadnode.
|
||||
|
||||
## Secret key for public key links
|
||||
# list bob_load_key '/etc/kadnode_secret.pem'
|
||||
|
||||
|
||||
## TLS usage:
|
||||
## For resolving domains, put credentials on the router and use option tls_client_cert.
|
||||
## For announcing domains, put the certificates and secret key on router and use option tls_server_cert.
|
||||
|
||||
## Folder of CA certificates
|
||||
## Install package 'ca-certificates' for the official CA set.
|
||||
# list tls_client_cert '/etc/ssl/certs'
|
||||
|
||||
## Server credentials
|
||||
# list tls_server_cert '/ect/mynode.crt,/etc/mynode.key'
|
||||
|
||||
|
||||
## Add domains to be announced.
|
||||
## Note: Only needed in special situations since tls_server_cert and bob_load_key announce automatically its associated domains.
|
||||
# list announce 'web.myname.p2p'
|
||||
|
||||
## Load and store good nodes every 24h and on start/shutdown.
|
||||
# option peerfile '/etc/kadnode/peers.txt'
|
||||
|
||||
## Add static peers addresses.
|
||||
list peer 'bttracker.debian.org:6881'
|
||||
list peer 'router.bittorrent.com:6881'
|
||||
|
||||
## Bind the DHT to this port.
|
||||
# option port '6881'
|
||||
|
||||
## Limit DHT communication to this interface.
|
||||
# option ifname 'eth0'
|
||||
|
||||
## Verbosity: quiet, verbose or debug
|
||||
# option verbosity 'quiet'
|
||||
|
||||
## Local port to accept forwarded requests.
|
||||
# option dns_port '3535'
|
||||
|
||||
## Disable multicast peer discovery on the LAN.
|
||||
# option lpd_disable '1'
|
||||
|
||||
## Disable port forwarding when this router is behind another
|
||||
## router in a private network that supports UPnP/NAT-PMP.
|
||||
# option fwd_disable '1'
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=95
|
||||
USE_PROCD=1
|
||||
KADNODE_BIN=/usr/bin/kadnode
|
||||
OPTS=""
|
||||
|
||||
|
||||
xappend() {
|
||||
local name="$2" value="$1"
|
||||
OPTS="$OPTS--${name//_/-} ${value//'/\\'}
|
||||
"
|
||||
}
|
||||
|
||||
append_opts_list() {
|
||||
local name cfg="$1"; shift
|
||||
for name in $*; do
|
||||
config_list_foreach "$cfg" "$name" xappend "$name"
|
||||
done
|
||||
}
|
||||
|
||||
append_opts() {
|
||||
local name value cfg="$1"; shift
|
||||
for name in $*; do
|
||||
config_get value "$cfg" "$name"
|
||||
[ -n "$value" ] && xappend "$value" "$name"
|
||||
done
|
||||
}
|
||||
|
||||
append_opts_boolean() {
|
||||
local name value cfg="$1"; shift
|
||||
for name in $*; do
|
||||
config_get_bool value "$cfg" "$name" 0
|
||||
[ $value -gt 0 ] && xappend '' $name
|
||||
done
|
||||
}
|
||||
|
||||
section_enabled() {
|
||||
config_get_bool enabled "$1" 'enabled' 0
|
||||
[ $enabled -gt 0 ]
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local cfg="$1"
|
||||
local CONFIG_FILE=/tmp/kadnode.${cfg}.conf
|
||||
|
||||
section_enabled "$cfg" || return
|
||||
|
||||
OPTS=""
|
||||
|
||||
append_opts "$cfg" lpd_addr dns_server dns_port verbosity peerfile config \
|
||||
query_tld user port ifname cmd_port
|
||||
|
||||
append_opts_list "$cfg" announce peer tls_client_cert tls_server_cert bob_load_key
|
||||
|
||||
append_opts_boolean "$cfg" dns_proxy_enable lpd_disable fwd_disable ipv4 ipv6
|
||||
|
||||
# Close stdin when cmd feature is present
|
||||
if [ $($KADNODE_BIN --version | grep -c cmd) -eq 1 ]; then
|
||||
xappend "" "cmd_disable_stdin"
|
||||
fi
|
||||
|
||||
echo "$OPTS" > $CONFIG_FILE
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $KADNODE_BIN
|
||||
procd_set_param file $CONFIG_FILE
|
||||
procd_set_param stderr 1
|
||||
procd_set_param stdout 1
|
||||
procd_append_param command --config $CONFIG_FILE
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_instance() {
|
||||
local cfg="$1"
|
||||
local CONFIG_FILE=/tmp/kadnode.${cfg}.conf
|
||||
|
||||
rm -f $CONFIG_FILE
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load 'kadnode'
|
||||
config_foreach start_instance 'kadnode'
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
config_load 'kadnode'
|
||||
config_foreach stop_instance 'kadnode'
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci add_list dhcp.@dnsmasq[0].server='/p2p/::1#3535'
|
||||
uci commit dhcp
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user