Skip to content

Commit

Permalink
mdnsd fix miniupnpd add to tpm312
Browse files Browse the repository at this point in the history
  • Loading branch information
lunatickochiya committed Oct 6, 2024
1 parent c33199f commit d7998a0
Show file tree
Hide file tree
Showing 6 changed files with 570 additions and 0 deletions.
24 changes: 24 additions & 0 deletions openwrt-2305/feeds-package-patch-2305/0001-mdnsd-std-err.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 4544ce5cb2079c110808d10d5ae45d002f4cfc8f Mon Sep 17 00:00:00 2001
From: lunatickochiya <[email protected]>
Date: Sun, 6 Oct 2024 09:31:28 +0800
Subject: [PATCH] mdnsd:std err

---
net/mdnsresponder/files/mdnsd.init | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/mdnsresponder/files/mdnsd.init b/net/mdnsresponder/files/mdnsd.init
index 817604b..8f73937 100755
--- a/net/mdnsresponder/files/mdnsd.init
+++ b/net/mdnsresponder/files/mdnsd.init
@@ -9,6 +9,7 @@ start_service() {
procd_open_instance
procd_set_param command /usr/sbin/mdnsd -debug
procd_set_param respawn
+ procd_set_param stderr 1
procd_close_instance
}

--
2.34.1

254 changes: 254 additions & 0 deletions openwrt-2305/feeds-package-patch-2305/0001-miniupnpd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
diff --git a/net/miniupnpd/files/miniupnpd.init b/net/miniupnpd/files/miniupnpd.init
index de35045..881b5d7 100644
--- a/net/miniupnpd/files/miniupnpd.init
+++ b/net/miniupnpd/files/miniupnpd.init
@@ -63,6 +63,7 @@ upnpd() {
local use_stun stun_host stun_port uuid notify_interval presentation_url
local upnp_lease_file clean_ruleset_threshold clean_ruleset_interval
local ipv6_disable
+ local force_forwarding

local enabled
config_get_bool enabled config enabled 1
@@ -90,6 +91,7 @@ upnpd() {
config_get clean_ruleset_threshold config clean_ruleset_threshold
config_get clean_ruleset_interval config clean_ruleset_interval
config_get ipv6_disable config ipv6_disable 0
+ config_get force_forwarding config force_forwarding 0

local conf ifname ifname6

@@ -142,6 +144,7 @@ upnpd() {
upnpd_write_bool igdv1 0 force_igd_desc_v1
upnpd_write_bool use_stun 0 ext_perform_stun
upnpd_write_bool ipv6_disable $ipv6_disable
+ upnpd_write_bool force_forwarding $force_forwarding

[ "$use_stun" -eq 0 ] || {
[ -n "$stun_host" ] && echo "ext_stun_host=$stun_host"
diff --git a/net/miniupnpd/files/upnpd.config b/net/miniupnpd/files/upnpd.config
index bd7c3ec..251850f 100644
--- a/net/miniupnpd/files/upnpd.config
+++ b/net/miniupnpd/files/upnpd.config
@@ -12,6 +12,8 @@ config upnpd config
option port 5000
option upnp_lease_file /var/run/miniupnpd.leases
option igdv1 1
+ option ipv6_disable 1
+ option force_forwarding '1'

config perm_rule
option action allow
diff --git a/net/miniupnpd/patches/400-fix.patch b/net/miniupnpd/patches/400-fix.patch
new file mode 100644
index 0000000..b301bef
--- /dev/null
+++ b/net/miniupnpd/patches/400-fix.patch
@@ -0,0 +1,207 @@
+From e1f8a143967e7129c62f5810f960352866b2b3af Mon Sep 17 00:00:00 2001
+From: Chen Minqiang <[email protected]>
+Date: Sun, 5 Jul 2020 10:42:52 +0800
+Subject: [PATCH] options: force_forwarding support
+
+This make the port forwarding force to work even
+when the router is behind NAT
+
+Signed-off-by: Chen Minqiang <[email protected]>
+---
+ miniupnpd.c | 12 ++++++++----
+ miniupnpd.conf | 2 ++
+ natpmp.c | 2 +-
+ options.c | 1 +
+ options.h | 1 +
+ testgetifaddr.c | 2 ++
+ testportinuse.c | 2 ++
+ upnpdescgen.c | 2 +-
+ upnpglobalvars.h | 2 ++
+ upnpredirect.c | 2 +-
+ upnpsoap.c | 6 +++++-
+ 11 files changed, 26 insertions(+), 8 deletions(-)
+
+diff --git a/miniupnpd.c b/miniupnpd.c
+index 3755c6362..219e7bbae 100644
+--- a/miniupnpd.c
++++ b/miniupnpd.c
+@@ -1010,7 +1010,7 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str, int debug_flag)
+ INIT_PRINT_ERR("Error parsing address : %s\n", lan_addr->ext_ip_str);
+ return -1;
+ }
+- if(addr_is_reserved(&lan_addr->ext_ip_addr)) {
++ if(addr_is_reserved(&lan_addr->ext_ip_addr) && !GETFLAG(FORCEFORWARDINGMASK)) {
+ /* error */
+ INIT_PRINT_ERR("Error: option ext_ip address contains reserved / private address : %s\n", lan_addr->ext_ip_str);
+ return -1;
+@@ -1252,6 +1252,10 @@ init(int argc, char * * argv, struct runtime_vars * v)
+ case UPNPEXT_IP:
+ use_ext_ip_addr = ary_options[i].value;
+ break;
++ case UPNP_FORCE_FORWARDING:
++ if(strcmp(ary_options[i].value, "yes") == 0)
++ SETFLAG(FORCEFORWARDINGMASK);
++ break;
+ case UPNPEXT_PERFORM_STUN:
+ if(strcmp(ary_options[i].value, "yes") == 0)
+ SETFLAG(PERFORMSTUNMASK);
+@@ -1859,7 +1863,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
+ INIT_PRINT_ERR("Error: option ext_ip contains invalid address %s\n", use_ext_ip_addr);
+ return 1;
+ }
+- if (addr_is_reserved(&addr)) {
++ if (addr_is_reserved(&addr) && !GETFLAG(FORCEFORWARDINGMASK)) {
+ INIT_PRINT_ERR("Error: option ext_ip contains reserved / private address %s, not public routable\n", use_ext_ip_addr);
+ return 1;
+ }
+@@ -2305,7 +2309,7 @@ main(int argc, char * * argv)
+ if (getifaddr(ext_if_name, if_addr, INET_ADDRSTRLEN, &addr, NULL) < 0) {
+ syslog(LOG_WARNING, "Cannot get IP address for ext interface %s. Network is down", ext_if_name);
+ disable_port_forwarding = 1;
+- } else if (addr_is_reserved(&addr)) {
++ } else if (addr_is_reserved(&addr) && !GETFLAG(FORCEFORWARDINGMASK)) {
+ syslog(LOG_INFO, "Reserved / private IP address %s on ext interface %s: Port forwarding is impossible", if_addr, ext_if_name);
+ syslog(LOG_INFO, "You are probably behind NAT, enable option ext_perform_stun=yes to detect public IP address");
+ syslog(LOG_INFO, "Or use ext_ip= / -o option to declare public IP address");
+@@ -2596,7 +2600,7 @@ main(int argc, char * * argv)
+ syslog(LOG_WARNING, "Cannot get IP address for ext interface %s. Network is down", ext_if_name);
+ disable_port_forwarding = 1;
+ } else {
+- int reserved = addr_is_reserved(&addr);
++ int reserved = addr_is_reserved(&addr) && !GETFLAG(FORCEFORWARDINGMASK);
+ if (!disable_port_forwarding && reserved) {
+ syslog(LOG_INFO, "Reserved / private IP address %s on ext interface %s: Port forwarding is impossible", if_addr, ext_if_name);
+ syslog(LOG_INFO, "You are probably behind NAT, enable option ext_perform_stun=yes to detect public IP address");
+diff --git a/miniupnpd.conf b/miniupnpd.conf
+index 9bf0c69a9..f9a6cc9cf 100644
+--- a/miniupnpd.conf
++++ b/miniupnpd.conf
+@@ -9,6 +9,9 @@
+ # Setting ext_ip is also useful in double NAT setup, you can declare here
+ # the public IP address.
+ #ext_ip=
++
++#force forwarding enable for upnp: default is no
++#force_forwarding=yes
+ # WAN interface must have public IP address. Otherwise it is behind NAT
+ # and port forwarding is impossible. In some cases WAN interface can be
+ # behind unrestricted full-cone NAT 1:1 when all incoming traffic is NAT-ed and
+diff --git a/natpmp.c b/natpmp.c
+index 7f20fdac2..c30f93557 100644
+--- a/natpmp.c
++++ b/natpmp.c
+@@ -109,7 +109,7 @@ static void FillPublicAddressResponse(unsigned char * resp, in_addr_t senderaddr
+ syslog(LOG_ERR, "Failed to get IP for interface %s", ext_if_name);
+ resp[3] = 3; /* Network Failure (e.g. NAT box itself
+ * has not obtained a DHCP lease) */
+- } else if (addr_is_reserved(&addr)) {
++ } else if (addr_is_reserved(&addr) && !GETFLAG(FORCEFORWARDINGMASK)) {
+ resp[3] = 3; /* Network Failure, box has not obtained
+ public IP address */
+ } else {
+diff --git a/options.c b/options.c
+index ce56bc544..c06ca78e6 100644
+--- a/options.c
++++ b/options.c
+@@ -35,6 +35,7 @@ static const struct {
+ { UPNPEXT_IFNAME6, "ext_ifname6" },
+ #endif
+ { UPNPEXT_IP, "ext_ip" },
++ { UPNP_FORCE_FORWARDING, "force_forwarding" },
+ { UPNPEXT_PERFORM_STUN, "ext_perform_stun" },
+ { UPNPEXT_STUN_HOST, "ext_stun_host" },
+ { UPNPEXT_STUN_PORT, "ext_stun_port" },
+diff --git a/options.h b/options.h
+index b91de9b2f..56ee93d84 100644
+--- a/options.h
++++ b/options.h
+@@ -21,6 +21,7 @@ enum upnpconfigoptions {
+ UPNPEXT_IFNAME6, /* ext_ifname6 */
+ #endif
+ UPNPEXT_IP, /* ext_ip */
++ UPNP_FORCE_FORWARDING, /* force forwarding enable for upnp */
+ UPNPEXT_PERFORM_STUN, /* ext_perform_stun */
+ UPNPEXT_STUN_HOST, /* ext_stun_host */
+ UPNPEXT_STUN_PORT, /* ext_stun_port */
+diff --git a/testgetifaddr.c b/testgetifaddr.c
+index 8045b8937..b5cdbb425 100644
+--- a/testgetifaddr.c
++++ b/testgetifaddr.c
+@@ -13,6 +13,8 @@
+ #include "config.h"
+ #include "getifaddr.h"
+
++int runtime_flags = 0;
++
+ #if defined(__sun)
+ /* solaris 10 does not define LOG_PERROR */
+ #define LOG_PERROR 0
+diff --git a/testportinuse.c b/testportinuse.c
+index 98574c625..507f83061 100644
+--- a/testportinuse.c
++++ b/testportinuse.c
+@@ -14,6 +14,8 @@
+ #include "config.h"
+ #include "portinuse.h"
+
++int runtime_flags = 0;
++
+ int main(int argc, char * * argv)
+ {
+ #ifndef CHECK_PORTINUSE
+diff --git a/upnpdescgen.c b/upnpdescgen.c
+index 5f93bba30..96b7a73ee 100644
+--- a/upnpdescgen.c
++++ b/upnpdescgen.c
+@@ -1316,7 +1316,7 @@ genEventVars(int * len, const struct serviceDesc * s)
+ else {
+ struct in_addr addr;
+ char ext_ip_addr[INET_ADDRSTRLEN];
+- if(getifaddr(ext_if_name, ext_ip_addr, INET_ADDRSTRLEN, &addr, NULL) < 0 || addr_is_reserved(&addr)) {
++ if(getifaddr(ext_if_name, ext_ip_addr, INET_ADDRSTRLEN, &addr, NULL) < 0 || (addr_is_reserved(&addr) && !GETFLAG(FORCEFORWARDINGMASK))) {
+ str = strcat_str(str, len, &tmplen, "0.0.0.0");
+ } else {
+ str = strcat_str(str, len, &tmplen, ext_ip_addr);
+diff --git a/upnpglobalvars.h b/upnpglobalvars.h
+index fcdc03ead..1c72ec05d 100644
+--- a/upnpglobalvars.h
++++ b/upnpglobalvars.h
+@@ -87,6 +87,8 @@ extern int runtime_flags;
+
+ #define PERFORMSTUNMASK 0x1000
+
++#define FORCEFORWARDINGMASK 0x2000
++
+ #define SETFLAG(mask) runtime_flags |= mask
+ #define GETFLAG(mask) (runtime_flags & mask)
+ #define CLEARFLAG(mask) runtime_flags &= ~mask
+diff --git a/upnpredirect.c b/upnpredirect.c
+index e9d1c82d2..8eaf09130 100644
+--- a/upnpredirect.c
++++ b/upnpredirect.c
+@@ -444,7 +444,7 @@ upnp_redirect_internal(const char * rhost, unsigned short eport,
+ {
+ /*syslog(LOG_INFO, "redirecting port %hu to %s:%hu protocol %s for: %s",
+ eport, iaddr, iport, protocol, desc); */
+- if(disable_port_forwarding)
++ if(disable_port_forwarding && !GETFLAG(FORCEFORWARDINGMASK))
+ return -1;
+ if(add_redirect_rule2(ext_if_name, rhost, eport, iaddr, iport, proto,
+ desc, timestamp) < 0) {
+diff --git a/upnpsoap.c b/upnpsoap.c
+index 567b39d4c..c2a9f9a47 100644
+--- a/upnpsoap.c
++++ b/upnpsoap.c
+@@ -348,7 +348,11 @@ GetExternalIPAddress(struct upnphttp * h, const char * action, const char * ns)
+ ext_ip_addr[0] = '\0';
+ } else if (addr_is_reserved(&addr)) {
+ syslog(LOG_NOTICE, "private/reserved address %s is not suitable for external IP", ext_ip_addr);
+- ext_ip_addr[0] = '\0';
++ if (!GETFLAG(FORCEFORWARDINGMASK)) {
++ ext_ip_addr[0] = '\0';
++ } else {
++ syslog(LOG_NOTICE, "force_forwarding enable, private/reserved address %s used as external IP", ext_ip_addr);
++ }
+ }
+ }
+ #else
24 changes: 24 additions & 0 deletions openwrt-2305/feeds-package-patch-23055/0001-mdnsd-std-err.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 4544ce5cb2079c110808d10d5ae45d002f4cfc8f Mon Sep 17 00:00:00 2001
From: lunatickochiya <[email protected]>
Date: Sun, 6 Oct 2024 09:31:28 +0800
Subject: [PATCH] mdnsd:std err

---
net/mdnsresponder/files/mdnsd.init | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/mdnsresponder/files/mdnsd.init b/net/mdnsresponder/files/mdnsd.init
index 817604b..8f73937 100755
--- a/net/mdnsresponder/files/mdnsd.init
+++ b/net/mdnsresponder/files/mdnsd.init
@@ -9,6 +9,7 @@ start_service() {
procd_open_instance
procd_set_param command /usr/sbin/mdnsd -debug
procd_set_param respawn
+ procd_set_param stderr 1
procd_close_instance
}

--
2.34.1

Loading

0 comments on commit d7998a0

Please sign in to comment.