diff --git a/omr-bypass/files/etc/init.d/omr-bypass b/omr-bypass/files/etc/init.d/omr-bypass index 1d292c55a..133a47529 100755 --- a/omr-bypass/files/etc/init.d/omr-bypass +++ b/omr-bypass/files/etc/init.d/omr-bypass @@ -2,7 +2,6 @@ # Copyright (C) 2018-2020 Ycarus (Yannick Chabanois) START=98 -STOP=10 USE_PROCD=1 EXTRA_COMMANDS="reload_rules bypass_asn" diff --git a/omr-bypass/files/etc/init.d/omr-bypass-nft b/omr-bypass/files/etc/init.d/omr-bypass-nft index ec71b9e0c..b77b45b52 100755 --- a/omr-bypass/files/etc/init.d/omr-bypass-nft +++ b/omr-bypass/files/etc/init.d/omr-bypass-nft @@ -2,7 +2,6 @@ # Copyright (C) 2018-2024 Ycarus (Yannick Chabanois) for OpenMPTCProuter START=98 -STOP=10 USE_PROCD=1 EXTRA_COMMANDS="reload_rules bypass_asn" diff --git a/omr-schedule/files/usr/share/omr/schedule.d/050-rutx b/omr-schedule/files/usr/share/omr/schedule.d/050-rutx index c4a2bc2dc..c0479511b 100755 --- a/omr-schedule/files/usr/share/omr/schedule.d/050-rutx +++ b/omr-schedule/files/usr/share/omr/schedule.d/050-rutx @@ -1,3 +1,4 @@ +#!/bin/sh # # Copyright (C) 2018-2023 Ycarus (Yannick Chabanois) for OpenMPTCProuter # diff --git a/omr-tracker/files/usr/share/omr/lib/common-post-tracking.sh b/omr-tracker/files/usr/share/omr/lib/common-post-tracking.sh index 7219e7d1c..ce39aac89 100755 --- a/omr-tracker/files/usr/share/omr/lib/common-post-tracking.sh +++ b/omr-tracker/files/usr/share/omr/lib/common-post-tracking.sh @@ -330,7 +330,7 @@ set_route_balancing() { local multipath_config_route interface_gw interface_if INTERFACE=$1 [ -z "$INTERFACE" ] && return - [ "$INTERFACE" = "omrvpn" ] && continue + [ "$INTERFACE" = "omrvpn" ] && return multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath) [ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off") [ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && { @@ -390,8 +390,8 @@ set_route_balancing6() { local multipath_config_route interface_gw interface_if INTERFACE=$1 [ -z "$INTERFACE" ] && return - [ "$INTERFACE" = "omr6in4" ] && continue - [ "$INTERFACE" = "omrvpn" ] && continue + [ "$INTERFACE" = "omr6in4" ] && return + [ "$INTERFACE" = "omrvpn" ] && return multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath) [ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off") [ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && { diff --git a/openmptcprouter-api/files/bin/omr-ip-intf b/openmptcprouter-api/files/bin/omr-ip-intf index b5a707690..4a2b925b7 100755 --- a/openmptcprouter-api/files/bin/omr-ip-intf +++ b/openmptcprouter-api/files/bin/omr-ip-intf @@ -7,18 +7,19 @@ timeout=$(uci -q get openmptcprouter.settings.status_getip_timeout) [ -z "$timeout" ] && timeout="1" get_ip_from_server() { + [ -n "$ip" ] && return serverport=$(uci -q get openmptcprouter.$1.port) get_ip() { + [ -n "$ip" ] && return serverip=$1 getip="$(curl -s -k -4 -m ${timeout} --interface $intf https://$serverip:$serverport/clienthost)" [ -n "$getip" ] && getip=$(echo $getip | jsonfilter -e '@.client_host' | sed 's/::ffff://') if expr "$getip" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then ip=$getip - break + return fi } config_list_foreach $1 ip get_ip - [ -n "$ip" ] && break } get_ip_from_website() { @@ -30,7 +31,6 @@ get_ip_from_website() { ipset del ss_rules_dst_bypass_all $checkip > /dev/null 2>&1 if expr "$getip" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then ip=$getip - break fi } diff --git a/openmptcprouter-api/files/bin/omr-ip6-intf b/openmptcprouter-api/files/bin/omr-ip6-intf index 2166441d9..cf833ec85 100755 --- a/openmptcprouter-api/files/bin/omr-ip6-intf +++ b/openmptcprouter-api/files/bin/omr-ip6-intf @@ -7,17 +7,18 @@ timeout=$(uci -q get openmptcprouter.settings.status_getip_timeout) [ -z "$timeout" ] && timeout="1" get_ip_from_server() { + [ -n "$ip" ] && return serverport=$(uci -q get openmptcprouter.$1.port) get_ip() { + [ -n "$ip" ] && return getip="$(curl -s -k -6 -m ${timeout} --interface $intf https://$serverip:$serverport/clienthost)" [ -n "$getip" ] && getip=$(echo $getip | jsonfilter -e '@.client_host') if [ -n "$(echo "$getip" | grep :)" ]; then ip=$getip - break + return fi } config_list_foreach $1 ip get_ip - [ -n "$ip" ] && break } get_ip_from_website() { @@ -29,7 +30,6 @@ get_ip_from_website() { ipset del ss_rules6_dst_bypass_all $checkip > /dev/null 2>&1 if [ -n "$(echo "$getip" | grep :)" ]; then ip=$getip - break fi } diff --git a/openmptcprouter-api/files/bin/omr-mptcp-intf b/openmptcprouter-api/files/bin/omr-mptcp-intf index 4a69b5bcf..0f3233bd6 100755 --- a/openmptcprouter-api/files/bin/omr-mptcp-intf +++ b/openmptcprouter-api/files/bin/omr-mptcp-intf @@ -8,8 +8,10 @@ timeout="$(uci -q get openmptcprouter.settings.status_vps_timeout)" [ -z "$intf" ] && return get_mptcp_from_server() { + [ -n "$support" ] && return serverport=$(uci -q get openmptcprouter.$1.port) get_mptcp() { + [ -n "$support" ] && return serverip=$1 if [ "$(echo $serverip | grep :)" ]; then if [ -f /proc/sys/net/mptcp/enabled ]; then @@ -26,11 +28,10 @@ get_mptcp_from_server() { fi [ -n "$support" ] && { support=$(echo $support | jsonfilter -e '@.mptcp') - break + return } } config_list_foreach $1 ip get_mptcp - [ -n "$support" ] && break } get_mptcpv0_from_website() { diff --git a/openmptcprouter/files/etc/init.d/openmptcprouter-vps b/openmptcprouter/files/etc/init.d/openmptcprouter-vps index 761896bae..95b943f11 100755 --- a/openmptcprouter/files/etc/init.d/openmptcprouter-vps +++ b/openmptcprouter/files/etc/init.d/openmptcprouter-vps @@ -43,6 +43,7 @@ _login() { if [ -z "$token" ]; then login_on_server() { server=$1 + [ -n "$token" ] && return #auth=`curl --max-time 10 -s -k -H "Content-Type: application/json" -X POST -d '{"username":"'$username'","password":"'$password'"}' https://$server:$serverport/login` resolve="$(resolveip -t 5 $server)" valid_ip6=$(valid_subnet6 $server) @@ -61,10 +62,10 @@ _login() { [ -n "$auth" ] && break done fi - [ -z "$auth" ] && return - token="$(echo "$auth" | jsonfilter -q -e '@.access_token')" - uci -q set openmptcprouter.${servername}.token="$token" - [ -n "$token" ] && break + [ -n "$auth" ] && { + token="$(echo "$auth" | jsonfilter -q -e '@.access_token')" + uci -q set openmptcprouter.${servername}.token="$token" + } } config_load openmptcprouter config_list_foreach ${servername} ip login_on_server @@ -1717,7 +1718,7 @@ _set_config_from_vps() { v2ray_key="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.key')" #v2ray_port="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.port')" v2ray_port="65228" - if [ -n "$(uci -q get v2ray.omr)" ] && (([ -n "$v2ray_key" ] && [ "$v2ray_key" != "$(uci -q get v2ray.omrout.s_vmess_user_id)" ]) || ([ -n "$v2ray_port" ] && [ "$v2ray_port" != "$(uci -q get v2ray.omrout.s_vmess.port)" ])); then + if [ -n "$(uci -q get v2ray.omr)" ] && ( ([ -n "$v2ray_key" ] && [ "$v2ray_key" != "$(uci -q get v2ray.omrout.s_vmess_user_id)" ]) || ([ -n "$v2ray_port" ] && [ "$v2ray_port" != "$(uci -q get v2ray.omrout.s_vmess.port)" ]) ); then uci -q batch <<-EOF >/dev/null set v2ray.omrout.s_socks_user_id="$v2ray_key" set v2ray.omrout.s_socks_port="$((v2ray_port+3))" @@ -1749,7 +1750,7 @@ _set_config_from_vps() { xray_vless_reality_key="$(echo "$vps_config" | jsonfilter -q -e '@.xray.config.vless_reality_key')" #v2ray_port="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.port')" xray_port="65248" - if [ -n "$(uci -q get xray.omr)" ] && (([ -n "$xray_key" ] && [ "$xray_key" != "$(uci -q get xray.omrout.s_vmess_user_id)" ]) || ([ -n "$xray_port" ] && [ "$xray_port" != "$(uci -q get xray.omrout.s_vmess.port)" ])); then + if [ -n "$(uci -q get xray.omr)" ] && ( ([ -n "$xray_key" ] && [ "$xray_key" != "$(uci -q get xray.omrout.s_vmess_user_id)" ]) || ([ -n "$xray_port" ] && [ "$xray_port" != "$(uci -q get xray.omrout.s_vmess.port)" ]) ); then uci -q batch <<-EOF >/dev/null set xray.omrout.s_shadowsocks_port="$((xray_port+4))" set xray.omrout.s_shadowsocks_password="$xray_sskey" @@ -1785,7 +1786,7 @@ _set_config_from_vps() { # Glorytun settings glorytun_key="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.key')" glorytun_port="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.port')" - if [ -n "$(uci -q get glorytun.vpn)" ] && (([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun.vpn.port)" ])); then + if [ -n "$(uci -q get glorytun.vpn)" ] && ( ([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun.vpn.port)" ]) ); then vpn="$(uci -q get openmptcprouter.settings.vpn)" glorytun_state=0 if [ "$vpn" = "glorytun_tcp" ]; then @@ -1810,7 +1811,7 @@ _set_config_from_vps() { /etc/init.d/glorytun restart >/dev/null 2>&1 fi fi - if [ -n "$(uci -q get glorytun.udp)" ] && (([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun-udp.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun-udp.vpn.port)" ])); then + if [ -n "$(uci -q get glorytun.udp)" ] && ( ([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun-udp.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun-udp.vpn.port)" ]) ); then vpn="$(uci -q get openmptcprouter.settings.vpn)" glorytun_state=0 if [ "$vpn" = "glorytun_udp" ]; then @@ -1964,7 +1965,7 @@ _set_config_from_vps() { # DSVPN settings dsvpn_key="$(echo "$vps_config" | jsonfilter -q -e '@.dsvpn.key')" dsvpn_port="$(echo "$vps_config" | jsonfilter -q -e '@.dsvpn.port')" - if [ -f /etc/init.d/dsvpn ] && [ -n "$(uci -q get dsvpn.vpn)" ] && (([ -n "$dsvpn_key" ] && [ "$dsvpn_key" != "$(uci -q get dsvpn.vpn.key)" ]) || ([ -n "$dsvpn_port" ] && [ "$dsvpn_port" != "$(uci -q get dsvpn.vpn.port)" ])); then + if [ -f /etc/init.d/dsvpn ] && [ -n "$(uci -q get dsvpn.vpn)" ] && ( ([ -n "$dsvpn_key" ] && [ "$dsvpn_key" != "$(uci -q get dsvpn.vpn.key)" ]) || ([ -n "$dsvpn_port" ] && [ "$dsvpn_port" != "$(uci -q get dsvpn.vpn.port)" ]) ); then dsvpn_state=0 if [ "$vpn" = "dsvpn" ]; then dsvpn_state=1 diff --git a/openmptcprouter/files/etc/init.d/vnstat_backup b/openmptcprouter/files/etc/init.d/vnstat_backup index 1434285d3..3c1e1bdba 100755 --- a/openmptcprouter/files/etc/init.d/vnstat_backup +++ b/openmptcprouter/files/etc/init.d/vnstat_backup @@ -1,10 +1,9 @@ #!/bin/sh /etc/rc.common EXTRA_COMMANDS="backup restore" -EXTRA_HELP=<