mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-15 03:51:51 +00:00
commit
86b7f82ca0
4 changed files with 48 additions and 31 deletions
|
@ -300,10 +300,10 @@ interface_multipath_settings() {
|
|||
else
|
||||
[ -n "$ipaddr" ] && [ -z "$(ip rule show from $ipaddr table $id)" ] && ip rule add from $ipaddr table $id pref 0
|
||||
[ -z "$(ip rule show oif $iface table $id)" ] && ip rule add oif $iface table $id pref 0
|
||||
ip route replace $network/$netmask dev $iface scope link metric $id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace $network/$netmask dev $iface scope link table $id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace default via $gateway dev $iface table $id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip route replace default via $gateway dev $iface metric $id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace $network/$netmask dev $iface scope link metric $id $initcwrwnd 2>&1 >/dev/null
|
||||
ip route replace $network/$netmask dev $iface scope link table $id $initcwrwnd 2>&1 >/dev/null
|
||||
ip route replace default via $gateway dev $iface table $id $initcwrwnd 2>&1 >/dev/null
|
||||
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip route replace default via $gateway dev $iface metric $id $initcwrwnd 2>&1 >/dev/null
|
||||
#ip route flush $id
|
||||
fi
|
||||
|
||||
|
@ -390,10 +390,10 @@ interface_multipath_settings() {
|
|||
else
|
||||
[ -n "$ip6addr" ] && ip -6 rule add from $ip6addr table 6$id pref 0 2>&1 >/dev/null
|
||||
[ -z "$(ip rule show pref 0 table 6$id oif $iface)" ] && ip rule add oif $iface table 6$id pref 0
|
||||
ip -6 route replace $network6/$netmask6 dev $iface scope link metric 6$id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip -6 route replace $network6/$netmask6 dev $iface scope link table 6$id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip -6 route replace default via $gateway6 dev $iface table 6$id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip -6 route replace default via $gateway6 dev $iface metric 6$id initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip -6 route replace $network6/$netmask6 dev $iface scope link metric 6$id $initcwrwnd 2>&1 >/dev/null
|
||||
ip -6 route replace $network6/$netmask6 dev $iface scope link table 6$id $initcwrwnd 2>&1 >/dev/null
|
||||
ip -6 route replace default via $gateway6 dev $iface table 6$id $initcwrwnd 2>&1 >/dev/null
|
||||
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip -6 route replace default via $gateway6 dev $iface metric 6$id $initcwrwnd 2>&1 >/dev/null
|
||||
#ip -6 route flush 6$id 2>&1 >/dev/null
|
||||
fi
|
||||
|
||||
|
@ -517,6 +517,7 @@ start_service() {
|
|||
config_load openmptcprouter
|
||||
config_foreach interface_max_metric interface
|
||||
|
||||
initcwrwnd=""
|
||||
config_load network
|
||||
#config_foreach remove route
|
||||
#config_foreach remove route6
|
||||
|
|
|
@ -57,8 +57,8 @@ set_route() {
|
|||
if [ "$interface_gw" != "" ] && [ "$interface_if" != "" ]; then
|
||||
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && [ "$SETDEFAULT" = "yes" ] && _log "$PREVINTERFACE down. Replace default route by $interface_gw dev $interface_if"
|
||||
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && [ "$SETDEFAULT" != "yes" ] && _log "$PREVINTERFACE down. Replace default in table 991337 route by $interface_gw dev $interface_if"
|
||||
[ "$SETDEFAULT" = "yes" ] && [ "$(uci -q openmptcprouter.settings.defaultgw)" != "0" ] && ip route replace default scope global metric 1 via $interface_gw dev $interface_if initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace default via $interface_gw dev $interface_if table 991337 initcwnd 10 initrwnd 10 2>&1 >/dev/null && SETROUTE=true
|
||||
[ "$SETDEFAULT" = "yes" ] && [ "$(uci -q openmptcprouter.settings.defaultgw)" != "0" ] && ip route replace default scope global metric 1 via $interface_gw dev $interface_if $initcwrwnd 2>&1 >/dev/null
|
||||
ip route replace default via $interface_gw dev $interface_if table 991337 $initcwrwnd 2>&1 >/dev/null && SETROUTE=true
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ set_server_default_route() {
|
|||
if [ "$(ip r show $serverip | grep nexthop)" != "" ]; then
|
||||
ip r delete $serverip >/dev/null 2>&1
|
||||
fi
|
||||
ip route replace $serverip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric 1 initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace $serverip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric 1 $initcwrwnd 2>&1 >/dev/null
|
||||
fi
|
||||
}
|
||||
config_list_foreach $server ip server_route
|
||||
|
@ -577,12 +577,12 @@ set_server_route() {
|
|||
#if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(ip route show dev $OMR_TRACKER_DEVICE metric $metric | grep $serverip | grep $OMR_TRACKER_DEVICE_GATEWAY)" = "" ] && [ "$multipath_config_route" != "off" ] && [ "$multipath_current_config" = "" ]; then
|
||||
if [ "$serverip" != "" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(ip route show dev $OMR_TRACKER_DEVICE metric $metric | grep $serverip | grep $OMR_TRACKER_DEVICE_GATEWAY)" = "" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
|
||||
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Set server $server ($serverip) route via $OMR_TRACKER_DEVICE_GATEWAY metric $metric"
|
||||
ip route replace $serverip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace $serverip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric $initcwrwnd 2>&1 >/dev/null
|
||||
fi
|
||||
}
|
||||
config_list_foreach $server ip server_route
|
||||
if [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && [ -n "$metric" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip route show dev $OMR_TRACKER_DEVICE metric $metric | grep default | grep $OMR_TRACKER_DEVICE_GATEWAY)" = "" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric $initcwrwnd 2>&1 >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -724,6 +724,8 @@ default_gw6=$(ip -6 route get 2606:4700:4700::1111 | grep via | awk '{print $3}'
|
|||
|
||||
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
|
||||
|
||||
initcwrwnd=""
|
||||
|
||||
# An interface in error will never be used in MPTCP
|
||||
if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
|
||||
if [ "$interface_up" = "true" ] && [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "modemmanager" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "wireguard" ]); then
|
||||
|
@ -918,7 +920,7 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
|
|||
if ([ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ]; then
|
||||
_log "Tunnel up : Replace default route by $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE"
|
||||
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Default gw : $default_gw - Current route: $(ip r)"
|
||||
ip route replace default scope global via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace default scope global via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE $initcwrwnd 2>&1 >/dev/null
|
||||
if [ "$(pgrep -f openmptcprouter-vps)" = "" ]; then
|
||||
/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 &
|
||||
fi
|
||||
|
@ -942,7 +944,7 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
|
|||
if [ -n "$OMR_NETWORK_DEVICE" ] && [ -n "$(uci -q get network.$OMR_NETWORK_DEVICE.mtu)" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
|
||||
mtu=$(uci -q get network.$OMR_NETWORK_DEVICE.mtu)
|
||||
uci -q set openmptcprouter.${OMR_TRACKER_INTERFACE}.mtu=$mtu
|
||||
[ -n "$mtu" ] && ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
|
||||
[ -n "$mtu" ] && [ "$(ip --json link show dev eth3 | jsonfilter -e '@[0].mtu' | tr -d '\n')" != "$mtu" ] && ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
|
||||
elif [ -z "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.mtu)" ] && [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
|
||||
if [ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ]; then
|
||||
|
@ -1035,7 +1037,7 @@ if [ "$multipath_config" = "master" ]; then
|
|||
[ -z "$omrvpn_intf" ] && omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun0")
|
||||
if [ -n "$omrvpn_intf" ] && [ "$(ip route show default | grep -v metric | awk '/default/ {print $5}' | grep $omrvpn_intf)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
|
||||
_log "Master up : Replace default route by $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE"
|
||||
ip route replace default scope global metric 1 via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace default scope global metric 1 via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE $initcwrwnd 2>&1 >/dev/null
|
||||
fi
|
||||
config_load openmptcprouter
|
||||
#if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ]; then
|
||||
|
@ -1122,10 +1124,10 @@ if [ "$multipath_config" = "master" ]; then
|
|||
fi
|
||||
fi
|
||||
if [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip r show table 991337)" != "default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE " ]; then
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE table 991337 initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE table 991337 $initcwrwnd 2>&1 >/dev/null
|
||||
fi
|
||||
if [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip -6 r show table 991337)" != "default via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE " ]; then
|
||||
ip -6 route replace default via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE table 991337 initcwnd 10 initrwnd 10 2>&1 >/dev/null
|
||||
ip -6 route replace default via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE table 991337 $initcwrwnd 2>&1 >/dev/null
|
||||
fi
|
||||
if ([ -n "$OMR_TRACKER_INTERFACE" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ]) || [ $(($(date +"%s") + $((10 + RANDOM % 31)) - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ] || [ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]; then
|
||||
[ "$(pgrep -f openmptcprouter-vps)" = "" ] && /etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 &
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
#!/bin/sh
|
||||
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||
#!/bin/sh
|
||||
# (c) Yannick Chabanois (ycarus@zugaina.org) for OpenMPTCProuter
|
||||
#
|
||||
#
|
||||
|
||||
FORCEVPS=false
|
||||
FASTTEST=false
|
||||
if [ "$1" = "forcevps" ]; then
|
||||
FORCEVPS=true
|
||||
INTERFACE="$2"
|
||||
else
|
||||
INTERFACE="$1"
|
||||
FORCEVPS=true
|
||||
fi
|
||||
if [ "$1" = "fasttest" ]; then
|
||||
FASTTEST=true
|
||||
fi
|
||||
for i in $@; do :; done
|
||||
INTERFACE="$i"
|
||||
|
||||
[ -n "$INTERFACE" ] && [ ! -d "/sys/class/net/$INTERFACE" ] && {
|
||||
echo "You must use a real interface. You wan find them using 'ip a' for example"
|
||||
|
@ -14,7 +21,7 @@ fi
|
|||
}
|
||||
|
||||
|
||||
echo "Select best test server..."
|
||||
[ "$FASTTEST" = true ] || echo "Select best test server..."
|
||||
HOSTLST="http://scaleway.testdebit.info/10G.iso http://bordeaux.testdebit.info/10G.iso http://aix-marseille.testdebit.info/10G.iso http://lyon.testdebit.info/10G.iso http://lille.testdebit.info/10G.iso http://paris.testdebit.info/10G.iso http://appliwave.testdebit.info/10G/10G.iso http://speedtest.frankfurt.linode.com/garbage.php?ckSize=10000 http://speedtest.tokyo2.linode.com/garbage.php?ckSize=10000 http://speedtest.singapore.linode.com/garbage.php?ckSize=10000 http://speedtest.newark.linode.com/garbage.php?ckSize=10000 http://speedtest.atlanta.linode.com/garbage.php?ckSize=10000 http://speedtest.dallas.linode.com/garbage.php?ckSize=10000 http://speedtest.fremont.linode.com/garbage.php?ckSize=10000 https://speed.hetzner.de/10GB.bin http://ipv6.bouygues.testdebit.info/10G.iso http://par.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin http://ams.download.datapacket.com/10000mb.bin http://fra.download.datapacket.com/10000mb.bin http://lon.download.datapacket.com/10000mb.bin http://mad.download.datapacket.com/10000mb.bin http://prg.download.datapacket.com/10000mb.bin http://sto.download.datapacket.com/10000mb.bin http://vie.download.datapacket.com/10000mb.bin http://war.download.datapacket.com/10000mb.bin http://atl.download.datapacket.com/10000mb.bin http://chi.download.datapacket.com/10000mb.bin http://lax.download.datapacket.com/10000mb.bin http://mia.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin http://speedtest.milkywan.fr/files/10G.iso"
|
||||
bestping="9999"
|
||||
for pinghost in $HOSTLST; do
|
||||
|
@ -24,7 +31,7 @@ for pinghost in $HOSTLST; do
|
|||
else
|
||||
ping=$(ping -6 -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1)
|
||||
fi
|
||||
echo "host: $domain - ping: $ping"
|
||||
[ "$FASTTEST" = true ] || echo "host: $domain - ping: $ping"
|
||||
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
|
||||
bestping=$ping
|
||||
HOST=$pinghost
|
||||
|
@ -34,11 +41,12 @@ fi
|
|||
|
||||
[ -z "$HOST" ] && HOST="https://speed.hetzner.de/10GB.bin"
|
||||
|
||||
echo "Best server is $HOST, running test:"
|
||||
[ "$FASTTEST" = true ] || echo "Best server is $HOST, running test:"
|
||||
trap : HUP INT TERM
|
||||
if [ -z "$INTERFACE" ]; then
|
||||
curl -6 $HOST >/dev/null || echo
|
||||
else
|
||||
/etc/init.d/sqm stop $INTERFACE
|
||||
domain=$(echo $HOST | awk -F/ '{print $3}')
|
||||
hostip=$(dig +nocmd +noall +answer AAAA $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ')
|
||||
if [ -n "$(ipset list 2>/dev/null | grep ss_rules6)" ]; then
|
||||
|
@ -46,10 +54,16 @@ else
|
|||
ipset add ss_rules6_dst_bypass_all $ip
|
||||
done
|
||||
fi
|
||||
curl -6 --interface $INTERFACE $HOST >/dev/null || echo
|
||||
if [ "$FASTTEST" = true ]; then
|
||||
avg_speed=$(curl -6 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE $HOST 2>/dev/null)
|
||||
echo "$avg_speed"
|
||||
else
|
||||
curl -6 --interface $INTERFACE $HOST >/dev/null || echo
|
||||
fi
|
||||
if [ -n "$(ipset list 2>/dev/null | grep ss_rules6)" ]; then
|
||||
for ip in $hostip; do
|
||||
ipset del ss_rules6_dst_bypass_all $ip
|
||||
done
|
||||
fi
|
||||
/etc/init.d/sqm start $INTERFACE
|
||||
fi
|
||||
|
|
|
@ -5,11 +5,11 @@ fs.file-max = 512000
|
|||
net.core.rmem_max = 16777216
|
||||
# max write buffer
|
||||
net.core.wmem_max = 16777216
|
||||
net.core.optmem_max = 33554432
|
||||
#net.core.optmem_max = 33554432
|
||||
# default read buffer
|
||||
#net.core.rmem_default = 16777216
|
||||
net.core.rmem_default = 16777216
|
||||
# default write buffer
|
||||
#net.core.wmem_default = 16777216
|
||||
net.core.wmem_default = 16777216
|
||||
# max processor input queue
|
||||
net.core.netdev_max_backlog = 8192
|
||||
# max backlog
|
||||
|
@ -40,7 +40,7 @@ net.ipv4.tcp_rmem = 4096 87380 16777216
|
|||
# TCP write buffer
|
||||
net.ipv4.tcp_wmem = 4096 87380 16777216
|
||||
# TCP buffer
|
||||
net.ipv4.tcp_mem = 8192000 8192000 8192000
|
||||
net.ipv4.tcp_mem = 1638400 1638400 1638400
|
||||
# UDP buffer
|
||||
net.ipv4.udp_mem = 4096 131072 67108864
|
||||
# turn off path MTU discovery
|
||||
|
|
Loading…
Reference in a new issue