kadnode: add new packagelilik-openwrt-22.03
@ -0,0 +1,44 @@ | |||
menu "Configuration" | |||
depends on PACKAGE_kadnode | |||
config KADNODE_ENABLE_LPD | |||
bool "Enable Local Peer Discovery" | |||
depends on PACKAGE_kadnode | |||
default y | |||
config KADNODE_ENABLE_CMD | |||
bool "Enable Command Console" | |||
depends on PACKAGE_kadnode | |||
default y | |||
config KADNODE_ENABLE_DNS | |||
bool "Enable the local DNS server" | |||
depends on PACKAGE_kadnode | |||
default y | |||
config KADNODE_ENABLE_TLS | |||
bool "Enable TLS authentication support" | |||
depends on PACKAGE_kadnode | |||
default y | |||
config KADNODE_ENABLE_BOB | |||
bool "Enable BOB authentication support" | |||
depends on PACKAGE_kadnode | |||
default y | |||
config KADNODE_ENABLE_UPNP | |||
bool "Enable UPnP support to add port forwardings on other routers" | |||
depends on PACKAGE_kadnode | |||
default n | |||
config KADNODE_ENABLE_NATPMP | |||
bool "Enable NAT-PMP support to add port forwardings on other routers" | |||
depends on PACKAGE_kadnode | |||
default n | |||
config KADNODE_ENABLE_DEBUG | |||
bool "Build in debug mode" | |||
depends on PACKAGE_kadnode | |||
default n | |||
endmenu |
@ -0,0 +1,93 @@ | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
include $(TOPDIR)/rules.mk | |||
PKG_NAME:=kadnode | |||
PKG_VERSION:=2.0.2 | |||
PKG_RELEASE:=1 | |||
PKG_SOURCE_PROTO:=git | |||
PKG_SOURCE_URL:=git://github.com/mwarning/KadNode.git | |||
PKG_SOURCE_VERSION:=26dbc9436f8d2c68b899cd32e01bdbe1565294b2 | |||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) | |||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | |||
PKG_MIRROR_HASH:=67ba2ce03c3dd74b547885891391657aa9d6fae7c14558634776e1111e7cbe57 | |||
PKG_LICENSE:=MIT | |||
PKG_BUILD_PARALLEL:=1 | |||
include $(INCLUDE_DIR)/package.mk | |||
define Package/kadnode | |||
SECTION:=net | |||
CATEGORY:=Network | |||
TITLE:=P2P DNS Resolver | |||
SUBMENU:=IP Addresses and Names | |||
URL:=https://github.com/mwarning/KadNode | |||
MENU:=1 | |||
DEPENDS:=+KADNODE_ENABLE_BOB:libmbedtls +KADNODE_ENABLE_TLS:libmbedtls +KADNODE_ENABLE_UPNP:libminiupnpc +KADNODE_ENABLE_NATPMP:libnatpmp | |||
MAINTAINER:=Moritz Warning <moritzwarning@web.de> | |||
endef | |||
define Package/kadnode/description | |||
A P2P DNS system based on the BitTorrent network. It can be used as a decentralized DynDNS service. | |||
endef | |||
define Package/kadnode/config | |||
source "$(SOURCE)/Config.in" | |||
endef | |||
FEATURES = | |||
ifeq ($(CONFIG_KADNODE_ENABLE_CMD),y) | |||
FEATURES += cmd | |||
endif | |||
ifeq ($(CONFIG_KADNODE_ENABLE_LPD),y) | |||
FEATURES += lpd | |||
endif | |||
ifeq ($(CONFIG_KADNODE_ENABLE_TLS),y) | |||
FEATURES += tls | |||
endif | |||
ifeq ($(CONFIG_KADNODE_ENABLE_BOB),y) | |||
FEATURES += bob | |||
endif | |||
ifeq ($(CONFIG_KADNODE_ENABLE_DNS),y) | |||
FEATURES += dns | |||
endif | |||
ifeq ($(CONFIG_KADNODE_ENABLE_UPNP),y) | |||
FEATURES += upnp | |||
endif | |||
ifeq ($(CONFIG_KADNODE_ENABLE_NATPMP),y) | |||
FEATURES += natpmp | |||
endif | |||
ifeq ($(CONFIG_KADNODE_ENABLE_DEBUG),y) | |||
FEATURES += debug | |||
endif | |||
MAKE_FLAGS += FEATURES="$(FEATURES)" | |||
define Package/kadnode/install | |||
$(INSTALL_DIR) $(1)/usr/bin | |||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/kadnode $(1)/usr/bin/ | |||
ifeq ($(CONFIG_KADNODE_ENABLE_CMD),y) | |||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/kadnode-ctl $(1)/usr/bin/ | |||
endif | |||
$(INSTALL_DIR) $(1)/etc/init.d | |||
$(INSTALL_BIN) files/kadnode.init $(1)/etc/init.d/kadnode | |||
$(INSTALL_DIR) $(1)/etc/config | |||
$(INSTALL_CONF) files/kadnode.config $(1)/etc/config/kadnode | |||
$(INSTALL_DIR) $(1)/etc/uci-defaults | |||
$(INSTALL_BIN) files/kadnode.postinst $(1)/etc/uci-defaults/99_kadnode | |||
endef | |||
$(eval $(call BuildPackage,kadnode)) |
@ -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' |
@ -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 |
@ -0,0 +1,46 @@ | |||
From a1f9e4e58dcdc7ea4e3b2bd3df110f10d23b437c Mon Sep 17 00:00:00 2001 | |||
From: Moritz Warning <moritzwarning@web.de> | |||
Date: Sun, 14 Jan 2018 21:47:24 +0100 | |||
Subject: [PATCH] fix type of returned address count | |||
--- | |||
src/ext-dns.c | 8 ++++---- | |||
1 file changed, 4 insertions(+), 4 deletions(-) | |||
diff --git a/src/ext-dns.c b/src/ext-dns.c | |||
index 3394e33..89a2311 100644 | |||
--- a/src/ext-dns.c | |||
+++ b/src/ext-dns.c | |||
@@ -470,9 +470,9 @@ static void setPointerRecord( struct ResourceRecord *rr, const char name[], cons | |||
rr->rd_data.ptr_record.name = domain; | |||
} | |||
-static int dns_setup_msg( struct Message *msg, IP addrs[], size_t addrs_num, const char* hostname ) { | |||
+static int dns_setup_msg( struct Message *msg, IP addrs[], int addrs_num, const char* hostname ) { | |||
const char *qName; | |||
- size_t i, c; | |||
+ int i, c; | |||
// Header: leave most values intact for response | |||
msg->qr = 1; // This is a response | |||
@@ -606,7 +606,7 @@ static void proxy_forward_response( uint8_t *buffer, ssize_t buflen, uint16_t id | |||
static void dns_handler( int rc, int sock ) { | |||
struct Message msg; | |||
IP clientaddr; | |||
- size_t addrs_num; | |||
+ int addrs_num; | |||
IP addrs[MAX_ADDR_RECORDS]; | |||
socklen_t addrlen_ret; | |||
ssize_t buflen; | |||
@@ -702,7 +702,7 @@ log_info("setup response"); | |||
return; | |||
} | |||
- log_debug( "DNS: Send back %lu addresses to: %s", | |||
+ log_debug( "DNS: Send back %d addresses to: %s", | |||
addrs_num, str_addr( &clientaddr ) | |||
); | |||
} | |||
-- | |||
2.15.1 | |||