From c2912183de121d7a64939ff36520b431ca91fa43 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 6 Apr 2021 20:50:08 +0200 Subject: [PATCH 1/4] Solve issue when interface doesn't exist anymore --- luci-app-omr-bypass/root/etc/init.d/omr-bypass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/luci-app-omr-bypass/root/etc/init.d/omr-bypass b/luci-app-omr-bypass/root/etc/init.d/omr-bypass index 60faa85e6..e7446143a 100755 --- a/luci-app-omr-bypass/root/etc/init.d/omr-bypass +++ b/luci-app-omr-bypass/root/etc/init.d/omr-bypass @@ -79,7 +79,7 @@ _bypass_domain() { local domain=$1 local intf=$2 intf=$(echo $intf | sed -e 's/\./_/') - + [ -n "$intf" ] && [ -z "$(ipset --list | grep omr_dst_bypass_$intf)" ] && return [ -z "$intf" ] && intf="all" if [ -n "$domain" ]; then domain=$(echo $domain | sed 's:^\.::') @@ -120,6 +120,7 @@ _bypass_mac() { config_get enabled $1 enabled [ "$enabled" = "0" ] && return intf=$(echo $intf | sed -e 's/\./_/') + [ -n "$intf" ] && [ -z "$(ipset --list | grep omr_dst_bypass_$intf)" ] && return local intfid="$(uci -q get omr-bypass.$intf.id)" [ -z "$intf" ] && intf="all" @@ -162,6 +163,7 @@ _bypass_lan_ip() { config_get enabled $1 enabled [ "$enabled" = "0" ] && return intf=$(echo $intf | sed -e 's/\./_/') + [ -n "$intf" ] && [ -z "$(ipset --list | grep omr_dst_bypass_$intf)" ] && return local intfid="$(uci -q get omr-bypass.$intf.id)" [ -z "$intf" ] && intf="all" @@ -220,6 +222,7 @@ _bypass_dest_port() { config_get enabled $1 enabled [ "$enabled" = "0" ] && return intf=$(echo $intf | sed -e 's/\./_/') + [ -n "$intf" ] && [ -z "$(ipset --list | grep omr_dst_bypass_$intf)" ] && return local intfid="$(uci -q get omr-bypass.$intf.id)" [ -z "$intf" ] && intf="all" @@ -276,6 +279,7 @@ _bypass_src_port() { config_get enabled $1 enabled [ "$enabled" = "0" ] && return intf=$(echo $intf | sed -e 's/\./_/') + [ -n "$intf" ] && [ -z "$(ipset --list | grep omr_dst_bypass_$intf)" ] && return local intfid="$(uci -q get omr-bypass.$intf.id)" [ -z "$intf" ] && intf="all" @@ -330,6 +334,7 @@ _bypass_proto() { config_get enabled $1 enabled [ "$enabled" = "0" ] && return intf=$(echo $intf | sed -e 's/\./_/') + [ -n "$intf" ] && [ -z "$(ipset --list | grep omr_dst_bypass_$intf)" ] && return local intfid="$(uci -q get omr-bypass.$intf.id)" [ -z "$intf" ] && intf="all" From 05017f372af289db1919adf76c5d5f3c3249add7 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 7 Apr 2021 18:17:04 +0200 Subject: [PATCH 2/4] Fix for IPv6 server with v2ray --- v2ray-core/files/etc/init.d/v2ray | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/v2ray-core/files/etc/init.d/v2ray b/v2ray-core/files/etc/init.d/v2ray index d7d25942d..72ca71c15 100755 --- a/v2ray-core/files/etc/init.d/v2ray +++ b/v2ray-core/files/etc/init.d/v2ray @@ -417,7 +417,7 @@ add_v2ray_redirect_rules() { v2ray-rules -l ${port} -L ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward [ "$(uci -q get v2ray.main.inbounds | grep omr6)" != "" ] && { v2ray-rules6 -f - v2ray-rules6 -l $((port+1)) -L $((port+1)) --rule-name def --src-default forward --dst-default forward --local-default forward + v2ray-rules6 -l $((port+1)) -L $((port+1)) -s $OUTBOUND_SERVERS_V6 --rule-name def --src-default forward --dst-default forward --local-default forward } [ -f /etc/init.d/omr-bypass ] && { logger -t "v2ray" "Reload omr-bypass rules" @@ -2092,9 +2092,12 @@ rules_up() { config_get enabled main enabled "0" [ "$enabled" = "0" ] && return OUTBOUND_SERVERS_V4="$(uci -q get v2ray.omrout.s_vless_address)" + OUTBOUND_SERVERS_V6="$(uci -q get v2ray.omrout.s_vless_address)" TRANSPARENT_PROXY_PORT="$(uci -q get v2ray.omr.port)" - logger -t "v2ray" "Rules UP" - add_v2ray_redirect_rules + [ -n "$OUTBOUND_SERVERS_V4" ] && { + logger -t "v2ray" "Rules UP" + add_v2ray_redirect_rules + } } rules_down() { From 543a11a2297d15e887b72952a4904b049fe5c9b0 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 7 Apr 2021 18:17:25 +0200 Subject: [PATCH 3/4] Restart miniupnpd if crashed --- mptcp/files/usr/share/omr/post-tracking.d/post-tracking | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mptcp/files/usr/share/omr/post-tracking.d/post-tracking b/mptcp/files/usr/share/omr/post-tracking.d/post-tracking index 4abf98d77..30a402bb1 100755 --- a/mptcp/files/usr/share/omr/post-tracking.d/post-tracking +++ b/mptcp/files/usr/share/omr/post-tracking.d/post-tracking @@ -1297,6 +1297,11 @@ if [ "$(pgrep v2ray)" = "" ] && [ "$(uci -q get v2ray.main.enabled)" = "1" ] && /etc/init.d/v2ray restart sleep 5 fi +if [ "$(pgrep miniupnpd)" = "" ] && [ "$(uci -q get upnpd.config.enabled)" = "1" ] && [ -f /etc/init.d/miniupnpd ]; then + _log "Can't find miniupnpd, restart it..." + /etc/init.d/miniupnpd restart + sleep 5 +fi if [ "$(pgrep rpcd)" = "" ] && [ -f /etc/init.d/rpcd ]; then _log "Can't find rpcd, restart it..." From 2093055c7fb42556b28bf3b51fce0aade5dc8de9 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 7 Apr 2021 18:17:45 +0200 Subject: [PATCH 4/4] Limit external ports for upnpd --- openmptcprouter/files/etc/uci-defaults/2092-upnpd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmptcprouter/files/etc/uci-defaults/2092-upnpd b/openmptcprouter/files/etc/uci-defaults/2092-upnpd index a89804ab6..34302eb69 100755 --- a/openmptcprouter/files/etc/uci-defaults/2092-upnpd +++ b/openmptcprouter/files/etc/uci-defaults/2092-upnpd @@ -7,4 +7,11 @@ if [ "$(uci -q get upnpd.config.external_ifac)" != "omrvpn" ]; then EOF fi +if [ "$(uci -q get upnpd.@perm_rule[0].ext_ports)" = "1024-65535" ]; then + uci -q batch <<-EOF >/dev/null + set upnpd.@perm_rule[0].ext_ports='1024-64999' + commit upnpd + EOF +fi + exit 0