mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Merge branch 'develop' into master
This commit is contained in:
commit
bc703d9f2f
133 changed files with 2598 additions and 2014 deletions
|
@ -48,13 +48,29 @@ interface_macaddr_count() {
|
|||
|
||||
interface_max_metric() {
|
||||
local config="$1"
|
||||
config_get metric "$config" metric
|
||||
if [ "$metric" = "$count" ]; then
|
||||
count=$((count+1))
|
||||
config_set "$config" metric $count
|
||||
fi
|
||||
if [ "$metric" -gt "$count" ]; then
|
||||
count=$metric
|
||||
if [ "$1" != "omrvpn" ] && [ "$1" != "omr6in4" ]; then
|
||||
config_get metric "$config" metric
|
||||
if [ "$metric" = "$count" ]; then
|
||||
count=$((count+1))
|
||||
config_set "$config" metric $count
|
||||
fi
|
||||
if [ "$metric" -gt "$count" ]; then
|
||||
count=$metric
|
||||
fi
|
||||
elif [ "$1" = "omrvpn" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set network.${config}.metric=1200
|
||||
commit network
|
||||
set openmptcprouter.${config}.metric=1200
|
||||
commit openmptcprouter
|
||||
EOF
|
||||
elif [ "$1" = "omr6in4" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set network.${config}.metric=1201
|
||||
commit network
|
||||
set openmptcprouter.${config}.metric=1201
|
||||
commit openmptcprouter
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -306,6 +322,7 @@ interface_multipath_settings() {
|
|||
EOF
|
||||
else
|
||||
ip -6 rule add from $ip6addr table 6$id pref 0
|
||||
ip -6 route replace $network6/$netmask6 dev $iface scope link metric 6$id
|
||||
ip -6 route replace $network6/$netmask6 dev $iface scope link table 6$id
|
||||
ip -6 route replace default via $gateway6 dev $iface table 6$id
|
||||
ip -6 route replace default via $gateway6 dev $iface metric $id
|
||||
|
@ -454,17 +471,13 @@ reload_service() {
|
|||
return 0
|
||||
}
|
||||
|
||||
add_interface_trigger() {
|
||||
local interface ignore
|
||||
|
||||
config_get interface "$1" interface
|
||||
config_get_bool ignore "$1" ignore 0
|
||||
|
||||
[ -n "$interface" -a $ignore -eq 0 ] && procd_add_interface_trigger "interface.*" "$interface" /etc/init.d/mptcp reload
|
||||
}
|
||||
service_triggers_load_interface() { ifaces="${ifaces}${1} "; }
|
||||
|
||||
service_triggers() {
|
||||
local ifaces n
|
||||
config_load network; config_foreach service_triggers_load_interface 'interface';
|
||||
procd_add_reload_trigger "network"
|
||||
config_load network
|
||||
config_foreach add_interface_trigger interface
|
||||
procd_open_trigger
|
||||
for n in $ifaces; do procd_add_reload_interface_trigger "$n"; procd_add_interface_trigger "interface.*" "$n" /etc/init.d/mptcp reload; done;
|
||||
procd_close_trigger
|
||||
}
|
||||
|
|
|
@ -247,10 +247,12 @@ disable_pihole() {
|
|||
if [ -n "$(uci -q get dhcp.@dnsmasq[0].server | grep '#53' | grep '10.2')" ]; then
|
||||
_log "Disable Pi-Hole..."
|
||||
uci -q del_list dhcp.@dnsmasq[0].server="$(uci -q get dhcp.@dnsmasq[0].server | tr ' ' '\n' | grep '#53' | grep '10.2')"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add_list dhcp.@dnsmasq[0].server='127.0.0.1#5353'
|
||||
commit dhcp
|
||||
EOF
|
||||
if [ -z "$(uci -q get dhcp.@dnsmasq[0].server | grep '127.0.0.1#5353')" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add_list dhcp.@dnsmasq[0].server='127.0.0.1#5353'
|
||||
commit dhcp
|
||||
EOF
|
||||
fi
|
||||
/etc/init.d/dnsmasq restart
|
||||
fi
|
||||
}
|
||||
|
@ -316,7 +318,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
|
|||
# multipath "$OMR_TRACKER_DEVICE" off > /dev/null 2>&1
|
||||
#fi
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
|
||||
glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 set down > /dev/null 2>&1
|
||||
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set down > /dev/null 2>&1
|
||||
fi
|
||||
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" = "1" ]; then
|
||||
VPN_BASE_INTF="$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.baseintf)"
|
||||
|
@ -369,7 +371,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
|
|||
config_load network
|
||||
config_foreach set_route interface $OMR_TRACKER_INTERFACE
|
||||
fi
|
||||
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get openmptcprouter.omr.shadowsocks)" = "up" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q get shadowsocks-libev.hi2.mode)" = "tcp_and_udp" ] && [ "$(uci -q get shadowsocks-libev.sss0.obfs)" != "1" ]; then
|
||||
if [ "$(uci -q get openmptcprouter.settings.shadowsocksudp)" = "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get openmptcprouter.omr.shadowsocks)" = "up" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q get shadowsocks-libev.hi2.mode)" = "tcp_and_udp" ] && [ "$(uci -q get shadowsocks-libev.sss0.obfs)" != "1" ]; then
|
||||
_log "Tunnel down use ShadowSocks for UDP"
|
||||
uci -q set shadowsocks-libev.ss_rules.redir_udp='hi2'
|
||||
if /etc/init.d/shadowsocks-libev rules_exist ; then
|
||||
|
@ -378,13 +380,19 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
|
|||
fi
|
||||
fi
|
||||
if [ "$(uci -q get dsvpn.vpn.enable)" = "1" ]; then
|
||||
_log "DSVPN down, restart it"
|
||||
/etc/init.d/dsvpn restart
|
||||
fi
|
||||
if [ "$(uci -q get mlvpn.general.enable)" = "1" ]; then
|
||||
_log "MLVPN down, restart it"
|
||||
/etc/init.d/mlvpn restart
|
||||
fi
|
||||
if [ "$(uci -q get glorytun.vpn.enable)" = "1" ]; then
|
||||
_log "Glorytun VPN down, restart it"
|
||||
/etc/init.d/glorytun restart
|
||||
fi
|
||||
if [ "$(uci -q get glorytun-udp.vpn.enable)" = "1" ]; then
|
||||
_log "Glorytun UDP VPN down, restart it"
|
||||
/etc/init.d/glorytun-udp restart
|
||||
fi
|
||||
config_load openmptcprouter
|
||||
|
@ -433,7 +441,7 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
|
|||
fi
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE="interface"
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
|
||||
if [ "$(uci -q get glorytun.vpn.enable)" != "1" ]; then
|
||||
if [ "$(uci -q get glorytun.vpn.enable)" != "1" ] || [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ]; then
|
||||
if [ -n "$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)" ]; then
|
||||
mtu=$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
|
||||
|
@ -559,7 +567,7 @@ if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
[ "$multipath_config" = "on" ] && {
|
||||
if [ "$multipath_config" = "on" ] || [ "$multipath_config" = "backup" ]; then
|
||||
download="$(uci -q get network.$OMR_TRACKER_INTERFACE.downloadspeed)"
|
||||
[ -z "$download" ] && download="$(uci -q get sqm.$OMR_TRACKER_INTERFACE.download)"
|
||||
upload="$(uci -q get network.$OMR_TRACKER_INTERFACE.uploadspeed)"
|
||||
|
@ -567,38 +575,28 @@ fi
|
|||
if [ "$(uci -q show | grep mptcpr)" = "" ]; then
|
||||
touch /etc/config/openmptcprouter
|
||||
fi
|
||||
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && ([ "$(glorytun-udp path | grep $OMR_TRACKER_DEVICE_IP)" = "" ] || [ "$(glorytun-udp path $OMR_TRACKER_DEVICE_IP | awk '{print $13}')" = "0" ] || [ "$(glorytun-udp path $OMR_TRACKER_DEVICE_IP | awk '{print $16}')" = "0" ]); then
|
||||
gtudpst="up"
|
||||
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" != "1" ] && [ "$multipath_config" = "backup" ] && [ "$(pgrep glorytun-udp)" != "" ] && gtudpst="backup"
|
||||
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp path | grep $OMR_TRACKER_DEVICE_IP)" = "" ]; then
|
||||
if [ "$download" != "0" ] && [ "$download" != "" ] && [ "$upload" != "0" ] && [ "$upload" != "" ]; then
|
||||
if [ "$(uci -q get glorytun.vpn.rateauto)" = "1" ]; then
|
||||
glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 set up rate auto tx $((upload*1000/8)) rx $((download*1000/8)) > /dev/null 2>&1
|
||||
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
|
||||
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate auto tx $((upload*1000/8)) rx $((download*1000/8)) > /dev/null 2>&1
|
||||
else
|
||||
glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 set up rate fixed tx $((upload*1000/8)) rx $((download*1000/8)) > /dev/null 2>&1
|
||||
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate fixed tx $((upload*1000/8)) rx $((download*1000/8)) > /dev/null 2>&1
|
||||
fi
|
||||
else
|
||||
if [ "$(uci -q get glorytun.vpn.rateauto)" = "1" ]; then
|
||||
glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 set up rate auto tx 12500000 rx 12500000 > /dev/null 2>&1
|
||||
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
|
||||
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate auto tx 12500000 rx 12500000 > /dev/null 2>&1
|
||||
else
|
||||
glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 set up rate fixed tx 12500000 rx 12500000 > /dev/null 2>&1
|
||||
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate fixed tx 12500000 rx 12500000 > /dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" = "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && ([ "$(glorytun-udp path | grep $OMR_TRACKER_DEVICE_IP)" = "" ] || [ "$(glorytun-udp path $OMR_TRACKER_DEVICE_IP | awk '{print $13}')" = "0" ] || [ "$(glorytun-udp path $OMR_TRACKER_DEVICE_IP | awk '{print $16}')" = "0" ]); then
|
||||
# if [ "$download" != "0" ] && [ "$download" != "" ] && [ "$upload" != "0" ] && [ "$upload" != "" ]; then
|
||||
# if [ "$(uci -q get glorytun.vpn.rateauto)" = "1" ]; then
|
||||
# glorytun-udp path $OMR_TRACKER_DEVICE_IP to 10.255.250.1 $(uci -q get glorytun.vpn.port) dev tun0 set up rate auto tx ${upload}000 rx ${download}000 > /dev/null 2>&1
|
||||
# else
|
||||
# glorytun-udp path $OMR_TRACKER_DEVICE_IP to 10.255.250.1 $(uci -q get glorytun.vpn.port) dev tun0 set up rate fixed tx ${upload}000 rx ${download}000 > /dev/null 2>&1
|
||||
# fi
|
||||
# else
|
||||
# if [ "$(uci -q get glorytun.vpn.rateauto)" = "1" ]; then
|
||||
# glorytun-udp path $OMR_TRACKER_DEVICE_IP to 10.255.250.1 $(uci -q get glorytun.vpn.port) dev tun0 set up rate auto tx 125000000 rx 125000000 > /dev/null 2>&1
|
||||
# else
|
||||
# glorytun-udp path $OMR_TRACKER_DEVICE_IP to 10.255.250.1 $(uci -q get glorytun.vpn.port) dev tun0 set up rate fixed tx 125000000 rx 125000000 > /dev/null 2>&1
|
||||
# fi
|
||||
# fi
|
||||
# if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp set | grep 'kxtimeout 7d')" = "" ]; then
|
||||
# glorytun-udp set dev tun0 kxtimeout 7d > /dev/null 2>&1
|
||||
# fi
|
||||
}
|
||||
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" != "1" ] && [ "$multipath_config" = "backup" ] && [ "$(pgrep glorytun-udp)" != "" ] && glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 set backup rate auto rx 125000000 tx 125000000 > /dev/null 2>&1
|
||||
[ "$multipath_config" = "backup" ] && [ "$(pgrep glorytun-udp)" != "" ] && glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set pref 500 > /dev/null 2>&1
|
||||
fi
|
||||
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" != "1" ] && {
|
||||
[ "$multipath_status" = "$multipath_config" ] || {
|
||||
if [ "$(sysctl -n net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ]; then
|
||||
|
@ -670,26 +668,28 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
|
|||
[ -n "$asn" ] && {
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.asn="$asn"
|
||||
}
|
||||
if [ -n "$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)" ]; then
|
||||
mtu=$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)
|
||||
[ -n "$mtu" ] && {
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
|
||||
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
|
||||
}
|
||||
else
|
||||
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && {
|
||||
local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP $serverip)
|
||||
if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ]; then
|
||||
if [ -n "$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)" ]; then
|
||||
mtu=$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)
|
||||
[ -n "$mtu" ] && {
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
|
||||
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
|
||||
}
|
||||
} || {
|
||||
local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP 1.1.1.1)
|
||||
[ -n "$mtu" ] && {
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
|
||||
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
|
||||
else
|
||||
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && {
|
||||
local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP $serverip)
|
||||
[ -n "$mtu" ] && {
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
|
||||
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
|
||||
}
|
||||
} || {
|
||||
local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP 1.1.1.1)
|
||||
[ -n "$mtu" ] && {
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
|
||||
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
|
||||
}
|
||||
}
|
||||
}
|
||||
fi
|
||||
fi
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
|
||||
|
@ -725,7 +725,12 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
|
|||
else
|
||||
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Get status and settings for $OMR_TRACKER_INTERFACE... Done"
|
||||
uci -q commit openmptcprouter
|
||||
#/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1
|
||||
if [ "$(pgrep openmptcprouter-vps)" = "" ] && ( [ "$(uci -q get openmptcprouter.settings.apilc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.settings.apilc))) -gt 3600 ] ); then
|
||||
_log "Check API configuration..."
|
||||
/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1
|
||||
uci -q set openmptcprouter.settings.apilc=$(date +"%s")
|
||||
_log "Check API configuration... Done"
|
||||
fi
|
||||
fi
|
||||
dns_flush
|
||||
fi
|
||||
|
@ -773,6 +778,10 @@ fi
|
|||
if [ "$(pgrep glorytun)" = "" ] && [ "$(uci -q get glorytun.vpn.enable)" = "1" ] && [ -f /etc/init.d/glorytun ] && [ "$(uci -q get glorytun.vpn.key)" != "" ]; then
|
||||
_log "Can't find Glorytun, restart it..."
|
||||
/etc/init.d/glorytun restart
|
||||
sleep 5
|
||||
fi
|
||||
if [ "$(pgrep glorytun-udp)" = "" ] && [ "$(uci -q get glorytun-usp.vpn.enable)" = "1" ] && [ -f /etc/init.d/glorytun-udp ] && [ "$(uci -q get glorytun-udp.vpn.key)" != "" ]; then
|
||||
_log "Can't find Glorytun UDP, restart it..."
|
||||
/etc/init.d/glorytun-udp restart
|
||||
sleep 5
|
||||
fi
|
||||
|
@ -812,6 +821,12 @@ if [ "$(pgrep v2ray)" = "" ] && [ "$(uci -q get v2ray.main.enabled)" = "1" ] &&
|
|||
sleep 5
|
||||
fi
|
||||
|
||||
if [ "$(pgrep rpcd)" = "" ] && [ -f /etc/init.d/rpcd ]; then
|
||||
_log "Can't find rpcd, restart it..."
|
||||
/etc/init.d/rpcd restart
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -f /etc/init.d/v2ray ] && [ "$(pgrep -f omr-tracker-v2ray)" = "" ]; then
|
||||
_log "Can't find omr-tracker-v2ray, restart omr-tracker..."
|
||||
/etc/init.d/omr-tracker restart
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue