1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Merge branch 'test' into develop

This commit is contained in:
suyuan 2020-10-08 10:51:08 +08:00
commit ff9d520ecc
57 changed files with 5930 additions and 1422 deletions

View file

@ -0,0 +1,35 @@
#!/bin/sh
INTERFACE="$1"
echo "Download server list..."
wget -q -O /tmp/speedtest.lst http://c.speedtest.net/speedtest-servers-static.php
bestuploadurl=""
besthost=""
bestpinghost=""
bestping="999"
echo "Select best server..."
while read line; do
if [ "$(echo $line | grep url)" != "" ]; then
pinghost=$(echo $line | awk -F'"' '{print $18}' | cut -d: -f1)
host=$(echo $line | awk -F'"' '{print $18}')
uploadurl=$(echo $line | awk -F'"' '{print $2}')
ping=$(ping -c1 -w1 $pinghost | cut -d "/" -s -f5 | cut -d "." -f1)
echo -n "."
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
bestping=$ping
bestuploadurl=$uploadurl
besthost=$host
bestpinghost=$pinghost
fi
fi
done < /tmp/speedtest.lst
echo
echo "Done: url: $bestuploadurl - host: $besthost - ping: $bestping"
echo "Download test:"
if [ -z "$INTERFACE" ]; then
curl -4 $besthost/speedtest/random7000x7000.jpg >/dev/null || echo
else
hostip=$(dig +short $bestpinghost | tr -d "\n")
ipset add ss_rules_dst_bypass_all $hostip
curl -4 --interface $INTERFACE $besthost/speedtest/random7000x7000.jpg >/dev/null || echo
ipset del ss_rules_dst_bypass_all $hostip
fi

View file

@ -1,15 +1,34 @@
#!/bin/sh
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
INTERFACE="$1"
HOST="proof.ovh.net"
echo "Select best test server..."
HOSTLST="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 http://speedtest.tele2.net/1000GB.zip http://www.ovh.net/files/10Gb.dat https://speed.hetzner.de/10GB.bin http://ipv4.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"
bestping="999"
for pinghost in $HOSTLST; do
domain=$(echo $pinghost | awk -F/ '{print $3}')
if [ -z "$INTERFACE" ]; then
ping=$(ping -c1 -w2 $domain | cut -d "/" -s -f5 | cut -d "." -f1)
else
ping=$(ping -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1)
fi
echo "host: $domain - ping: $ping"
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
bestping=$ping
HOST=$pinghost
fi
done
[ -z "$HOST" ] && HOST="http://proof.ovh.net/files/10Gio.dat"
echo "Best server is $HOST, running test:"
trap : HUP INT TERM
if [ -z "$INTERFACE" ]; then
curl -4 http://$HOST/files/10Gio.dat >/dev/null || echo
curl -4 $HOST >/dev/null || echo
else
hostip=$(dig +short A $HOST | tr -d "\n")
domain=$(echo $HOST | awk -F/ '{print $3}')
hostip=$(dig +short A $domain | tr -d "\n")
ipset add ss_rules_dst_bypass_all $hostip
curl -4 --interface $INTERFACE http://$HOST/files/10Gio.dat >/dev/null || echo
curl -4 $HOST >/dev/null || echo
ipset del ss_rules_dst_bypass_all $hostip
fi

View file

@ -21,7 +21,7 @@ mptcp_over_vpn() {
logger -t "MPTCPoverVPN" "Enable MPTCP over VPN for ${interface}"
id=$(uci -q get network.${interface}.metric)
remoteip=""
config_load_openmptcprouter
config_load openmptcprouter
config_foreach _getremoteip server
localip=$(ubus call network.interface.$interface status | jsonfilter -e '@["ipv4-address"][0].address' | tr -d "\n")
[ -z "$(uci -q get openmptcprouter.ovpn${interface}.multipath)" ] && multipath=$(uci -q get network.${interface}.multipath)
@ -64,6 +64,13 @@ mptcp_over_vpn() {
add_list firewall.zone_vpn.network="ovpn${interface}"
commit firewall
EOF
else
uci -q batch <<-EOF >/dev/null
set network.${interface}.multipath='off'
commit network
set openmptcprouter.${interface}.multipath="off"
commit openmptcprouter
EOF
fi
elif [ "$(uci -q get openmptcprouter.ovpn${interface})" != "" ]; then
logger -t "MPTCPoverVPN" "Disable MPTCP over VPN for ${interface}"

View file

@ -714,6 +714,8 @@ _vps_firewall_redirect_port() {
config_get family $1 family "ipv4"
config_get enabled $1 enabled "1"
config_get src_dip $1 src_dip
config_get dest_ip $1 dest_ip
config_get dest_port $1 dest_port
config_get src_ip $1 src_ip
if [ "$(echo $src_dport | cut -d'-' -f2)" -ge "65000" ]; then
logger -t "OMR-VPS" "You can't redirect ports >= 65000, they are needed by OpenMPTCProuter Server part"
@ -731,7 +733,10 @@ _vps_firewall_redirect_port() {
checkfw=$(echo "$vpsfwlist" | grep "$src_dport # OMR $username redirect router $src_dport port $protoi")
else
comment=""
[ -n "$src_dip" ] && comment=" to $src_dip"
[ -n "$src_dip" ] && {
comment=" to $src_dip"
iptables-save --counters | sed "s:-d $src_dip/32::g" | iptables-restore -w
}
[ -n "$src_ip" ] && comment=" from $src_ip"
checkfw=$(echo "$vpsfwlist" | grep "# OMR $username redirect router $src_dport port $protoi${comment}")
fi
@ -843,6 +848,7 @@ _set_vps_firewall() {
vpsfw6list=$(echo $fw6_list | jsonfilter -q -e '@.list[*]' | sed '/^[[:space:]]*$/d')
config_load firewall
config_foreach _vps_firewall_redirect_port redirect
config_foreach _vps_firewall_redirect_port rule
[ -n "$vpsfwlist" ] || [ -n "$vpsfw6list" ] && {
logger -t "OMR-VPS" "Remove old firewall rules"
_vps_firewall_close_port
@ -1326,7 +1332,7 @@ _backup_get_and_apply() {
backup_sha256sum="$(echo "$vps_backup" | jsonfilter -q -e '@.sha256sum')"
[ -n "$backup_data" ] && {
echo $backup_data | base64 -d > /tmp/backup.tar.gz
sysupgrade -t /tmp/backup.tar.gz
sysupgrade -r /tmp/backup.tar.gz
}
}