1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
This commit is contained in:
suyuan 2024-12-21 10:51:45 +08:00 committed by GitHub
commit d3136e1834
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 602 additions and 259 deletions

View file

@ -830,8 +830,15 @@ function wizard_add()
ucic:set("xray","omrout","s_trojan_address",server_ip)
ucic:set("xray","omrout","s_socks_address",server_ip)
ucic:set("xray","omrout","s_shadowsocks_address",server_ip)
luci.sys.call("uci -q del openvpn.omr.remote")
luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
luci.sys.call("uci -q del openvpn." .. sectionname .. ".remote")
luci.sys.call("uci -q add_list openvpn." .. sectioname .. ".remote=" .. server_ip)
end
end)
--luci.sys.call("uci -q del openvpn.omr.remote")
--luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
ucic:set("qos","serverin","srchost",server_ip)
ucic:set("qos","serverout","dsthost",server_ip)
local nbip = 0
@ -882,8 +889,15 @@ function wizard_add()
ucic:set("xray","omrout","s_trojan_address",server_ip)
ucic:set("xray","omrout","s_socks_address",server_ip)
ucic:set("xray","omrout","s_shadowsocks_address",server_ip)
luci.sys.call("uci -q del openvpn.omr.remote")
luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
luci.sys.call("uci -q del openvpn." .. sectionname .. ".remote")
luci.sys.call("uci -q add_list openvpn." .. sectionname .. ".remote=" .. server_ip)
end
end)
--luci.sys.call("uci -q del openvpn.omr.remote")
--luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
ucic:set("qos","serverin","srchost",server_ip)
ucic:set("qos","serverout","dsthost",server_ip)
local nbip = 0
@ -938,7 +952,13 @@ function wizard_add()
ucic:set("shadowsocks-libev","sss1","method","none")
ucic:set("shadowsocks-rust","sss0","method","none")
ucic:set("shadowsocks-rust","sss1","method","none")
ucic:set("openvpn","omr","cipher","none")
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
ucic:set("openvpn",sectionname,"cipher","none")
end
end)
--ucic:set("openvpn","omr","cipher","none")
ucic:set("mlvpn","general","cleartext_data","1")
ucic:set("v2ray","omrout","s_vmess_user_security","none")
ucic:set("v2ray","omrout","s_vless_user_security","none")
@ -957,7 +977,13 @@ function wizard_add()
ucic:set("shadowsocks-libev","sss1","method","aes-256-gcm")
ucic:set("glorytun","vpn","chacha20","0")
ucic:set("glorytun-udp","vpn","chacha","0")
ucic:set("openvpn","omr","cipher","AES-256-GCM")
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
ucic:set("openvpn",sectionname,"cipher","AES-256-GCM")
end
end)
--ucic:set("openvpn","omr","cipher","AES-256-GCM")
ucic:set("mlvpn","general","cleartext_data","0")
ucic:set("v2ray","omrout","s_vmess_user_security","aes-128-gcm")
ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm")
@ -977,7 +1003,13 @@ function wizard_add()
ucic:set("shadowsocks-libev","sss1","method","aes-256-cfb")
ucic:set("glorytun","vpn","chacha20","0")
ucic:set("glorytun-udp","vpn","chacha","0")
ucic:set("openvpn","omr","cipher","AES-256-CFB")
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
ucic:set("openvpn",sectionname,"cipher","AES-256-CFB")
end
end)
--ucic:set("openvpn","omr","cipher","AES-256-CFB")
ucic:set("mlvpn","general","cleartext_data","0")
ucic:set("v2ray","omrout","s_vmess_user_security","aes-128-gcm")
ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm")
@ -997,7 +1029,13 @@ function wizard_add()
ucic:set("shadowsocks-libev","sss1","method","chacha20-ietf-poly1305")
ucic:set("glorytun","vpn","chacha20","1")
ucic:set("glorytun-udp","vpn","chacha","1")
ucic:set("openvpn","omr","cipher","chacha20-poly1305")
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
ucic:set("openvpn",sectionname,"cipher","chacha20-poly1305")
end
end)
--ucic:set("openvpn","omr","cipher","chacha20-poly1305")
ucic:set("mlvpn","general","cleartext_data","0")
ucic:set("v2ray","omrout","s_vmess_user_security","chacha20-poly1305")
ucic:set("v2ray","omrout","s_vless_user_security","chacha20-poly1305")
@ -1224,10 +1262,34 @@ function wizard_add()
ucic:commit("ubond")
if default_vpn == "openvpn" and disablednb ~= serversnb then
ucic:set("openvpn","omr","enabled",1)
ucic:set("network","omrvpn","proto","none")
if ucic:get("openmptcprouter","settings","openvpn_lb") == "0" then
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
ucic:set("openvpn",sectionname,"enabled",0)
ucic:set("network",sectioname,"proto","none")
end
end)
ucic:set("openvpn","omr","enabled",1)
else
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
ucic:set("openvpn",sectionname,"enabled",1)
ucic:set("network",sectioname,"proto","none")
end
end)
--ucic:set("openvpn","omr","enabled",1)
end
--ucic:set("network","omrvpn","proto","none")
else
ucic:delete("openvpn","omr","enabled")
ucic:foreach("openvpn","openvpn", function(s)
local sectionname = s[".name"]
if sectionname:match("^omr.*") then
ucic:delete("openvpn",sectionname,"enabled")
end
end)
--ucic:delete("openvpn","omr","enabled")
end
ucic:save("openvpn")
ucic:commit("openvpn")
@ -1362,6 +1424,17 @@ function settings_add()
local externalcheck = luci.http.formvalue("externalcheck") or "1"
ucic:set("openmptcprouter","settings","external_check",externalcheck)
-- Enable/disable OpenVPN multiple clients
local openvpnlb = luci.http.formvalue("openvpnlb") or "1"
if ucic:get("openmptcprouter","settings","openvpn_lb") ~= openvpnlb then
ucic:set("openmptcprouter","settings","openvpn_lb",openvpnlb)
ucic:foreach("openmptcprouter", "server", function(s)
local sectionname = s[".name"]
ucic:set("openmptcprouter",sectionname,"get_config","1")
end)
end
-- Enable/disable restrict proxy to LAN
local restricttolan = luci.http.formvalue("restricttolan") or "0"
ucic:set("openmptcprouter","settings","restrict_to_lan",restricttolan)

View file

@ -364,6 +364,16 @@
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Disable OpenVPN multi clients%></label>
<div class="cbi-value-field">
<input type="checkbox" name="openvpnlb" class="cbi-input-checkbox" value="0" <% if luci.model.uci.cursor():get("openmptcprouter","settings","openvpn_lb") == "0" then %>checked<% end %>>
<br />
<div class="cbi-value-description">
<%:Disable OpenVPN multi clients to distribute connections and use more CPU cores%>
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Disable tracebox test%></label>
<div class="cbi-value-field">

View file

@ -712,3 +712,23 @@ dns_flush() {
unbound-control flush-negative >/dev/null 2>&1
unbound-control flush-bogus >/dev/null 2>&1
}
set_vpn_balancing_routes() {
vpngw="$1"
vpn_route() {
local vpnname
vpnname=$1
[ -z "$(echo $vpnname | grep omr)" ] && return
config_get enabled $vpnname enabled
[ "$enabled" != "1" ] && return
config_get dev $vpnname dev
[ -z "$dev" ] && return
allvpnroutes="$allvpnroutes nexthop via $vpngw dev $dev"
}
allvpnroutes=""
config_load openvpn
config_foreach vpn_route openvpn
_log "allvpnroutes: $allvpnroutes"
[ -n "$allvpnroutes" ] && ip route replace default scope global${allvpnroutes} >/dev/null 2>&1
}

View file

@ -61,13 +61,18 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
fi
fi
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 (was $default_gw)"
[ "$(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 $initcwrwnd >/dev/null 2>&1
if [ "$(uci -q get openvpn.omr2.enabled)" != "1" ]; then
_log "Tunnel up : Replace default route by $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE (was $default_gw)"
ip route replace default scope global via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE $initcwrwnd >/dev/null 2>&1
else
_log "Tunnel up : Replace default route by load balancing to $OMR_TRACKER_DEVICE_GATEWAY"
set_vpn_balancing_routes "$OMR_TRACKER_DEVICE_GATEWAY"
fi
if [ "$(pgrep -f openmptcprouter-vps)" = "" ]; then
/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 &
fi
[ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && conntrack -D -p udp >/dev/null 2>&1
[ -n "$(uci -q get shadowsocks-libev.sss0)" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && conntrack -D -p udp >/dev/null 2>&1
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "New route: $(ip r)"
fi
@ -388,5 +393,7 @@ if [ "$(sysctl -qen net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ] || [ "$(sysct
fi
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
#[ -n "$OMR_TRACKER_DEVICE" ] && OMR_TRACKER_PREV_DEVICE="$OMR_TRACKER_DEVICE"
#ubus call network reload
exit 0

View file

@ -1,35 +1,123 @@
#!/bin/sh
#
# Copyright (C) 2018-2024 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# This script check speed using Speedtest servers
INTERFACE="$1"
bypass_host_enable() {
INTERFACE=$1
HOST=$2
[ -n "$(tc qdisc show dev $INTERFACE | grep ingress)" ] && /etc/init.d/sqm stop $INTERFACE
domain=$(echo $HOST | awk -F/ '{print $3}')
if [ "$IPV6" = true ]; then
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
for ip in $hostip; do
ipset add ss_rules6_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_6 2>/dev/null)" ]; then
for ip in $hostip; do
nft add element inet fw4 omr_dst_bypass_all_6 { $ip } >/dev/null 2>&1
done
fi
else
hostip=$(dig +nocmd +noall +answer A $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ')
if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then
for ip in $hostip; do
ipset add ss_rules_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_4 2>/dev/null)" ]; then
for ip in $hostip; do
nft add element inet fw4 omr_dst_bypass_all_4 { $ip } >/dev/null 2>&1
done
fi
fi
}
bypass_host_disable() {
INTERFACE=$1
HOST=$2
domain=$(echo $HOST | awk -F/ '{print $3}')
if [ "$IPV6" = true ]; then
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
for ip in $hostip; do
ipset del ss_rules6_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_6 2>/dev/null)" ]; then
for ip in $hostip; do
nft delete element inet fw4 omr_dst_bypass_all_6 { $ip } >/dev/null 2>&1
done
fi
else
hostip=$(dig +nocmd +noall +answer A $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ')
if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then
for ip in $hostip; do
ipset del ss_rules_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_4 2>/dev/null)" ]; then
for ip in $hostip; do
nft delete element inet fw4 omr_dst_bypass_all_4 { $ip } >/dev/null 2>&1
done
fi
fi
/etc/init.d/sqm start $INTERFACE
}
if [ -f /usr/bin/v2ray ]; then
upload_file="/usr/bin/v2ray"
elif [ -f /usr/bin/xray ]; then
upload_file="/usr/bin/xray"
elif [ -f /boot/vmlinuz ]; then
upload_file="/boot/vmlinuz"
elif [ -f /bin/bash ]; then
upload_file="/bin/bash"
else
upload_file="/bin/busybox"
fi
echo "Download server list..."
wget -q -O /tmp/speedtest.lst http://c.speedtest.net/speedtest-servers-static.php
wget -q -O /tmp/speedtest.lst https://www.speedtest.net/api/js/servers
bestuploadurl=""
besthost=""
bestpinghost=""
sponsor=""
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
host=$(echo $line | jsonfilter -e '@.host')
pinghost=$(echo $host | awk -F: '{print $1}')
url=$(echo $line | jsonfilter -e '@.url')
ping=$(ping -c1 -w1 $pinghost | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
echo -n "."
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
bestping=$ping
besturl=$url
besthost=$host
bestpinghost=$pinghost
sponsor=$(echo $line | jsonfilter -q -e '@.sponsor')
fi
done < /tmp/speedtest.lst
done < <(cat /tmp/speedtest.lst | jsonfilter -e '@[*]')
echo
echo "Done: url: $bestuploadurl - host: $besthost - ping: $bestping"
echo "Done: url: $besturl - host: $besthost - ping: $bestping - sponsor: $sponsor"
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
bypass_host_enable $INTERFACE $bestpinghost
echo "Download:"
curl -4 --interface $INTERFACE $besthost/speedtest/random7000x7000.jpg >/dev/null || echo
ipset del ss_rules_dst_bypass_all $hostip
echo "Upload:"
curl -4 --interface $INTERFACE -F "file=@$upload_file" $besturl >/dev/null || echo
bypass_host_disable $INTERFACE $bestpinghost
fi

View file

@ -1,6 +1,11 @@
#!/bin/sh
# (c) Yannick Chabanois (ycarus@zugaina.org) for OpenMPTCProuter
#
# Copyright (C) 2018-2024 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# This script test global or interface speed
#
FORCEVPS=false
@ -15,26 +20,174 @@ for i in $@; do :; done
INTERFACE="$i"
[ "$INTERFACE" = "forcevps" ] || [ "$INTERFACE" = "fasttest" ] && INTERFACE=""
IPV6=false
if [ "$(basename $0)" = "omr-test-speedv6" ]; then
IPV6=true
fi
[ -n "$INTERFACE" ] && [ ! -d "/sys/class/net/$INTERFACE" ] && {
echo "You must use a real interface. You wan find them using 'ip a' for example (not $INTERFACE)"
exit 0
}
[ "$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 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 http://speedtest.milkywan.fr/files/10G.iso"
bestping="9999"
for pinghost in $HOSTLST; do
domain=$(echo $pinghost | awk -F/ '{print $3}')
if [ -z "$INTERFACE" ] || [ "$FORCEVPS" = true ]; then
ping=$(ping -4 -c1 -w2 $domain | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
HOSTLST6="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 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"
select_server() {
[ "$FASTTEST" = true ] || echo "Select best test server..."
bestping="9999"
if [ "$IPV6" = true ]; then
for pinghost in $HOSTLST6; do
domain=$(echo $pinghost | awk -F/ '{print $3}')
if [ -z "$INTERFACE" ] || [ "$FORCEVPS" = true ]; then
ping=$(ping -6 -c1 -w2 $domain | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
else
ping=$(ping -6 -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
fi
[ "$FASTTEST" = true ] || echo "host: $domain - ping: $ping"
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
bestping=$ping
HOST=$pinghost
fi
done
else
ping=$(ping -4 -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
for pinghost in $HOSTLST; do
domain=$(echo $pinghost | awk -F/ '{print $3}')
if [ -z "$INTERFACE" ] || [ "$FORCEVPS" = true ]; then
ping=$(ping -4 -c1 -w2 $domain | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
else
ping=$(ping -4 -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
fi
[ "$FASTTEST" = true ] || echo "host: $domain - ping: $ping"
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
bestping=$ping
HOST=$pinghost
fi
done
fi
[ "$FASTTEST" = true ] || echo "host: $domain - ping: $ping"
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
bestping=$ping
HOST=$pinghost
}
get_speed_global() {
HOST=$1
if [ "$IPV6" = true ]; then
curl -6 -o /dev/null $HOST || echo
else
curl -4 -o /dev/null $HOST || echo
fi
}
get_speed_global_fast() {
HOST=$1
if [ "$IPV6" = true ]; then
avg_speed=$(curl -6 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' $HOST 2>/dev/null)
else
avg_speed=$(curl -4 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' $HOST 2>/dev/null)
fi
echo "$avg_speed"
}
bypass_host_enable() {
INTERFACE=$1
HOST=$2
[ -n "$(tc qdisc show dev $INTERFACE | grep ingress)" ] && /etc/init.d/sqm stop $INTERFACE
domain=$(echo $HOST | awk -F/ '{print $3}')
if [ "$IPV6" = true ]; then
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
for ip in $hostip; do
ipset add ss_rules6_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_6 2>/dev/null)" ]; then
for ip in $hostip; do
nft add element inet fw4 omr_dst_bypass_all_6 { $ip } >/dev/null 2>&1
done
fi
else
hostip=$(dig +nocmd +noall +answer A $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ')
if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then
for ip in $hostip; do
ipset add ss_rules_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_4 2>/dev/null)" ]; then
for ip in $hostip; do
nft add element inet fw4 omr_dst_bypass_all_4 { $ip } >/dev/null 2>&1
done
fi
fi
}
bypass_host_disable() {
INTERFACE=$1
HOST=$2
domain=$(echo $HOST | awk -F/ '{print $3}')
if [ "$IPV6" = true ]; then
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
for ip in $hostip; do
ipset del ss_rules6_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_6 2>/dev/null)" ]; then
for ip in $hostip; do
nft delete element inet fw4 omr_dst_bypass_all_6 { $ip } >/dev/null 2>&1
done
fi
else
hostip=$(dig +nocmd +noall +answer A $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ')
if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then
for ip in $hostip; do
ipset del ss_rules_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_4 2>/dev/null)" ]; then
for ip in $hostip; do
nft delete element inet fw4 omr_dst_bypass_all_4 { $ip } >/dev/null 2>&1
done
fi
fi
/etc/init.d/sqm start $INTERFACE
}
get_speed_interface() {
INTERFACE=$1
HOST=$2
bypass_host_enable $INTERFACE $HOST
if [ "$IPV6" = true ]; then
curl -6 -o /dev/null --interface $INTERFACE $HOST || echo
else
curl -4 -o /dev/null --interface $INTERFACE $HOST || echo
fi
bypass_host_disable $INTERFACE $HOST
}
get_speed_interface_fast() {
INTERFACE=$1
HOST=$2
bypass_host_enable $INTERFACE $HOST
if [ "$IPV6" = true ]; then
avg_speed=$(curl -6 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE $HOST 2>/dev/null)
else
avg_speed=$(curl -4 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE $HOST 2>/dev/null)
fi
echo "$avg_speed"
bypass_host_disable $INTERFACE $HOST
}
response="000"
try=0
while [ "$response" = "000" ] && [ "$try" -le 3 ]; do
select_server
if [ "$IPV6" = true ]; then
response=$(curl -6 --write-out '%{http_code}' --silent --head --insecure -IL --connect-timeout 5 --output /dev/null $HOST)
HOSTLST6=$(echo $HOSTLST6 | tr ' ' '\n' | grep -v "$HOST" | xargs)
else
response=$(curl -4 --write-out '%{http_code}' --silent --head --insecure -IL --connect-timeout 5 --output /dev/null $HOST)
HOSTLST=$(echo $HOSTLST | tr ' ' '\n' | grep -v "$HOST" | xargs)
fi
try=$((try+1))
done
[ -z "$HOST" ] && HOST="http://speedtest.milkywan.fr/files/10G.iso"
@ -43,40 +196,14 @@ done
trap : HUP INT TERM
if [ -z "$INTERFACE" ]; then
if [ "$FASTTEST" = true ]; then
avg_speed=$(curl -4 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' $HOST 2>/dev/null)
echo "$avg_speed"
get_speed_global_fast $HOST
else
curl -4 -o /dev/null $HOST || echo
get_speed_global $HOST
fi
else
[ -n "$(tc qdisc show dev $INTERFACE | grep ingress)" ] && /etc/init.d/sqm stop $INTERFACE
domain=$(echo $HOST | awk -F/ '{print $3}')
hostip=$(dig +nocmd +noall +answer A $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ')
if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then
for ip in $hostip; do
ipset add ss_rules_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_4 2>/dev/null)" ]; then
for ip in $hostip; do
nft add element inet fw4 omr_dst_bypass_all_4 { $ip } >/dev/null 2>&1
done
fi
if [ "$FASTTEST" = true ]; then
avg_speed=$(curl -4 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE $HOST 2>/dev/null)
echo "$avg_speed"
get_speed_interface_fast $INTERFACE $HOST
else
curl -4 -o /dev/null --interface $INTERFACE $HOST || echo
get_speed_interface $INTERFACE $HOST
fi
if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then
for ip in $hostip; do
ipset del ss_rules_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_4 2>/dev/null)" ]; then
for ip in $hostip; do
nft delete element inet fw4 omr_dst_bypass_all_4 { $ip } >/dev/null 2>&1
done
fi
/etc/init.d/sqm start $INTERFACE
fi

View file

@ -1,79 +0,0 @@
#!/bin/sh
# (c) Yannick Chabanois (ycarus@zugaina.org) for OpenMPTCProuter
#
#
FORCEVPS=false
FASTTEST=false
if [ "$1" = "forcevps" ]; then
FORCEVPS=true
fi
if [ "$1" = "fasttest" ]; then
FASTTEST=true
fi
for i in $@; do :; done
INTERFACE="$i"
[ "$INTERFACE" = "forcevps" ] || [ "$INTERFACE" = "fasttest" ] && INTERFACE=""
[ -n "$INTERFACE" ] && [ ! -d "/sys/class/net/$INTERFACE" ] && {
echo "You must use a real interface. You wan find them using 'ip a' for example"
exit 0
}
[ "$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 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
domain=$(echo $pinghost | awk -F/ '{print $3}')
if [ -z "$INTERFACE" ] || [ "$FORCEVPS" = true ]; then
ping=$(ping -6 -c1 -w2 $domain | cut -d "/" -s -f5 | cut -d "." -f1)
else
ping=$(ping -6 -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1)
fi
[ "$FASTTEST" = true ] || echo "host: $domain - ping: $ping"
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
bestping=$ping
HOST=$pinghost
fi
done
[ -z "$HOST" ] && HOST="http://speedtest.milkywan.fr/files/10G.iso"
[ "$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
for ip in $hostip; do
ipset add ss_rules6_dst_bypass_all $ip
done
fi
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_6 2>/dev/null)" ]; then
for ip in $hostip; do
nft add element inet fw4 omr_dst_bypass_all_6 { $ip } >/dev/null 2>&1
done
fi
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
if [ -n "$(nft list set inet fw4 omr_dst_bypass_all_6 2>/dev/null)" ]; then
for ip in $hostip; do
nft delete element inet fw4 omr_dst_bypass_all_6 { $ip } >/dev/null 2>&1
done
fi
/etc/init.d/sqm start $INTERFACE
fi

View file

@ -0,0 +1 @@
omr-test-speed

View file

@ -1451,6 +1451,25 @@ _set_ssrust_server() {
fi
}
_set_openvpn_server() {
local option=$2
local value=$3
if [ "$value" = "true" ]; then
value=1
elif [ "$value" = "false" ]; then
value=0
fi
if [ "$(echo $1 | grep omr)" != "" ]; then
if [ "$option" = "remote" ]; then
uci -q delete openvpn.$1.$option
uci -q add_list openvpn.$1.$option=$value
else
uci -q set openvpn.$1.$option=$value
fi
fi
}
_set_config_from_vps() {
local shadowsocks_disabled vpn glorytun_state redirect shorewall_redirect mlvpn_key openvpn_key dsvpn_key
[ -z "$vps_config" ] && vps_config=$(_get_json "config")
@ -1625,10 +1644,12 @@ _set_config_from_vps() {
if [ "$(uci -q get shadowsocks-libev.sss0.server)" != "127.0.0.1" ]; then
config_foreach _set_ss_server server "server" $vpsip
fi
uci -q commit shadowsocks-libev
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ -n "$(uci -q changes shadowsocks-libev)" ]; then
logger -t "OMR-VPS" "Shadowsocks restart..."
/etc/init.d/shadowsocks-libev restart >/dev/null 2>&1
if [ -n "$(uci -q changes shadowsocks-libev)" ]; then
uci -q commit shadowsocks-libev
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ]; then
logger -t "OMR-VPS" "Shadowsocks restart..."
/etc/init.d/shadowsocks-libev restart >/dev/null 2>&1
fi
fi
fi
@ -1653,10 +1674,12 @@ _set_config_from_vps() {
if [ "$(uci -q get shadowsocks-rust.sss0.server)" != "127.0.0.1" ]; then
config_foreach _set_ssrust_server server "server" $vpsip
fi
uci -q commit shadowsocks-rust
if [ "$(uci -q get shadowsocks-rust.sss0.disabled)" != "1" ] && [ -n "$(uci -q changes shadowsocks-rust)" ]; then
logger -t "OMR-VPS" "Shadowsocks Rust restart..."
/etc/init.d/shadowsocks-rust restart >/dev/null 2>&1
if [ -n "$(uci -q changes shadowsocks-rust)" ]; then
uci -q commit shadowsocks-rust
if [ "$(uci -q get shadowsocks-rust.sss0.disabled)" != "1" ]; then
logger -t "OMR-VPS" "Shadowsocks Rust restart..."
/etc/init.d/shadowsocks-rust restart >/dev/null 2>&1
fi
fi
fi
@ -1681,10 +1704,12 @@ _set_config_from_vps() {
uci -q set v2ray.omrout.s_trojan_address="$vpsip"
uci -q set v2ray.omrout.s_socks_address="$vpsip"
fi
uci -q commit v2ray
if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -n "$(uci -q changes v2ray)" ]; then
logger -t "OMR-VPS" "V2ray restart..."
/etc/init.d/v2ray restart >/dev/null 2>&1
if [ -n "$(uci -q changes v2ray)" ]; then
uci -q commit v2ray
if [ "$(uci -q get v2ray.main.enabled)" = "1" ]; then
logger -t "OMR-VPS" "V2ray restart..."
/etc/init.d/v2ray restart >/dev/null 2>&1
fi
fi
fi
@ -1718,10 +1743,12 @@ _set_config_from_vps() {
uci -q set xray.omrout.s_socks_address="$vpsip"
uci -q set xray.omrout.s_shadowsocks_address="$vpsip"
fi
uci -q commit xray
if [ "$(uci -q get xray.main.enabled)" = "1" ] && [ -n "$(uci -q changes xray)" ]; then
logger -t "OMR-VPS" "Xray restart..."
/etc/init.d/xray restart >/dev/null 2>&1
if [ -n "$(uci -q changes xray)" ]; then
uci -q commit xray
if [ "$(uci -q get xray.main.enabled)" = "1" ]; then
logger -t "OMR-VPS" "Xray restart..."
/etc/init.d/xray restart >/dev/null 2>&1
fi
fi
fi
@ -1747,8 +1774,8 @@ _set_config_from_vps() {
if [ "$(uci -q get glorytun.vpn.host)" != "127.0.0.1" ]; then
uci -q set glorytun.vpn.host="$vpsip"
fi
uci -q commit glorytun
if [ -n "$(uci -q changes glorytun)" ]; then
uci -q commit glorytun
logger -t "OMR-VPS" "Glorytun restart..."
/etc/init.d/glorytun restart >/dev/null 2>&1
fi
@ -1772,8 +1799,8 @@ _set_config_from_vps() {
if [ "$(uci -q get glorytun-udp.vpn.host)" != "127.0.0.1" ]; then
uci -q set glorytun-udp.vpn.host="$vpsip"
fi
uci -q commit glorytun-udp
if [ -n "$(uci -q changes glorytun-udp)" ]; then
uci -q commit glorytun-udp
logger -t "OMR-VPS" "Glorytun UDP restart..."
/etc/init.d/glorytun-udp restart >/dev/null 2>&1
fi
@ -1790,20 +1817,31 @@ _set_config_from_vps() {
if [ "$vpn" = "openvpn" ]; then
openvpn_state=1
fi
uci -q batch <<-EOF >/dev/null
set openvpn.omr.port=$openvpn_port
set openvpn.omr.secret="/etc/luci-uploads/openvpn.key"
EOF
if [ "$openvpn_state" = "1" ]; then
config_load openvpn
config_foreach _set_openvpn_server openvpn "port" "$openvpn_port"
config_foreach _set_openvpn_server openvpn "secret" "/etc/luci-uploads/openvpn.key"
#uci -q batch <<-EOF >/dev/null
# set openvpn.omr.port=$openvpn_port
# set openvpn.omr.secret="/etc/luci-uploads/openvpn.key"
#EOF
if [ "$(uci -q get openmptcprouter.settings.openvpn_lb)" = "0" ]; then
config_foreach _set_openvpn_server openvpn "enabled" "0"
uci -q set openvpn.omr.enabled=$openvpn_state
else
uci -q del openvpn.omr.enabled
config_foreach _set_openvpn_server openvpn "enabled" "$openvpn_state"
fi
#if [ "$openvpn_state" = "1" ]; then
# uci -q set openvpn.omr.enabled=$openvpn_state
#else
# uci -q del openvpn.omr.enabled
#fi
if [ "$(uci -q get openvpn.omr.remote)" != "127.0.0.1" ]; then
uci -q set openvpn.omr.remote="$vpsip"
config_foreach _set_openvpn_server openvpn "remote" "$vpsip"
#uci -q set openvpn.omr.remote="$vpsip"
fi
uci -q commit openvpn
if [ -n "$(uci -q changes openvpn)" ]; then
uci -q commit openvpn
logger -t "OMR-VPS" "OpenVPN restart..."
/etc/init.d/openvpn restart
fi
@ -1828,21 +1866,43 @@ _set_config_from_vps() {
if [ "$vpn" = "openvpn" ]; then
openvpn_state=1
fi
uci -q batch <<-EOF >/dev/null
set openvpn.omr.port=$openvpn_port
set openvpn.omr.key="/etc/luci-uploads/client.key"
set openvpn.omr.cert="/etc/luci-uploads/client.crt"
set openvpn.omr.ca="/etc/luci-uploads/ca.crt"
set openvpn.omr.enabled=$openvpn_state
set openvpn.omr.tls_client=1
set openvpn.omr.client=1
set openvpn.omr.allow_recursive_routing=1
EOF
if [ -z "$(uci -q get openvpn.omr.remote | grep $vpsip)" ]; then
uci -q add_list openvpn.omr.remote="$vpsip"
NBCPU=$(grep -c '^processor' /proc/cpuinfo | tr -d "\n")
if [ "$NBCPU" -gt 1 ] && [ -z "$(uci -q get openvpn.omr2)" ]; then
[ -f /rom/etc/uci-defaults/2020-omr-vpn ] && ./rom/etc/uci-defaults/2020-omr-vpn
[ -f /usr/share/omr-update/2020-omr-vpn ] && ./usr/share/omr-update/2020-omr-vpn
fi
config_load openvpn
if [ "$(uci -q get openmptcprouter.settings.openvpn_lb)" = "0" ]; then
config_foreach _set_openvpn_server openvpn "enabled" "0"
uci -q set openvpn.omr.enabled=$openvpn_state
else
config_foreach _set_openvpn_server openvpn "enabled" "$openvpn_state"
fi
config_foreach _set_openvpn_server openvpn "key" "/etc/luci-uploads/client.key"
config_foreach _set_openvpn_server openvpn "cert" "/etc/luci-uploads/client.crt"
config_foreach _set_openvpn_server openvpn "ca" "/etc/luci-uploads/ca.crt"
config_foreach _set_openvpn_server openvpn "tls_client" "1"
config_foreach _set_openvpn_server openvpn "client" "1"
config_foreach _set_openvpn_server openvpn "allow_recursive_routing" "1"
#uci -q batch <<-EOF >/dev/null
# set openvpn.omr.port=$openvpn_port
# set openvpn.omr.key="/etc/luci-uploads/client.key"
# set openvpn.omr.cert="/etc/luci-uploads/client.crt"
# set openvpn.omr.ca="/etc/luci-uploads/ca.crt"
# set openvpn.omr.enabled=$openvpn_state
# set openvpn.omr.tls_client=1
# set openvpn.omr.client=1
# set openvpn.omr.allow_recursive_routing=1
#EOF
if [ "$(uci -q get openvpn.omr.remote)" != "127.0.0.1" ]; then
config_foreach _set_openvpn_server openvpn "remote" "$vpsip"
#uci -q set openvpn.omr.remote="$vpsip"
fi
uci -q commit openvpn
if [ -n "$(uci -q changes openvpn)" ]; then
uci -q commit openvpn
logger -t "OMR-VPS" "OpenVPN restart..."
/etc/init.d/openvpn restart
fi
@ -1864,8 +1924,8 @@ _set_config_from_vps() {
if [ "$(uci -q get mlvpn.general.host)" != "127.0.0.1" ]; then
uci -q set mlvpn.general.host="$vpsip"
fi
uci -q commit mlvpn
if [ -n "$(uci -q changes mlvpn)" ]; then
uci -q commit mlvpn
logger -t "OMR-VPS" "MLVPN restart..."
/etc/init.d/mlvpn restart
fi
@ -1888,8 +1948,8 @@ _set_config_from_vps() {
if [ "$(uci -q get dsvpn.vpn.host)" != "127.0.0.1" ]; then
uci -q set dsvpn.vpn.host="$vpsip"
fi
uci -q commit dsvpn
if [ -n "$(uci -q changes dsvpn)" ]; then
uci -q commit dsvpn
logger -t "OMR-VPS" "DSVPN restart..."
/etc/init.d/dsvpn restart
fi
@ -1959,9 +2019,9 @@ _set_config_from_vps() {
uci -q batch <<-EOF >/dev/null
set network.omr6in4.ip6addr="$omr6in4_vps_remoteip"
set network.omr6in4.gateway="$omr6in4_vps_localip"
commit network
EOF
if [ -n "$(uci -q changes network)" ]; then
uci -q commit network
/etc/init.d/network reload
sleep 6
fi

View file

@ -30,54 +30,6 @@ if [ "$(uci -q get network.omrvpn.txqueuelen)" = "1000" ]; then
EOF
fi
if [ "$(uci -q get openvpn.omr.proto)" != "tcp-client" ]; then
uci -q batch <<-EOF >/dev/null
set openvpn.omr=openvpn
set openvpn.omr.dev=tun0
set openvpn.omr.port=65301
set openvpn.omr.cipher=AES-256-GCM
set openvpn.omr.proto=tcp-client
set openvpn.omr.auth_nocache=1
set openvpn.omr.client=1
set openvpn.omr.tls_client=1
set openvpn.omr.reneg_sec=0
set openvpn.omr.allow_recursive_routing=1
set openvpn.omr.sndbuf=0
set openvpn.omr.rcvbuf=0
set openvpn.omr.route_delay=5
set openvpn.omr.disable_dco=1
set openvpn.omr.ping_restart=60
commit openvpn
EOF
fi
if [ -z "$(uci -q get openvpn.omr.disable_dco)" ]; then
uci -q batch <<-EOF >/dev/null
set openvpn.omr.disable_dco=1
commit openvpn
EOF
fi
if [ -z "$(uci -q get openvpn.omr.ping_restart)" ]; then
uci -q batch <<-EOF >/dev/null
set openvpn.omr.ping_restart=60
commit openvpn
EOF
fi
if [ -z "$(uci -q get openvpn.omr.tun_mtu)" ]; then
uci -q batch <<-EOF >/dev/null
set openvpn.omr.tun_mtu=1420
commit openvpn
EOF
fi
uci -q delete openvpn.omr.secret
uci -q delete openvpn.omr.ncp_disable=0
#if [ "$(uci -q get openvpn.omr.com_lzo)" = "" ]; then
# uci -q batch <<-EOF >/dev/null
# set openvpn.omr.comp_lzo=adaptive
# EOF
#fi
if [ "$(uci -q get ipsec.ipsec.password)" = "myvpn" ]; then
uci -q batch <<-EOF >/dev/null
set ipsec.ipsec.enabled='0'
@ -86,6 +38,7 @@ if [ "$(uci -q get ipsec.ipsec.password)" = "myvpn" ]; then
chmod u+x /etc/init.d/ipsec
fi
if [ "$(uci -q get dsvpn.vpn)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set dsvpn.vpn=dsvpn
@ -185,5 +138,70 @@ if [ "$(uci -q get openmptcprouter.settings.vpn)" = "" ]; then
EOF
fi
if [ "$(uci -q get openvpn.omr.proto)" != "tcp-client" ] || [ -z "$(uci -q get openvpn.omr.disable_dco)" ] || [ -z "$(uci -q get openvpn.omr.ping_restart)" ] || [ -z "$(uci -q get openvpn.omr.tun_mtu)" ]; then
uci -q batch <<-EOF >/dev/null
set openvpn.omr=openvpn
set openvpn.omr.dev=tun0
set openvpn.omr.port=65301
set openvpn.omr.cipher=AES-256-GCM
set openvpn.omr.proto=tcp-client
set openvpn.omr.auth_nocache=1
set openvpn.omr.client=1
set openvpn.omr.tls_client=1
set openvpn.omr.reneg_sec=0
set openvpn.omr.allow_recursive_routing=1
set openvpn.omr.sndbuf=0
set openvpn.omr.rcvbuf=0
set openvpn.omr.route_delay=5
set openvpn.omr.disable_dco=1
set openvpn.omr.ping_restart=60
set openvpn.omr.tun_mtu=1420
delete openvpn.omr.secret
delete openvpn.omr.ncp_disable=0
commit openvpn
EOF
fi
NBCPU=$(grep -c '^processor' /proc/cpuinfo | tr -d "\n")
if [ "$NBCPU" -gt 1 ] && [ -z "$(uci -q get openvpn.omr2)" ]; then
[ "$NBCPU" -gt 4 ] && NBCPU=4
for c in $(seq 2 $NBCPU); do
uci -q batch <<-EOF >/dev/null
set openvpn.omr$c=openvpn
set openvpn.omr$c.dev=tun$((c-1))
set openvpn.omr$c.port=65301
set openvpn.omr$c.cipher=AES-256-GCM
set openvpn.omr$c.proto=tcp-client
set openvpn.omr$c.auth_nocache=1
set openvpn.omr$c.client=1
set openvpn.omr$c.tls_client=1
set openvpn.omr$c.reneg_sec=0
set openvpn.omr$c.allow_recursive_routing=1
set openvpn.omr$c.sndbuf=0
set openvpn.omr$c.rcvbuf=0
set openvpn.omr$c.route_delay=5
set openvpn.omr$c.disable_dco=1
set openvpn.omr$c.ping_restart=60
set openvpn.omr$c.tun_mtu=1420
del_list firewall.zone_vpn.device=tun$((c-1))
add_list firewall.zone_vpn.device=tun$((c-1))
EOF
done
uci -q commit openvpn
uci -q commit firewall
uci set -q openmptcprouter.vps.get_config="1"
uci -q set openmptcprouter.settings.openvpn_lb="0"
uci -q commit openmptcprouter
fi
# This must not be enabled, this break everything
#if [ "$(uci -q get openvpn.omr.com_lzo)" = "" ]; then
# uci -q batch <<-EOF >/dev/null
# set openvpn.omr.comp_lzo=adaptive
# EOF
#fi
rm -f /tmp/luci-indexcache
exit 0

View file

@ -1,19 +1,37 @@
#!/bin/sh
source /etc/os-release
if [ "$ID" = "openmptcprouter" ]; then
cat > "/etc/opkg/customfeeds.conf" <<-EOF
src/gz openwrt_luci https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/luci
src/gz openwrt_packages https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/packages
src/gz openwrt_base https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/base
src/gz openwrt_routing https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/routing
src/gz openwrt_telephony https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/telephony
EOF
TARGET="$(cat /etc/banner | awk '/TARGET/ {print $2}')"
cat > "/etc/opkg/distfeeds.conf" <<-EOF
src/gz openmptcprouter_core https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/targets/${OPENWRT_BOARD}/packages
src/gz openmptcprouter_base https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/base
src/gz openmptcprouter_luci https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/luci
src/gz openmptcprouter_openmptcprouter https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/openmptcprouter
src/gz openmptcprouter_packages https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/packages
EOF
if [ -f /etc/opkg/customfeeds.conf ]; then
cat > "/etc/opkg/customfeeds.conf" <<-EOF
src/gz openwrt_luci https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/luci
src/gz openwrt_packages https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/packages
src/gz openwrt_base https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/base
src/gz openwrt_routing https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/routing
src/gz openwrt_telephony https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/telephony
EOF
TARGET="$(cat /etc/banner | awk '/TARGET/ {print $2}')"
cat > "/etc/opkg/distfeeds.conf" <<-EOF
src/gz openmptcprouter_core https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/targets/${OPENWRT_BOARD}/packages
src/gz openmptcprouter_base https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/base
src/gz openmptcprouter_luci https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/luci
src/gz openmptcprouter_openmptcprouter https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/openmptcprouter
src/gz openmptcprouter_packages https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/packages
EOF
elif [ -f /etc/apk/repositories.d/distfeeds.list ]; then
cat > "/etc/apk/repositories.d/customfeeds.list" <<-EOF
https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/luci/packages.adb
https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/packages/packages.adb
https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/base/packages.adb
https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/routing/packages.adb
https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/telephony/packages.adb
EOF
TARGET="$(cat /etc/banner | awk '/TARGET/ {print $2}')"
cat > "/etc/apk/repositories.d/distfeeds.list" <<-EOF
https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/targets/${OPENWRT_BOARD}/packages/packages.adb
https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/base/packages.adb
https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/luci/packages.adb
https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/openmptcprouter/packages.adb
https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/packages/packages.adb
EOF
fi
fi