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 ipq60xx

This commit is contained in:
suyuan 2023-09-16 14:34:32 +08:00
commit 842ca9e505
46 changed files with 1926 additions and 1614 deletions

View file

@ -60,7 +60,11 @@ end
o = s:option(ListValue, "congestion", translate("Congestion Control"),translate("Default is cubic"))
local availablecong = sys.exec("sysctl -n net.ipv4.tcp_available_congestion_control | xargs -n1 | sort | xargs")
for cong in string.gmatch(availablecong, "[^%s]+") do
o:value(cong, translate(cong))
if cong == "bbr" and string.match(availablecong, "bbr1") then
o:value(cong, "bbr3")
else
o:value(cong, cong)
end
end
-- if tonumber(uname.release:sub(1,4)) >= 5.15 then

View file

@ -1321,7 +1321,18 @@ end
function backupgr()
local get_backup = luci.http.formvalue("restore") or ""
if get_backup ~= "" then
luci.sys.call("/etc/init.d/openmptcprouter-vps backup_get >/dev/null 2>/dev/null")
local dobackup = 0
ucic:foreach("openmptcprouter","server", function(s)
servername = s[".name"]
local get_selected_backup = luci.http.formvalue(servername .. "") or ""
if get_selected_backup ~= "" then
dobackup = 1
luci.sys.call("/etc/init.d/openmptcprouter-vps backup_get " .. servername .. " " .. get_selected_backup .. ">/dev/null 2>/dev/null")
end
end)
if dobackup == 0 then
luci.sys.call("/etc/init.d/openmptcprouter-vps backup_get >/dev/null 2>/dev/null")
end
end
local send_backup = luci.http.formvalue("save") or ""
if send_backup ~= "" then

View file

@ -16,10 +16,36 @@ menuentry = ucic:get("openmptcprouter","settings","menu") or "openmptcprouter"
%>
<h3><%=servername%></h3>
<%
if luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup") ~= nil then
if luci.model.uci.cursor():get("openmptcprouter",servername,"allbackup") ~= nil then
%>
<div class="cbi-section-node">
<%:Last available backup on server:%> <%=os.date('%d-%b-%Y', luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup"))%>
<div class="cbi-value">
<label class="cbi-value-title"><%:Backup availables on server%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="<%=servername%>-backup" size="1">
<option value=""></option>
<%
lastmodif=""
allbackup=luci.model.uci.cursor():get("openmptcprouter",servername,"allbackup")
for _, backup in pairs(allbackup) do
filemodif=split(backup, '|')
if filemodif[2] ~= lastmodif then
lastmodif=filemodif[2]
%>
<option value="<%=filemodif[1]%>"><%=os.date('%c',filemodif[2])%></option>
<%
end
end
%>
</select>
</div>
</div>
</div>
<%
elseif luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup") ~= nil then
%>
<div class="cbi-section-node">
<%:Last available backup on server:%> <%=os.date('%c', luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup"))%>
</div>
<% else %>
<div class="cbi-section-node">
@ -29,6 +55,7 @@ menuentry = ucic:get("openmptcprouter","settings","menu") or "openmptcprouter"
<%
end)
%>
<br/>
<input type="submit" class="cbi-button cbi-button-action important" name="restore" value="<%:Restore backup%>"/>
<input type="submit" class="cbi-button cbi-button-action important" name="save" value="<%:Send backup%>"/>

View file

@ -241,7 +241,7 @@
</select>
<br />
<div class="cbi-value-description">
<%:Set the default Proxy used for TCP when ShadowSocks is enabled, for TCP and UDP when V2Ray VLESS or VMESS is enabled.%>
<%:Set the default Proxy used for TCP when ShadowSocks is enabled, for TCP and UDP when V2Ray VLESS, VMESS or Trojan is enabled.%>
<%:Only ShadowSocks is supported with server multiple IPs for now.%>
</div>
</div>

View file

@ -332,6 +332,8 @@ function server_settings(server,server_ip,openmptcprouter_vps_key)
ucic:set("qos","serverout","dsthost",server_ip)
ucic:set("v2ray","omrout","s_vmess_address",server_ip)
ucic:set("v2ray","omrout","s_vless_address",server_ip)
ucic:set("v2ray","omrout","s_socks_address",server_ip)
ucic:set("v2ray","omrout","s_trojan_address",server_ip)
ucic:save("qos")
ucic:commit("qos")
ucic:save("mlvpn")
@ -962,6 +964,9 @@ function interfaces_status()
if mArray.openmptcprouter["kernel"]:sub(1,3) == "5.4" and mArray.openmptcprouter["vps_kernel"]:sub(1,3) ~= "5.4" then
mArray.openmptcprouter["kernel_match"] = false
end
if mArray.openmptcprouter["kernel"]:sub(1,1) == "6" and mArray.openmptcprouter["vps_kernel"]:sub(1,1) ~= "6" then
mArray.openmptcprouter["kernel_match"] = false
end
end
if mArray.openmptcprouter["vps_hostname"] == "" then
@ -1307,6 +1312,8 @@ function interfaces_status()
if connectivity == "OK" then
connectivity = "WARNING"
end
else
gw_ping = "UP"
end
else
gw_ping = "DOWN"
@ -1323,6 +1330,8 @@ function interfaces_status()
if connectivity == "OK" then
connectivity = "WARNING"
end
else
gw_ping6="UP"
end
else
gw_ping6 = "DOWN"
@ -1340,6 +1349,7 @@ function interfaces_status()
end
elseif gateway == "" and gateway6 == "" then
gw_ping = "DOWN"
gw_ping6 = "DOWN"
connectivity = "ERROR"
end
@ -1661,6 +1671,398 @@ function _ipv6_discover(interface)
return ra6_result
end
function interfaces_only_status()
local ut = require "luci.util"
local ntm = require "luci.model.network".init()
local uci = require "luci.model.uci".cursor()
local mArray = {}
-- OpenMPTCProuter info
mArray.openmptcprouter = {}
mArray.openmptcprouter["service_addr"] = uci:get("shadowsocks-libev", "sss0", "server") or ""
if mArray.openmptcprouter["service_addr"] == "" or mArray.openmptcprouter["service_addr"] == "192.168.1.3" then
mArray.openmptcprouter["service_addr"] = ""
ucic:foreach("openmptcprouter", "server", function(s)
local serverip = uci:get("openmptcprouter",s[".name"],"ip") or ""
local disabled = uci:get("openmptcprouter",s[".name"],"disabled") or "0"
if serverip ~= "" and disabled ~= "1" then
mArray.openmptcprouter["service_addr"] = serverip
end
end)
end
if mArray.openmptcprouter["service_addr"] ~= "" then
mArray.openmptcprouter["service_addr_ip"] = ut.trim(sys.exec("resolveip -4 -t 1 " .. mArray.openmptcprouter["service_addr"] .. " | head -n 1"))
mArray.openmptcprouter["service_addr_ip6"] = ut.trim(sys.exec("resolveip -6 -t 1 " .. mArray.openmptcprouter["service_addr"] .. " | head -n 1"))
end
-- overview status
mArray.wans = {}
allintf = {}
allmac = {}
uci:foreach("network", "interface", function (section)
local interface = section[".name"]
local net = ntm:get_network(interface)
local ipaddr = net:ipaddr() or ""
local ip6addr = net:ip6addr() or ""
local gateway = section["gateway"] or ""
local gateway6 = section["ip6gw"] or ""
local multipath = section["multipath"]
local enabled = section["auto"]
local proto = section["proto"] or ""
local ipv6 = section["ipv6"] or "0"
local mac = section ["macaddr"] or ""
local itype = section ["type"] or ""
local state = uci:get("openmptcprouter", interface, "state") or ""
local ifname = get_device(interface)
if ifname == "" or ifname == nil then
ifname = section["device"] or ""
end
--if multipath == "off" and not ifname:match("^tun.*") then return end
if multipath == "off" then return end
if enabled == "0" then return end
local connectivity = "OK"
if ipaddr == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then
ipaddr = ut.trim(sys.exec("ip -4 -br addr ls dev " .. ifname .. " | awk -F'[ /]+' '{print $3}' | tr -d '\n'"))
end
if ipaddr == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then
ipaddr = ut.trim(sys.exec("ip -4 addr show dev " .. ifname .. " | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1 | tr -d '\n'"))
end
if ip6addr == "" and ifname ~= nil and ifname ~= "" and (ipv6 == "1" or ipv6 == "auto") then
ip6addr = ut.trim(sys.exec("ip -6 -br addr ls dev " .. ifname .. " | awk -F'[ /]+' '{print $3}' | tr -d '\n'"))
end
if ip6addr == "" and ifname ~= nil and ifname ~= "" and (ipv6 == "1" or ipv6 == "auto") then
ip6addr = ut.trim(sys.exec("ip -6 addr show dev " .. ifname .. " | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1 | tr -d '\n'"))
end
if ipaddr == "" and ip6addr == "" then
connectivity = "ERROR"
end
local multipath_state = ""
local current_multipath_state = ""
if ifname ~= "" and ifname ~= nil and connectivity ~= "ERROR" then
if fs.access("/sys/class/net/" .. ifname) then
multipath_state = ut.trim(sys.exec("multipath " .. ifname .. " | grep deactivated"))
if multipath_state == "" then
connectivity = "OK"
else
connectivity = "ERROR"
end
else
connectivity = "ERROR"
end
else
connectivity = "ERROR"
end
if ifname ~= "" and ifname ~= nil and connectivity ~= "ERROR" then
local test_current_multipath_state = ut.trim(sys.exec("multipath " .. ifname))
if string.find(test_current_multipath_state,"deactivated") then
current_multipath_state = "off"
elseif string.find(test_current_multipath_state,"default") then
current_multipath_state = "on"
elseif string.find(test_current_multipath_state,"backup") then
current_multipath_state = "backup"
elseif string.find(test_current_multipath_state,"handover") then
current_multipath_state = "handover"
else
current_multipath_state = ""
end
end
local signal = ""
local operator = ""
local phonenumber = ""
local donglestate = ""
local networktype = ""
if gateway ~= "" or gateway6 ~= "" then
if uci:get("openmptcprouter", "settings", "disablegwping") ~= "1" and connectivity ~= "ERROR" then
if gateway ~= "" then
local gw_ping_test = ""
if ifname ~= "" and ifname ~= nil then
gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 -B -I " .. ifname .. " " .. gateway .. " | grep '100% packet loss'"))
else
gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway .. " | grep '100% packet loss'"))
end
if gw_ping_test ~= "" then
gw_ping = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
end
else
gw_ping = "UP"
end
else
gw_ping = "DOWN"
end
if gateway6 ~= "" then
local gw_ping6_test = ""
if ifname ~= "" and ifname ~= nil then
gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 -B -I " .. ifname .. " " .. gateway6 .. " | grep '100% packet loss'"))
else
gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway6 .. " | grep '100% packet loss'"))
end
if gw_ping6_test ~= "" then
gw_ping6 = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
else
gw_ping6 = "UP"
end
end
else
gw_ping6 = "DOWN"
end
end
if uci:get("openmptcprouter", interface, "manufacturer") == "huawei" and ipaddr ~= "" then
intfdata = ut.trim(sys.exec("omr-huawei " .. ipaddr .. " " .. gateway .. " all"))
if intfdata ~= "" then
signal = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $1}'"))
operator = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $2}'"))
phonenumber = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $3}'"))
donglestate = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $4}'"))
networktype = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $5}'"))
end
end
elseif gateway == "" and gateway6 == "" then
gw_ping = "DOWN"
gw_ping6 = "DOWN"
connectivity = "ERROR"
end
if ifname ~= "" and ifname ~= nil then
--local proto = section['proto']
if proto == "qmi" then
local device = section['device']
intfdata = ut.trim(sys.exec("omr-qmi " .. device .. " all"))
if intfdata ~= "" then
signal = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $1}'"))
operator = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $2}'"))
phonenumber = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $3}'"))
donglestate = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $4}'"))
networktype = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $5}'"))
end
elseif proto == "3g" then
local device = section['device']
signal = sys.exec("omr-3g " .. device .. " | tr -d '\n'")
elseif proto == "modemmanager" then
local device = section['device']
intfdata = ut.trim(sys.exec("omr-modemmanager " .. device .. " all"))
if intfdata ~= "" then
signal = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $1}'"))
operator = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $2}'"))
phonenumber = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $3}'"))
donglestate = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $4}'"))
networktype = ut.trim(sys.exec("echo '".. intfdata .. "' | awk -F';' '{print $5}'"))
end
end
end
local latency = ""
local server_ping = ""
local server_http = ""
--if connectivity ~= "ERROR" and ifname ~= "" and gateway ~= "" and gw_ping ~= "DOWN" and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" and ipaddr ~= "" then
if ifname ~= "" and (gateway ~= "" or gateway6 ~= "") and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" and (ipaddr ~= "" or ip6addr ~= "") and connectivity ~= "ERROR" then
local serverip = mArray.openmptcprouter["service_addr"]
if serverip == "127.0.0.1" then
serverip = mArray.openmptcprouter["wan_addr"]
end
if serverip ~= "" and uci:get("openmptcprouter", "settings", "disableserverping") ~= "1" then
local server_ping_test = sys.exec("ping -B -w 1 -c 1 -I " .. ifname .. " " .. serverip)
local server_ping_result = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | grep '100% packet loss'"))
if server_ping_result ~= "" then
server_ping = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
end
else
server_ping = "UP"
latency = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | cut -d '/' -s -f5 | cut -d '.' -f1"))
end
end
if adminport == "" then
adminport = "65500"
end
-- httping disable for now, with -l (ssl) timeout is ignored
if false and server_ping == "UP" and uci:get("openmptcprouter", "settings", "disableserverhttptest") ~= "1" and ipaddr ~= "" and adminport ~= "" then
local server_http_result = ""
local server_http_test = ""
if mArray.openmptcprouter["service_addr_ip"] ~= "" then
server_http_test = sys.exec("httping -l " .. mArray.openmptcprouter["service_addr_ip"] .. ":" .. adminport .. " -y " .. ipaddr .. " -t 1 -c 1")
server_http_result = ut.trim(sys.exec("echo '" .. server_http_test .. "' | grep '100.00% failed'"))
elseif mArray.openmptcprouter["service_addr_ip6"] ~= "" then
server_http_test = sys.exec("httping -l [" .. mArray.openmptcprouter["service_addr_ip6"] .. "]:" .. adminport .. " -y " .. ipaddr .. " -t 1 -c 1")
server_http_result = ut.trim(sys.exec("echo '" .. server_http_test .. "' | grep '100.00% failed'"))
end
if server_http_result ~= "" then
server_http = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
end
else
server_http = "UP"
end
end
end
local multipath_available = ""
local multipath_available_state = ""
if connectivity ~= "ERROR" and ifname ~= nil and ifname ~= "" and (gateway ~= "" or gateway6 ~= "") and (gw_ping == "UP" or gw_ping6 == "UP") then
-- Test if multipath can work on the connection
local multipath_available_state = uci:get("openmptcprouter",interface,"mptcp_status") or ""
if multipath_available_state == "" then
multipath_available = "NO CHECK"
elseif multipath_available_state == "MPTCP enabled" then
multipath_available = "OK"
else
multipath_available = "ERROR"
end
else
multipath_available = "NO CHECK"
end
local zonewan = "NO"
if ut.trim(sys.exec("uci -q get firewall.zone_wan.network | grep '" .. interface .. "'")) ~= "" or interface:match("^wg.*") or interface:match("^ovpn.*") then
zonewan = "OK"
end
-- Detect if WAN get an IPv6
local ipv6_discover = "NONE"
local mtu = ""
local whois = ""
local whois6 = ""
local publicIP = ""
local publicIP6 = ""
if connectivity ~= "ERROR" then
if ifname ~= nil and (ifname:match("^tun.*") and interface:match("^ovpn.*")) then
publicIP = uci:get("openmptcprouter",interface:sub(5),"publicip") or ""
if ifname ~= nil and ipaddr ~= "" and publicIP == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
publicIP = ut.trim(sys.exec("omr-ip-intf " .. get_device(interface:sub(5))))
end
publicIP6 = uci:get("openmptcprouter",interface:sub(5),"publicip6") or ""
if ifname ~= nil and ip6addr ~= "" and publicIP6 == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
publicIP6 = ut.trim(sys.exec("omr-ip6-intf " .. get_device(interface:sub(5))))
end
elseif ifname ~= nil and interface:match("^wg.*") then
publicIP = uci:get("openmptcprouter",interface:sub(3),"publicip") or ""
if ifname ~= nil and ipaddr ~= "" and publicIP == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
publicIP = ut.trim(sys.exec("omr-ip-intf " .. get_device(interface:sub(3))))
end
publicIP6 = uci:get("openmptcprouter",interface:sub(3),"publicip6") or ""
if ifname ~= nil and ip6addr ~= "" and publicIP6 == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
publicIP6 = ut.trim(sys.exec("omr-ip6-intf " .. get_device(interface:sub(3))))
end
else
publicIP = uci:get("openmptcprouter",interface,"publicip") or ""
if ifname ~= nil and ipaddr ~= "" and publicIP == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
publicIP = ut.trim(sys.exec("omr-ip-intf " .. ifname))
end
publicIP6 = uci:get("openmptcprouter",interface,"publicip6") or ""
if ifname ~= nil and ip6addr ~= "" and publicIP6 == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
publicIP6 = ut.trim(sys.exec("omr-ip6-intf " .. ifname))
end
end
if publicIP ~= "" then
whois = uci:get("openmptcprouter",interface,"asn") or ""
if whois == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
whois = ut.trim(sys.exec("whois " .. publicIP .. " | grep -i 'netname' | awk '{print $2}'"))
--whois = ut.trim(sys.exec("wget -4 -qO- -T 1 'http://api.iptoasn.com/v1/as/ip/" .. publicIP .. "' | jsonfilter -q -e '@.as_description'"))
end
if publicIP == mArray.openmptcprouter["wan_addr"] then
mArray.openmptcprouter["direct_output"] = true
end
end
if publicIP6 ~= "" then
whois6 = uci:get("openmptcprouter",interface,"asn") or ""
if whois6 == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
whois6 = ut.trim(sys.exec("whois " .. publicIP6 .. " | grep -i 'netname' | awk '{print $2}'"))
--whois6 = ut.trim(sys.exec("wget -6 -qO- -T 1 'http://api.iptoasn.com/v1/as/ip/" .. publicIP6 .. "' | jsonfilter -q -e '@.as_description'"))
end
if publicIP6 == mArray.openmptcprouter["wan_addr6"] then
mArray.openmptcprouter["direct_output"] = true
end
end
if ifname ~= "" and ifname ~= nil then
if fs.access("/sys/class/net/" .. ifname) then
mtu = ut.trim(sys.exec("cat /sys/class/net/" .. ifname .. "/mtu | tr -d '\n'"))
if mtu == "" and interface ~= nil then
mtu = uci:get("openmptcprouter",interface,"mtu") or ""
end
end
end
loop = false
if uci:get("openmptcprouter", interface, "loop") == "1" then
loop = true
end
end
local rx = ""
local tx = ""
if ifname ~= "" and ifname ~= nil then
rx = ut.trim(sys.exec("devstatus " .. ifname .. " | jsonfilter -e '@.statistics.rx_bytes'"))
tx = ut.trim(sys.exec("devstatus " .. ifname .. " | jsonfilter -e '@.statistics.tx_bytes'"))
end
if state == "down" then
connectivity = "ERROR"
end
local data = {
label = section["label"] or interface,
name = interface,
--link = net:adminlink() or "",
ifname = ifname,
ipaddr = ipaddr,
ip6addr = ip6addr,
gateway = gateway,
gateway6 = gateway6,
multipath = section["multipath"],
status = connectivity,
wanip = publicIP,
wanip6 = publicIP6,
latency = latency,
mtu = mtu,
whois = whois or "unknown",
whois6 = whois6 or "unknown",
qos = section["trafficcontrol"],
download = section["download"],
upload = section["upload"],
gw_ping = gw_ping,
gw_ping6 = gw_ping6,
server_ping = server_ping,
server_http = server_http,
ipv6_discover = ipv6_discover,
multipath_available = multipath_available,
multipath_state = current_multipath_state,
signal = signal,
operator = operator,
phonenumber = phonenumber,
donglestate = donglestate,
networktype = networktype,
proto = proto,
rx = rx,
tx = tx,
zonewan = zonewan,
iftype = itype,
state = state,
loop = loop,
}
table.insert(mArray.wans, data);
end)
if next(mArray.wans) == nil then
mArray.openmptcprouter["direct_output"] = true
end
return mArray
end
local methods = {
getrootfs = {
call = function()
@ -1677,6 +2079,11 @@ local methods = {
return interfaces_status()
end
},
statusinterfaces = {
call = function()
return interfaces_only_status()
end
},
setIPv6 = {
args = { disable = 0 },
call = function(args)

View file

@ -170,7 +170,8 @@ alpha_delta_ewma=0.095
# shaper rate is adjusted by a maximum of shaper_rate_max_adjust_down_bufferbloat on detection of bufferbloat
# and this is scaled by the average delta owd / average owd delta threshold
# otherwise shaper rate is adjusted up on load high, and down on load idle or low
shaper_rate_max_adjust_down_bufferbloat=0.75 # how rapidly to reduce shaper rate upon detection of bufferbloat
shaper_rate_min_adjust_down_bufferbloat=0.99 # how rapidly to reduce shaper rate upon detection of bufferbloat (min reduction)
shaper_rate_max_adjust_down_bufferbloat=0.75 # how rapidly to reduce shaper rate upon detection of bufferbloat (max reduction)
shaper_rate_adjust_up_load_high=1.01 # how rapidly to increase shaper rate upon high load detected
shaper_rate_adjust_down_load_low=0.99 # how rapidly to return down to base shaper rate upon idle or low load detected
shaper_rate_adjust_up_load_low=1.01 # how rapidly to return up to base shaper rate upon idle or low load detected

View file

@ -91,9 +91,9 @@ interface_max_metric() {
fi
elif [ "$1" = "omrvpn" ]; then
uci -q batch <<-EOF >/dev/null
set network.${config}.metric=9000
set network.${config}.metric=1500
commit network
set openmptcprouter.${config}.metric=9000
set openmptcprouter.${config}.metric=1500
commit openmptcprouter
EOF
elif [ "$1" = "omr6in4" ]; then
@ -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

View file

@ -4,11 +4,11 @@ if [ "$(uci -q get network.globals.mptcp_path_manager)" = "" ]; then
set network.globals.multipath='enable'
set network.globals.mptcp_path_manager='fullmesh'
set network.globals.mptcp_scheduler='blest'
set network.globals.congestion='cubic'
set network.globals.congestion='bbr'
set network.globals.mptcp_checksum=0
set network.globals.mptcp_debug=0
set network.globals.mptcp_syn_retries=4
set network.globals.mptcp_subflows=3
set network.globals.mptcp_subflows=8
set network.globals.mptcp_add_addr_accepted=1
set network.globals.mptcp_add_addr_timeout=120
set network.globals.mptcp_pm_type=0
@ -18,12 +18,13 @@ if [ "$(uci -q get network.globals.mptcp_path_manager)" = "" ]; then
commit network
EOF
fi
#if [ "$(uci -q get network.globals.congestion)" != "bbr" ]; then
# uci -q batch <<-EOF >/dev/null
# set network.globals.congestion=bbr
# commit network
# EOF
#fi
# BBRv2 is replaced by BBRv3
if [ "$(uci -q get network.globals.congestion)" = "bbr2" ]; then
uci -q batch <<-EOF >/dev/null
set network.globals.congestion='bbr'
commit network
EOF
fi
if [ "$(uci -q get network.globals.mptcp_syn_retries)" = "1" ]; then
uci -q batch <<-EOF >/dev/null
set network.globals.mptcp_syn_retries=4
@ -62,7 +63,7 @@ if [ "$(uci -q show network.globals | grep mptcp_fullmesh)" = "" ]; then
fi
if [ "$(uci -q get network.globals.mptcp_subflows)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set network.globals.mptcp_subflows=3
set network.globals.mptcp_subflows=8
set network.globals.mptcp_add_addr_accepted=1
set network.globals.mptcp_add_addr_timeout=120
commit network

View file

@ -131,6 +131,14 @@ if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then
printf "0x%02x" $(($(($IFF^$(($IFF&$IFF_MASK))))|$FLAG)) > $FLAG_PATH
else
# Remove not needed if* interfaces in MPTCP
oldintfs=$(ip mptcp endpoint show | grep "dev if" | awk '{ print $3 }')
[ -n "$oldintfs" ] && {
for oldintf in $oldintfs; do
ip mptcp endpoint delete id $oldintf 2>&1 >/dev/null
done
}
ID=$(ip mptcp endpoint show | grep -m 1 "dev $DEVICE" | awk '{print $3}')
IFF=$(ip mptcp endpoint show | grep -m 1 "dev $DEVICE" | awk '{print $4}')
IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')

View file

@ -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
@ -357,10 +357,18 @@ set_route_balancing() {
fi
if [ "$multipath_config_route" = "backup" ]; then
nbintfb=$((nbintfb+1))
routesbalancingbackup="$routesbalancingbackup nexthop via $interface_gw dev $interface_if weight $weight"
if [ -z "$routesbalancingbackup" ]; then
routesbalancingbackup="nexthop via $interface_gw dev $interface_if weight $weight"
else
routesbalancingbackup="$routesbalancingbackup nexthop via $interface_gw dev $interface_if weight $weight"
fi
else
nbintf=$((nbintf+1))
routesbalancing="$routesbalancing nexthop via $interface_gw dev $interface_if weight $weight"
if [ -z "$routesbalancing" ]; then
routesbalancing="nexthop via $interface_gw dev $interface_if weight $weight"
else
routesbalancing="$routesbalancing nexthop via $interface_gw dev $interface_if weight $weight"
fi
fi
fi
fi
@ -424,10 +432,18 @@ set_route_balancing6() {
fi
if [ "$multipath_config_route" = "backup" ]; then
nbintfb6=$((nbintfb6+1))
routesbalancingbackup6="$routesbalancingbackup6 nexthop via $interface_gw dev $interface_if weight $weight"
if [ -z "$routesbalancingbackup6" ]; then
routesbalancingbackup6="nexthop via $interface_gw dev $interface_if weight $weight"
else
routesbalancingbackup6="$routesbalancingbackup6 nexthop via $interface_gw dev $interface_if weight $weight"
fi
else
nbintf6=$((nbintf6+1))
routesbalancing6="$routesbalancing6 nexthop via $interface_gw dev $interface_if weight $weight"
if [ -z "$routesbalancingbackup" ]; then
routesbalancing6="nexthop via $interface_gw dev $interface_if weight $weight"
else
routesbalancing6="$routesbalancing6 nexthop via $interface_gw dev $interface_if weight $weight"
fi
fi
fi
fi
@ -561,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
}
@ -708,94 +724,7 @@ 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"]')
if [ -n "$(grep RUTX /etc/board.json)" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ "$OMR_TRACKER_DEVICE" = "wwan0" ]; then
modemdata=$(omr-modemmanager '/sys/devices/platform/soc/60f8800.usb2/6000000.dwc3/xhci-hcd.1.auto/usb3/3-1' all)
gen=$(echo $modemdata | cut -d ';' -f 5 | tr -d '\n')
if [ "$gen" = "gsm" ]; then
echo "default-on" > /sys/class/leds/mob_gen_2/trigger
echo "none" > /sys/class/leds/mob_gen_3/trigger
echo "none" > /sys/class/leds/mob_gen_4/trigger
elif [ "$gen" = "umts" ]; then
echo "none" > /sys/class/leds/mob_gen_2/trigger
echo "default-on" > /sys/class/leds/mob_gen_3/trigger
echo "none" > /sys/class/leds/mob_gen_4/trigger
elif [ "$gen" = "lte" ]; then
echo "none" > /sys/class/leds/mob_gen_2/trigger
echo "none" > /sys/class/leds/mob_gen_3/trigger
echo "default-on" > /sys/class/leds/mob_gen_4/trigger
fi
bar=$(echo $modemdata | cut -d ';' -f 1 | tr -d '\n')
if [ "$bar" -gt "0" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_1/trigger
else
echo "none" > /sys/class/leds/mob_ssid_1/trigger
fi
if [ "$bar" -gt "30" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_2/trigger
else
echo "none" > /sys/class/leds/mob_ssid_2/trigger
fi
if [ "$bar" -gt "50" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_3/trigger
else
echo "none" > /sys/class/leds/mob_ssid_3/trigger
fi
if [ "$bar" -gt "70" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_4/trigger
else
echo "none" > /sys/class/leds/mob_ssid_4/trigger
fi
if [ "$bar" -gt "90" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_5/trigger
else
echo "none" > /sys/class/leds/mob_ssid_5/trigger
fi
elif [ "$OMR_TRACKER_DEVICE" = "wwan1" ]; then
modemdata=$(omr-modemmanager '/sys/devices/platform/soc/8af8800.usb3/8a00000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1.2' all)
gen=$(echo $modemdata | cut -d ';' -f 5 | tr -d '\n')
if [ "$gen" = "gsm" ]; then
echo "default-on" > /sys/class/leds/mob2_gen_2/trigger
echo "none" > /sys/class/leds/mob2_gen_3/trigger
echo "none" > /sys/class/leds/mob2_gen_4/trigger
elif [ "$gen" = "umts" ]; then
echo "none" > /sys/class/leds/mob2_gen_2/trigger
echo "default-on" > /sys/class/leds/mob2_gen_3/trigger
echo "none" > /sys/class/leds/mob2_gen_4/trigger
elif [ "$gen" = "lte" ]; then
echo "none" > /sys/class/leds/mob2_gen_2/trigger
echo "none" > /sys/class/leds/mob2_gen_3/trigger
echo "default-on" > /sys/class/leds/mob2_gen_4/trigger
fi
bar=$(echo $modemdata | cut -d ';' -f 1 | tr -d '\n')
if [ "$bar" -gt "0" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_1/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_1/trigger
fi
if [ "$bar" -gt "30" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_2/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_2/trigger
fi
if [ "$bar" -gt "50" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_3/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_3/trigger
fi
if [ "$bar" -gt "70" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_4/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_4/trigger
fi
if [ "$bar" -gt "90" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_5/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_5/trigger
fi
fi
fi
initcwrwnd=""
# An interface in error will never be used in MPTCP
if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
@ -815,7 +744,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
modem_device=$(mmcli -m $modem -K | grep 'modem.generic.device ' | awk '{print $3}')
[ -n "$modem_device" ] && modem_interface=$(uci show network | grep $modem_device | awk -F. '{print $2}')
[ -n "$modem_interface" ] && {
_log "No anwser from $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE), restart associed interface $modem_interface"
_log "No answer from $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE), restart associed interface $modem_interface"
ifup $modem_interface
}
fi
@ -971,16 +900,16 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
# Set a little sleep after an interface error
if [ -n "$RANDOM" ]; then
sleep `expr $RANDOM % 10`
sleep `expr $RANDOM % 100`
else
sleep `awk 'BEGIN{srand();print int(rand()*9)}'`
sleep `awk 'BEGIN{srand();print int(rand()*20)}'`
fi
exit 0
fi
if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then
if [ "$(uci -q get openmptcprouter.settings.shadowsocksudp)" = "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "hi1" ]; then
if [ "$(uci -q get openmptcprouter.settings.shadowsocksudp)" = "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ -n "$(uci -q get shadowsocks-libev.sss0)" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "hi1" ]; then
_log "Tunnel up disable use of ShadowSocks for UDP"
uci -q delete shadowsocks-libev.ss_rules.redir_udp
if /etc/init.d/shadowsocks-libev rules_exist ; then
@ -991,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
@ -1002,6 +931,7 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
# Set VPN MTU
if [ -n "$OMR_TRACKER_LATENCY" ] && [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ]); then
local serverip=$(uci -q get shadowsocks-libev.sss0.server)
[ -z "$serverip" ] && serverip=$(uci -q get v2ray.omrout.s_vless_address)
[ -n "$serverip" ] && serverip="$(resolveip -4 -t 5 $serverip | head -n 1 | tr -d '\n')"
if [ "$serverip" = "192.168.1.3" ] || [ "$serverip" = "127.0.0.1" ]; then
serverip=""
@ -1014,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
@ -1107,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
@ -1194,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 &
@ -1304,538 +1234,3 @@ fi
}
}
#ubus call network reload
# Save wan settings for status page
if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(date +"%s") + $((30 + RANDOM % 31)) - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ] || [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.state)" = "down" ]); then
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Get status and settings for $OMR_TRACKER_INTERFACE..."
local ipaddr=""
local ip6addr=""
if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ]; then
[ -n "$OMR_TRACKER_DEVICE_IP" ] && ipaddr="$(omr-ip-intf $OMR_TRACKER_DEVICE)"
[ -n "$OMR_TRACKER_DEVICE_IP6" ] && ip6addr="$(omr-ip6-intf $OMR_TRACKER_DEVICE)"
else
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state="up"
fi
[ -n "$ipaddr" ] && {
# Check if we can get a IPv6 address, if yes enable RA else disable
#local check_ipv6_website="$(uci -q get openmptcprouter.settings.check_ipv6_website)"
#[ -z "$check_ipv6_website" ] && check_ipv6_website="http://ipv6.openmptcprouter.com/"
#local ip6addr="$(curl -s -6 -m 2 $check_ipv6_website)"
#[ -z "$ip6addr" ] && {
# local ip6addr="$(curl -s -6 -m 2 http://ifconfig.me/)"
#}
#if [ "$(uci -q get openmptcprouter.settings.ipv6_disable)" = "0" ]; then
# if [ -n "$ip6addr" ] && [ "$(uci -q get dhcp.lan.ra_default)" != 1 ]; then
# _log "Enable IPv6 RA"
# uci -q set dhcp.lan.ra=server
# uci -q set dhcp.lan.ra_default=1
# uci -q set dhcp.lan.dhcpv6=server
# /etc/init.d/odhcpd start > /dev/null 2>&1
# /etc/init.d/odhcpd enable > /dev/null 2>&1
# elif [ -z "$ip6addr" ] && [ "$(uci -q set dhcp.lan.ra_default)" = 1 ]; then
# _log "Disable IPv6 RA"
# uci -q delete dhcp.lan.ra
# uci -q delete dhcp.lan.dhcpv6
# /etc/init.d/odhcpd start > /dev/null 2>&1
# /etc/init.d/odhcpd enable > /dev/null 2>&1
# fi
#fi
if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ]; then
#local asn="$(wget -4 -qO- -T 4 http://api.iptoasn.com/v1/as/ip/$ipaddr | jsonfilter -q -e '@.as_description')"
#[ -z "$asn" ] && {
local asn="$(timeout 2 whois $ipaddr 2>/dev/null | grep -m 1 -i 'netname' | awk '{print $2}')"
#}
fi
[ -z "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE)" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE=interface
}
if [ "$(uci -q get openmptcprouter.latest_versions.lc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.latest_versions.lc))) -gt 3600 ]; then
local latestversions="$(curl -4 -s -m 3 https://55860.com/bak/version.json)"
[ -n "$latestversions" ] && {
uci -q set openmptcprouter.latest_versions=latest_versions
uci -q set openmptcprouter.latest_versions.omr=$(echo $latestversions | jsonfilter -q -e '@.omr')-$(ubus call system board | jsonfilter -e '@.kernel' | cut -d'.' -f1,2)
uci -q set openmptcprouter.latest_versions.vps=$(echo $latestversions | jsonfilter -q -e '@.vps')
uci -q set openmptcprouter.latest_versions.lc=$(date +"%s")
}
fi
[ -n "$ipaddr" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.publicip)" != "$ipaddr" ] && {
_log "New public ip detected for $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE): $ipaddr"
/etc/init.d/mptcp enabled && {
_log "Reload MPTCP for $OMR_TRACKER_DEVICE"
/etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE" 2>&1 >/dev/null
}
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.publicip="$ipaddr"
}
[ -n "$OMR_TRACKER_LATENCY" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
[ -n "$asn" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.asn)" != "$asn" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.asn="$asn"
}
# Routing loop detection
local lanip="$(uci -q get network.lan.ipaddr)"
local masterip
get_master_ip() {
if [ -n "$1" ] && [ "$(uci -q get openmptcprouter.$1.multipath)" = "master" ]; then
masterip="$(uci -q get openmptcprouter.$1.publicip)"
fi
}
config_load openmptcprouter
config_foreach get_master_ip interface
if [ -n "$lanip" ] && [ -n "$masterip" ] && [ -n "$ipaddr" ] && [ "$ipaddr" = "$masterip" ] && [ "$(uci -q get openmptcprouter.settings.disableloopdetection)" != "1" ]; then
loop=0
routingloop() {
vpsip=""
[ -n "$1"] && vpsip="$(uci -q get openmptcprouter.$1.ip)"
if [ -n "$vpsip" ] && [ "$(omr-routing-loop $vpsip $lanip $OMR_TRACKER_DEVICE)" = "detected" ]; then
loop=1
fi
}
config_load openmptcprouter
config_foreach routingloop server
if [ "$loop" = "1" ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.loop='1'
else
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.loop
fi
else
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.loop
fi
local omrtracebox
traceboxmtutest() {
omr_tracebox_mtu() {
local serverip=$1
[ "$serverip" != "${1#*[0-9].[0-9]}" ] && serverip=""
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && [ "$(pgrep -f tracebox)" = "" ] && [ "$(uci -q get openmptcprouter.settings.tracebox)" != "0" ] && {
omrtracebox="$(omr-tracebox-mptcp $serverip $OMR_TRACKER_DEVICE)"
[ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox"
}
#if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ -n "$(uci -q get network.$(find_network_device ${OMR_TRACKER_INTERFACE}).mtu)" ]; then
network_device=$(find_network_device ${OMR_TRACKER_INTERFACE})
mtu=""
[ -n "$network_device" ] && mtu=$(uci -q get network.${network_device}.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
}
elif [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
[ -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
}
config_list_foreach $1 ip omr_tracebox_mtu
}
config_load openmptcprouter
config_foreach traceboxmtutest server
[ "$(uci -q get openmptcprouter.settings.tracebox)" = "0" ] && [ -n "$OMR_TRACKER_DEVICE" ] && {
mptcpsupport="$(omr-mptcp-intf $OMR_TRACKER_DEVICE)"
[ -n "$mptcpsupport" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$mptcpsupport"
}
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
}
[ -n "$ip6addr" ] && {
if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ]; then
local asn="$(whois $ip6addr 2>/dev/null | grep -m 1 -i 'netname' | awk '{print $2}')"
fi
[ -z "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE)" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE=interface
}
if [ "$(uci -q get openmptcprouter.latest_versions.lc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.latest_versions.lc))) -gt 3600 ]; then
local latestversions="$(curl -6 -s -m 3 https://55860.com/bak/version.json)"
[ -n "$latestversions" ] && {
uci -q set openmptcprouter.latest_versions=latest_versions
uci -q set openmptcprouter.latest_versions.omr=$(echo $latestversions | jsonfilter -q -e '@.omr')
uci -q set openmptcprouter.latest_versions.vps=$(echo $latestversions | jsonfilter -q -e '@.vps')
uci -q set openmptcprouter.latest_versions.lc=$(date +"%s")
}
fi
[ -n "$ip6addr" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.publicip)" != "$ip6addr" ] && {
_log "New public ip detected for $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE): $ip6addr"
/etc/init.d/mptcp enabled && {
_log "Reload MPTCP for $OMR_TRACKER_DEVICE"
/etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE" 2>&1 >/dev/null
}
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.publicip="$ip6addr"
}
[ -n "$OMR_TRACKER_LATENCY" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
[ -n "$asn" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.asn="$asn"
}
local omrtracebox
traceboxmtutest() {
omr_tracebox_mtu() {
local serverip=$1
[ "$serverip" != "${1#*:[0-9a-fA-F]}" ] && serverip=""
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && [ "$(pgrep -f tracebox)" = "" ] && [ "$(uci -q get openmptcprouter.settings.tracebox)" != "0" ] && {
omrtracebox="$(omr-tracebox-mptcp $serverip $OMR_TRACKER_DEVICE)"
[ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox"
}
#if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
network_device=$(find_network_device ${OMR_TRACKER_INTERFACE})
if [ -n "$network_device" ] && [ -n "$(uci -q get network.${network_device}.mtu)" ]; then
mtu=$(uci -q get network.$(find_network_device ${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
}
elif [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && {
local mtu=$(omr-mtu6 $OMR_TRACKER_DEVICE_IP6 $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-mtu6 $OMR_TRACKER_DEVICE_IP6 2606:4700:4700::1111)
[ -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
}
config_list_foreach $1 ip omr_tracebox_mtu
}
config_load openmptcprouter
config_foreach traceboxmtutest server
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
}
if [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get openmptcprouter.settings.external_check)" = "0" ]; then
if ping -B -I $OMR_TRACKER_DEVICE -c 1 $(uci -q get shadowsocks-libev.sss0.server) 2>&1 >/dev/null; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
fi
fi
proto="$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)"
#if [ "$proto" = "qmi" ]; then
# intfdata="$(omr-qmi $OMR_TRACKER_DEVICE all | tr -d '\n')"
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.operator=$(echo $intfdata | awk -F";" '{print $2}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.number=$(echo $intfdata | awk -F";" '{print $3}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state=$(echo $intfdata | awk -F";" '{print $4}')
#elif [ "$proto" = "modemmanager" ]; then
# intfdata="$(omr-modemmanager $OMR_TRACKER_DEVICE all)"
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.operator=$(echo $intfdata | awk -F";" '{print $2}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.number=$(echo $intfdata | awk -F";" '{print $3}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state=$(echo $intfdata | awk -F";" '{print $4}')
#else
if [ "$proto" != "qmi" ] && [ "$proto" != "modemmanager" ]; then
if [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ] && [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$(curl --interface $OMR_TRACKER_DEVICE_IP -s -m 2 -X GET http://$OMR_TRACKER_DEVICE_GATEWAY/api/webserver/SesTokInfo)" ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.manufacturer='huawei'
else
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.manufacturer
fi
fi
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(( $(date +"%s") - 3400 ))
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Get status and settings for $OMR_TRACKER_INTERFACE... Failed"
uci -q commit openmptcprouter
else
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Get status and settings for $OMR_TRACKER_INTERFACE... Done"
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
if [ "$(pgrep -f 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
[ -n "$OMR_TRACKER_INTERFACE" ] && [ -n "$OMR_TRACKER_LATENCY" ] && {
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency)" != "" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency_previous="$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency)"
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
#[ -z "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max="$OMR_TRACKER_LATENCY"
#[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max)" -lt "$OMR_TRACKER_LATENCY" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max="$OMR_TRACKER_LATENCY"
if [ "$multipath_config" = "on" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath)" != "master" ] && ([ "$(uci -q get openmptcprouter.settings.master)" = "dynamic" ] || ( ( [ "$(uci -q get openmptcprouter.settings.master)" = "change" ] || [ "$(uci -q get openmptcprouter.settings.master)" = "" ] ) && [ "$(uci -q get openmptcprouter.settings.master_lcintf | grep $OMR_TRACKER_INTERFACE)" = "" ] ) ); then
masterintf="$(uci -q show openmptcprouter | grep -m 1 multipath=\'master\' | cut -d'.' -f2)"
[ -z "$masterintf" ] && masterintf="$(uci -q show network | grep -m 1 multipath=\'master\' | cut -d'.' -f2)"
masterlatency="$(uci -q get openmptcprouter.$masterintf.latency | tr -d '\n')"
if [ -z "$masterlatency" ] || ([ -n "$masterintf" ] && [ "$(uci -q get openmptcprouter.$masterintf.state)" = "down" ]); then
masterlatency=1000
fi
if [ -n "$masterintf" ] && ([ "$masterlatency" != "" ] || [ "$(uci -q get openmptcprouter.$masterintf.state)" = "down" ]); then
if ( ( [ "$(uci -q get openmptcprouter.settings.master)" = "change" ] || [ "$(uci -q get openmptcprouter.settings.master)" = "" ] ) && [ "$OMR_TRACKER_LATENCY" -lt $(awk "BEGIN {printf \"%i\",${masterlatency}/1.5}") ] ) || ( [ "$(uci -q get openmptcprouter.settings.master)" = "dynamic" ] && [ "$OMR_TRACKER_LATENCY" -lt "$((masterlatency/2))" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_previous)" -lt "$((masterlatency/2))" ] ); then
uci -q set network.$masterintf.multipath='on'
uci -q set openmptcprouter.$masterintf.multipath='on'
uci -q set network.$OMR_TRACKER_INTERFACE.multipath='master'
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.multipath='master'
if [ "$(uci -q get openmptcprouter.settings.master_lcintf | grep $OMR_TRACKER_INTERFACE)" = "" ]; then
uci -q add_list openmptcprouter.settings.master_lcintf="$OMR_TRACKER_INTERFACE"
fi
if [ "$(uci -q get openmptcprouter.settings.master)" = "" ]; then
uci -q set openmptcprouter.settings.master="change"
fi
if [ "$(uci -q get openmptcprouter.settings.master)" != "dynamic" ]; then
[ -n "$(uci -q changes network)" ] && uci -q commit network
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
_log "Change master interface from $masterintf ($masterlatency ms) to $OMR_TRACKER_INTERFACE ($OMR_TRACKER_LATENCY ms)"
fi
fi
fi
}
if [ -n "$OMR_TRACKER_INTERFACE" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
addlatency=$(uci -q get network.${OMR_TRACKER_INTERFACE}.addlatency)
[ -z "$addlatency" ] && addlatency="0"
if [ "$addlatency" = "0" ] && [ "$(tc qdisc show dev $OMR_TRACKER_DEVICE | grep delay)" != "" ]; then
tc qdisc del dev ${OMR_TRACKER_DEVICE} root netem 2>&1 >/dev/null
fi
if [ "$addlatency" != "0" ]; then
if [ "$(tc qdisc show dev $OMR_TRACKER_DEVICE | grep delay)" = "" ]; then
tc qdisc add dev ${OMR_TRACKER_DEVICE} root netem delay ${addlatency}ms 2>&1 >/dev/null
elif [ "$(tc qdisc show dev $OMR_TRACKER_DEVICE | awk '/delay/ { print $10 }' | sed 's/ms//')" != "$addlatency" ]; then
tc qdisc replace dev ${OMR_TRACKER_DEVICE} root netem delay ${addlatency}ms 2>&1 >/dev/null
fi
fi
fi
if [ "$(pgrep -f omr-test-speed-server)" = "" ] && [ "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.testspeed)" = "1" ] && [ -z "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.testspeed_lc)" ]; then
launch_speedtest() {
local server=$1
[ "$(uci -q get openmptcprouter.${server}.current)" != "1" ] && return
download_speed=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest)
download_speed2=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest)
download_speed3=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest)
[ "$download_speed2" -gt "$download_speed" ] && download_speed=${download_speed2}
[ "$download_speed3" -gt "$download_speed" ] && download_speed=${download_speed3}
download_speed=$((download_speed*8/1000))
if [ -n "$download_speed" ] && [ "$download_speed" != "0" ]; then
upload_speed=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest upload)
upload_speed2=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest upload)
upload_speed3=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest upload)
[ "$upload_speed2" -gt "$upload_speed" ] && upload_speed=${upload_speed2}
[ "$upload_speed3" -gt "$upload_speed" ] && upload_speed=${upload_speed3}
# Set Download speed settings
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ]; then
uci -q set sqm.${OMR_TRACKER_INTERFACE}.download=$((download_speed*65/100))
uci -q set sqm.${OMR_TRACKER_INTERFACE}.max_download=${download_speed}
uci -q set sqm.${OMR_TRACKER_INTERFACE}.min_download=$((download_speed*10/100))
else
uci -q set sqm.${OMR_TRACKER_INTERFACE}.download=$((download_speed*95/100))
fi
_log "Calculated ${OMR_TRACKER_INTERFACE} download speed: ${download_speed}"
uci -q set network.${OMR_TRACKER_INTERFACE}.downloadspeed=${download_speed}
# Set Upload speed settings
upload_speed=$((upload_speed*8/1000))
if [ -n "$upload_speed" ] && [ "$upload_speed" != "0" ]; then
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ]; then
uci -q set sqm.${OMR_TRACKER_INTERFACE}.upload=$((upload_speed*65/100))
uci -q set sqm.${OMR_TRACKER_INTERFACE}.max_upload=${upload_speed}
uci -q set sqm.${OMR_TRACKER_INTERFACE}.min_upload=$((upload_speed*10/100))
else
uci -q set sqm.${OMR_TRACKER_INTERFACE}.upload=$((upload_speed*95/100))
fi
_log "Calculated ${OMR_TRACKER_INTERFACE} upload speed: ${upload_speed}"
uci -q set network.${OMR_TRACKER_INTERFACE}.uploadspeed=${upload_speed}
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.testspeed_lc=$(date +"%s")
uci commit network
uci commit sqm
uci commit openmptcprouter
fi
fi
}
config_load openmptcprouter
config_foreach launch_speedtest server
sleep 5
fi
# If a service is down, force restart it
if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f ss-redir)" = "" ] && [ "$(pgrep -f ss-local)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" != "" ]; then
_log "Can't find Shadowsocks, restart it..."
/etc/init.d/shadowsocks-libev restart 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/init.d/glorytun ] && [ "$(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 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/init.d/glorytun-udp ] && [ "$(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 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep -f dnsmasq)" = "" ] && [ -f /etc/init.d/dnsmasq ]; then
_log "Can't find dnsmasq, restart it..."
/etc/init.d/dnsmasq restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep -f unbound)" = "" ] && [ -f /etc/init.d/unbound ] && [ "$(uci -q get unbound.@unbound[0].enabled)" = "1" ]; then
_log "Can't find unbound, restart it..."
/etc/init.d/unbound restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep openvpn)" = "" ] && [ -f /etc/init.d/openvpn ]; then
openvpn_enable=0
openvpn_enabled() {
[ "$(uci -q get openvpn.$1.enabled)" = "1" ] && openvpn_enable=1
}
config_load openvpn
config_foreach openvpn_enabled openvpn
if [ "$openvpn_enable" = "1" ]; then
_log "Can't find OpenVPN, restart it"
/etc/init.d/openvpn restart 2>&1 >/dev/null
sleep 5
fi
fi
if [ "$(pgrep mlvpn)" = "" ] && [ "$(uci -q get mlvpn.general.enable)" = "1" ] && [ -f /etc/init.d/mlvpn ] && [ "$(uci -q get mlvpn.general.password)" != "" ]; then
_log "Can't find MLVPN, restart it..."
/etc/init.d/mlvpn restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep dsvpn)" = "" ] && [ "$(uci -q get dsvpn.vpn.enable)" = "1" ] && [ -f /etc/init.d/dsvpn ] && [ "$(uci -q get dsvpn.vpn.key)" != "" ]; then
_log "Can't find DSVPN, restart it..."
/etc/init.d/dsvpn restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep -f v2ray)" = "" ] && [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -f /etc/init.d/v2ray ]; then
_log "Can't find V2Ray, restart it..."
/etc/init.d/v2ray restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep miniupnpd)" = "" ] && [ "$(uci -q get upnpd.config.enabled)" = "1" ] && [ -f /etc/init.d/miniupnpd ]; then
_log "Can't find miniupnpd, restart it..."
/etc/init.d/miniupnpd restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep rpcd)" = "" ] && [ -f /etc/init.d/rpcd ]; then
_log "Can't find rpcd, restart it..."
/etc/init.d/rpcd restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep uhttpd)" = "" ] && [ -f /etc/init.d/uhttpd ]; then
_log "Can't find uhttpd, restart it..."
/etc/init.d/uhttpd restart 2>&1 >/dev/null
sleep 5
fi
#if [ "$(pgrep ModemManager)" = "" ] && [ -f /etc/init.d/modemmanager ] && [ -n "$(uci -q show network | grep modemmanager)" ] && [ "$(uci -q get openmptcprouter.settings.modemmanager)" != "0" ]; then
# _log "Can't find ModemManager, restart it..."
# /etc/init.d/modemmanager restart 2>&1 >/dev/null
# sleep 5
#fi
if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -f /etc/init.d/v2ray ] && [ "$(pgrep -f omr-tracker-v2ray)" = "" ] && [ "$(pgrep -f '/etc/init.d/omr-tracker')" = "" ]; then
_log "Can't find omr-tracker-v2ray, restart omr-tracker..."
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi
set_get_config() {
local server=$1
[ -n "$server" ] && uci -q set openmptcprouter.${server}.get_config=1
}
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ]; then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f '/etc/init.d/omr-tracker')" = "" ]; then
_log "Can't find omr-tracker-ss, restart omr-tracker..."
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi
if [ "$(uci -q get glorytun.vpn.enable)" = "1" ] && [ "$(uci -q get glorytun.vpn.key)" = "" ]; then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ "$(uci -q get v2ray.omrout.s_vless_user_id)" = "" ]; then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
if [ -n "$(logread | tail -n 2 | grep 'Ring expansion failed')" ]; then
_log "Workaround Ring expansion failed problem"
echo 1 > /sys/bus/pci/devices/0000:00:00.0/remove
sleep 2
echo 1 > /sys/bus/pci/rescan
fi
if [ -f /etc/init.d/omr-bypass ] && (([ -f /usr/sbin/iptables-legacy-save ] && [ "$(iptables-legacy-save 2>/dev/null | grep omr-bypass)" = "" ]) || [ "$(iptables-save 2>/dev/null | grep omr-bypass)" = "" ]) && [ "$(pgrep -f omr-bypass)" = "" ]; then
_log "Can't find omr-bypass rules, restart omr-bypass..."
/etc/init.d/omr-bypass 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/backup/installed_packages.txt ] && [ -n "$(grep overlay /etc/backup/installed_packages.txt)" ] && ([ "$(uci -q get openmptcprouter.settings.sysupgrade_lc)" = "" ] || [ $(($(date +"%s") + $((30 + RANDOM % 31)) - $(uci -q get openmptcprouter.settings.sysupgrade_lc))) -gt 3600 ]) && [ $(($(date +"%s") - $(stat -c "%Y" /etc/backup/installed_packages.txt))) -gt 86400 ]; then
_log "Reinstall packages..."
uci -q set openmptcprouter.settings.sysupgrade_lc=$(date +"%s")
/etc/init.d/sysupgrade restart 2>&1 >/dev/null
sleep 10
fi
if [ "$(pgrep -f openmptcprouter-vps)" = "" ] && [ "$(uci -q show openmptcprouter | grep token_error=\'1\')" != "" ]; then
/etc/init.d/openmptcprouter-vps token >/dev/null 2>&1 &
sleep 5
fi
if [ "$(pgrep -f openmptcprouter-vps)" = "" ] && ([ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]); then
/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 &
sleep 5
fi
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.enabled)" = "1" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ -z $(pgrep -f "config.${OMR_TRACKER_INTERFACE}") ]; then
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.max_download)" != "0" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.download)" != "0" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.max_upload)" != "0" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.upload)" != "0" ]; then
_log "Restart SQM Autorate"
/etc/init.d/sqm-autorate restart >/dev/null 2>&1
sleep 5
fi
fi
#if [ "$(uci -q show openmptcprouter | grep server)" != "" ] && [ "$(uci -q show openmptcprouter | grep password)" != "" ] && [ "$(pgrep -f openmptcprouter-vps)" = "" ] && [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" = "" ] && ([ "$(uci -q show openmptcprouter | grep set_firewall=\'1\')" != "" ] || (([ -f /usr/sbin/iptables-legacy-save ] && [ -z "$(iptables-save 2>/dev/null | grep omr_dst_bypass_${OMR_TRACKER_DEVICE})" ]) || [ -z "$(iptables-save 2>/dev/null | grep omr_dst_bypass_${OMR_TRACKER_DEVICE})" ])); then
if [ "$(pgrep -f set_vps_firewall)" = "" ] && [ "$(uci -q show openmptcprouter | grep server)" != "" ] && [ "$(uci -q show openmptcprouter | grep password)" != "" ] && [ "$(pgrep -f openmptcprouter-vps)" = "" ] && [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" = "" ] && [ "$(uci -q show openmptcprouter | grep set_firewall=\'1\')" != "" ]; then
check_server_fw() {
[ "$(uci -q get openmptcprouter.$1.set_firewall)" = "1" ] && {
_log "Set firewall on server $1"
/etc/init.d/openmptcprouter-vps set_vps_firewall $1 >/dev/null 2>&1
}
}
config_load openmptcprouter
config_foreach check_server_fw server
run_fw_include() {
[ -n "$1" ] && [ "$(uci -q get firewall.$1.reload)" = "0" ] && sh $(uci -q get firewall.$1.path) >/dev/null 2>&1
}
config_load firewall
config_foreach run_fw_include include
#/etc/init.d/shadowsocks-libev rules_up >/dev/null 2>&1
#/etc/init.d/v2ray rules_up >/dev/null 2>&1
#/etc/init.d/omr-bypass reload_rules >/dev/null 2>&1
#sh /etc/firewall.gre-tunnel >/dev/null 2>&1
/bin/blocklanfw >/dev/null 2>&1
sleep 5
fi

View file

@ -0,0 +1,184 @@
#
# Copyright (C) 2018-2023 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 services status and do appropriate actions
# If a service is down, force restart it
if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f ss-redir)" = "" ] && [ "$(pgrep -f ss-local)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" != "" ]; then
_log "Can't find Shadowsocks, restart it..."
/etc/init.d/shadowsocks-libev restart 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/init.d/glorytun ] && [ "$(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 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/init.d/glorytun-udp ] && [ "$(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 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep -f dnsmasq)" = "" ] && [ -f /etc/init.d/dnsmasq ]; then
_log "Can't find dnsmasq, restart it..."
/etc/init.d/dnsmasq restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep -f unbound)" = "" ] && [ -f /etc/init.d/unbound ] && [ "$(uci -q get unbound.@unbound[0].enabled)" = "1" ]; then
_log "Can't find unbound, restart it..."
/etc/init.d/unbound restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep openvpn)" = "" ] && [ -f /etc/init.d/openvpn ]; then
openvpn_enable=0
openvpn_enabled() {
[ "$(uci -q get openvpn.$1.enabled)" = "1" ] && openvpn_enable=1
}
config_load openvpn
config_foreach openvpn_enabled openvpn
if [ "$openvpn_enable" = "1" ]; then
_log "Can't find OpenVPN, restart it"
/etc/init.d/openvpn restart 2>&1 >/dev/null
sleep 5
fi
fi
if [ "$(pgrep mlvpn)" = "" ] && [ "$(uci -q get mlvpn.general.enable)" = "1" ] && [ -f /etc/init.d/mlvpn ] && [ "$(uci -q get mlvpn.general.password)" != "" ]; then
_log "Can't find MLVPN, restart it..."
/etc/init.d/mlvpn restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep dsvpn)" = "" ] && [ "$(uci -q get dsvpn.vpn.enable)" = "1" ] && [ -f /etc/init.d/dsvpn ] && [ "$(uci -q get dsvpn.vpn.key)" != "" ]; then
_log "Can't find DSVPN, restart it..."
/etc/init.d/dsvpn restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep -f v2ray)" = "" ] && [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -f /etc/init.d/v2ray ]; then
_log "Can't find V2Ray, restart it..."
/etc/init.d/v2ray restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep miniupnpd)" = "" ] && [ "$(uci -q get upnpd.config.enabled)" = "1" ] && [ -f /etc/init.d/miniupnpd ]; then
_log "Can't find miniupnpd, restart it..."
/etc/init.d/miniupnpd restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep rpcd)" = "" ] && [ -f /etc/init.d/rpcd ]; then
_log "Can't find rpcd, restart it..."
/etc/init.d/rpcd restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep uhttpd)" = "" ] && [ -f /etc/init.d/uhttpd ]; then
_log "Can't find uhttpd, restart it..."
/etc/init.d/uhttpd restart 2>&1 >/dev/null
sleep 5
fi
#if [ "$(pgrep ModemManager)" = "" ] && [ -f /etc/init.d/modemmanager ] && [ -n "$(uci -q show network | grep modemmanager)" ] && [ "$(uci -q get openmptcprouter.settings.modemmanager)" != "0" ]; then
# _log "Can't find ModemManager, restart it..."
# /etc/init.d/modemmanager restart 2>&1 >/dev/null
# sleep 5
#fi
if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -f /etc/init.d/v2ray ] && [ "$(pgrep -f omr-tracker-v2ray)" = "" ] && [ "$(pgrep -f '/etc/init.d/omr-tracker')" = "" ]; then
_log "Can't find omr-tracker-v2ray, restart omr-tracker..."
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi
set_get_config() {
local server=$1
[ -n "$server" ] && uci -q set openmptcprouter.${server}.get_config=1
}
if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ]; then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f '/etc/init.d/omr-tracker')" = "" ]; then
_log "Can't find omr-tracker-ss, restart omr-tracker..."
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi
if [ "$(uci -q get glorytun.vpn.enable)" = "1" ] && [ "$(uci -q get glorytun.vpn.key)" = "" ]; then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ "$(uci -q get v2ray.omrout.s_vless_user_id)" = "" ]; then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
if [ -n "$(logread | tail -n 2 | grep 'Ring expansion failed')" ]; then
_log "Workaround Ring expansion failed problem"
echo 1 > /sys/bus/pci/devices/0000:00:00.0/remove
sleep 2
echo 1 > /sys/bus/pci/rescan
fi
if [ -f /etc/init.d/omr-bypass ] && (([ -f /usr/sbin/iptables-legacy-save ] && [ "$(iptables-legacy-save 2>/dev/null | grep omr-bypass)" = "" ]) || [ "$(iptables-save 2>/dev/null | grep omr-bypass)" = "" ]) && [ "$(pgrep -f omr-bypass)" = "" ]; then
_log "Can't find omr-bypass rules, restart omr-bypass..."
/etc/init.d/omr-bypass 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/backup/installed_packages.txt ] && [ -n "$(grep overlay /etc/backup/installed_packages.txt)" ] && ([ "$(uci -q get openmptcprouter.settings.sysupgrade_lc)" = "" ] || [ $(($(date +"%s") + $((30 + RANDOM % 31)) - $(uci -q get openmptcprouter.settings.sysupgrade_lc))) -gt 3600 ]) && [ $(($(date +"%s") - $(stat -c "%Y" /etc/backup/installed_packages.txt))) -gt 86400 ]; then
_log "Reinstall packages..."
uci -q set openmptcprouter.settings.sysupgrade_lc=$(date +"%s")
/etc/init.d/sysupgrade restart 2>&1 >/dev/null
sleep 10
fi
if [ "$(pgrep -f openmptcprouter-vps)" = "" ] && [ "$(uci -q show openmptcprouter | grep token_error=\'1\')" != "" ]; then
/etc/init.d/openmptcprouter-vps token >/dev/null 2>&1 &
sleep 5
fi
if [ "$(pgrep -f openmptcprouter-vps)" = "" ] && ([ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]); then
/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 &
sleep 5
fi
if [ -n "$OMR_TRACKER_INTERFACE" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.enabled)" = "1" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ -z $(pgrep -f "config.${OMR_TRACKER_INTERFACE}") ]; then
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.max_download)" != "0" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.download)" != "0" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.max_upload)" != "0" ] && [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.upload)" != "0" ]; then
_log "Restart SQM Autorate"
/etc/init.d/sqm-autorate restart >/dev/null 2>&1
sleep 5
fi
fi
#if [ "$(uci -q show openmptcprouter | grep server)" != "" ] && [ "$(uci -q show openmptcprouter | grep password)" != "" ] && [ "$(pgrep -f openmptcprouter-vps)" = "" ] && [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" = "" ] && ([ "$(uci -q show openmptcprouter | grep set_firewall=\'1\')" != "" ] || (([ -f /usr/sbin/iptables-legacy-save ] && [ -z "$(iptables-save 2>/dev/null | grep omr_dst_bypass_${OMR_TRACKER_DEVICE})" ]) || [ -z "$(iptables-save 2>/dev/null | grep omr_dst_bypass_${OMR_TRACKER_DEVICE})" ])); then
if [ "$(pgrep -f set_vps_firewall)" = "" ] && [ "$(uci -q show openmptcprouter | grep server)" != "" ] && [ "$(uci -q show openmptcprouter | grep password)" != "" ] && [ "$(pgrep -f openmptcprouter-vps)" = "" ] && [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" = "" ] && [ "$(uci -q show openmptcprouter | grep set_firewall=\'1\')" != "" ]; then
check_server_fw() {
[ "$(uci -q get openmptcprouter.$1.set_firewall)" = "1" ] && {
_log "Set firewall on server $1"
/etc/init.d/openmptcprouter-vps set_vps_firewall $1 >/dev/null 2>&1
}
}
config_load openmptcprouter
config_foreach check_server_fw server
run_fw_include() {
[ -n "$1" ] && [ "$(uci -q get firewall.$1.reload)" = "0" ] && sh $(uci -q get firewall.$1.path) >/dev/null 2>&1
}
config_load firewall
config_foreach run_fw_include include
#/etc/init.d/shadowsocks-libev rules_up >/dev/null 2>&1
#/etc/init.d/v2ray rules_up >/dev/null 2>&1
#/etc/init.d/omr-bypass reload_rules >/dev/null 2>&1
#sh /etc/firewall.gre-tunnel >/dev/null 2>&1
/bin/blocklanfw >/dev/null 2>&1
sleep 5
fi

View file

@ -0,0 +1,273 @@
#
# Copyright (C) 2018-2023 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 save settings for status page usage
[ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ -z "$OMR_TRACKER_INTERFACE" ] && exit 0
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
[ "$interface_up" != "true" ] && exit 0
# Save wan settings for status page
if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(date +"%s") + $((30 + RANDOM % 31)) - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ] || [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.state)" = "down" ]); then
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Get status and settings for $OMR_TRACKER_INTERFACE..."
local ipaddr=""
local ip6addr=""
if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ]; then
[ -n "$OMR_TRACKER_DEVICE_IP" ] && ipaddr="$(omr-ip-intf $OMR_TRACKER_DEVICE)"
[ -n "$OMR_TRACKER_DEVICE_IP6" ] && ip6addr="$(omr-ip6-intf $OMR_TRACKER_DEVICE)"
else
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state="up"
fi
[ -n "$ipaddr" ] && {
# Check if we can get a IPv6 address, if yes enable RA else disable
#local check_ipv6_website="$(uci -q get openmptcprouter.settings.check_ipv6_website)"
#[ -z "$check_ipv6_website" ] && check_ipv6_website="http://ipv6.openmptcprouter.com/"
#local ip6addr="$(curl -s -6 -m 2 $check_ipv6_website)"
#[ -z "$ip6addr" ] && {
# local ip6addr="$(curl -s -6 -m 2 http://ifconfig.me/)"
#}
#if [ "$(uci -q get openmptcprouter.settings.ipv6_disable)" = "0" ]; then
# if [ -n "$ip6addr" ] && [ "$(uci -q get dhcp.lan.ra_default)" != 1 ]; then
# _log "Enable IPv6 RA"
# uci -q set dhcp.lan.ra=server
# uci -q set dhcp.lan.ra_default=1
# uci -q set dhcp.lan.dhcpv6=server
# /etc/init.d/odhcpd start > /dev/null 2>&1
# /etc/init.d/odhcpd enable > /dev/null 2>&1
# elif [ -z "$ip6addr" ] && [ "$(uci -q set dhcp.lan.ra_default)" = 1 ]; then
# _log "Disable IPv6 RA"
# uci -q delete dhcp.lan.ra
# uci -q delete dhcp.lan.dhcpv6
# /etc/init.d/odhcpd start > /dev/null 2>&1
# /etc/init.d/odhcpd enable > /dev/null 2>&1
# fi
#fi
if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ]; then
#local asn="$(wget -4 -qO- -T 4 http://api.iptoasn.com/v1/as/ip/$ipaddr | jsonfilter -q -e '@.as_description')"
#[ -z "$asn" ] && {
local asn="$(timeout 2 whois $ipaddr 2>/dev/null | grep -m 1 -i 'netname' | awk '{print $2}')"
#}
fi
[ -z "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE)" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE=interface
}
if [ "$(uci -q get openmptcprouter.latest_versions.lc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.latest_versions.lc))) -gt 3600 ]; then
local latestversions="$(curl -4 -s -m 3 https://55860.com/bak/version.json)"
[ -n "$latestversions" ] && {
uci -q set openmptcprouter.latest_versions=latest_versions
uci -q set openmptcprouter.latest_versions.omr=$(echo $latestversions | jsonfilter -q -e '@.omr')-$(ubus call system board | jsonfilter -e '@.kernel' | cut -d'.' -f1,2)
uci -q set openmptcprouter.latest_versions.vps=$(echo $latestversions | jsonfilter -q -e '@.vps')
uci -q set openmptcprouter.latest_versions.lc=$(date +"%s")
}
fi
[ -n "$ipaddr" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.publicip)" != "$ipaddr" ] && {
_log "New public ip detected for $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE): $ipaddr (previous: $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.publicip))"
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.publicip="$ipaddr"
/etc/init.d/mptcp enabled && {
_log "Reload MPTCP for $OMR_TRACKER_DEVICE"
/etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE" 2>&1 >/dev/null
}
}
[ -n "$OMR_TRACKER_LATENCY" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
[ -n "$asn" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.asn)" != "$asn" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.asn="$asn"
}
# Routing loop detection
local lanip="$(uci -q get network.lan.ipaddr)"
local masterip
get_master_ip() {
if [ -n "$1" ] && [ "$(uci -q get openmptcprouter.$1.multipath)" = "master" ]; then
masterip="$(uci -q get openmptcprouter.$1.publicip)"
fi
}
config_load openmptcprouter
config_foreach get_master_ip interface
if [ -n "$lanip" ] && [ -n "$masterip" ] && [ -n "$ipaddr" ] && [ "$ipaddr" = "$masterip" ] && [ "$(uci -q get openmptcprouter.settings.disableloopdetection)" != "1" ]; then
loop=0
routingloop() {
vpsip=""
[ -n "$1"] && vpsip="$(uci -q get openmptcprouter.$1.ip)"
if [ -n "$vpsip" ] && [ "$(omr-routing-loop $vpsip $lanip $OMR_TRACKER_DEVICE)" = "detected" ]; then
loop=1
fi
}
config_load openmptcprouter
config_foreach routingloop server
if [ "$loop" = "1" ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.loop='1'
else
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.loop
fi
else
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.loop
fi
local omrtracebox
traceboxmtutest() {
omr_tracebox_mtu() {
local serverip=$1
[ "$serverip" != "${1#*[0-9].[0-9]}" ] && serverip=""
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && [ "$(pgrep -f tracebox)" = "" ] && [ "$(uci -q get openmptcprouter.settings.tracebox)" != "0" ] && {
omrtracebox="$(omr-tracebox-mptcp $serverip $OMR_TRACKER_DEVICE)"
[ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox"
}
#if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ -n "$(uci -q get network.$(find_network_device ${OMR_TRACKER_INTERFACE}).mtu)" ]; then
network_device=$(find_network_device ${OMR_TRACKER_INTERFACE})
mtu=""
[ -n "$network_device" ] && mtu=$(uci -q get network.${network_device}.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
}
elif [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && {
local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP $serverip)
[ -n "$mtu" ] && [ "$mtu" != "$(ip --json link show dev $OMR_TRACKER_DEVICE | jsonfilter -e '@[0].mtu' | tr -d '\n')" ] && {
mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP $serverip)
[ -n "$mtu" ] && [ "$mtu" != "$(ip --json link show dev $OMR_TRACKER_DEVICE | jsonfilter -e '@[0].mtu' | tr -d '\n')" ] && {
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" ] && [ "$mtu" != "$(ip --json link show dev $OMR_TRACKER_DEVICE | jsonfilter -e '@[0].mtu' | tr -d '\n')" ] && {
mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP $serverip)
[ -n "$mtu" ] && [ "$mtu" != "$(ip --json link show dev $OMR_TRACKER_DEVICE | jsonfilter -e '@[0].mtu' | tr -d '\n')" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
}
}
}
fi
fi
}
config_list_foreach $1 ip omr_tracebox_mtu
}
config_load openmptcprouter
config_foreach traceboxmtutest server
[ "$(uci -q get openmptcprouter.settings.tracebox)" = "0" ] && [ -n "$OMR_TRACKER_DEVICE" ] && {
mptcpsupport="$(omr-mptcp-intf $OMR_TRACKER_DEVICE)"
[ -n "$mptcpsupport" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$mptcpsupport"
}
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
}
[ -n "$ip6addr" ] && {
if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ]; then
local asn="$(whois $ip6addr 2>/dev/null | grep -m 1 -i 'netname' | awk '{print $2}')"
fi
[ -z "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE)" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE=interface
}
if [ "$(uci -q get openmptcprouter.latest_versions.lc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.latest_versions.lc))) -gt 3600 ]; then
local latestversions="$(curl -6 -s -m 3 https://55860.com/bak/version.json)"
[ -n "$latestversions" ] && {
uci -q set openmptcprouter.latest_versions=latest_versions
uci -q set openmptcprouter.latest_versions.omr=$(echo $latestversions | jsonfilter -q -e '@.omr')
uci -q set openmptcprouter.latest_versions.vps=$(echo $latestversions | jsonfilter -q -e '@.vps')
uci -q set openmptcprouter.latest_versions.lc=$(date +"%s")
}
fi
[ -n "$ip6addr" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.publicip)" != "$ip6addr" ] && {
_log "New public ip detected for $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE): $ip6addr"
/etc/init.d/mptcp enabled && {
_log "Reload MPTCP for $OMR_TRACKER_DEVICE"
/etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE" 2>&1 >/dev/null
}
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.publicip="$ip6addr"
}
[ -n "$OMR_TRACKER_LATENCY" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
[ -n "$asn" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.asn="$asn"
}
local omrtracebox
traceboxmtutest() {
omr_tracebox_mtu() {
local serverip=$1
[ "$serverip" != "${1#*:[0-9a-fA-F]}" ] && serverip=""
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && [ "$(pgrep -f tracebox)" = "" ] && [ "$(uci -q get openmptcprouter.settings.tracebox)" != "0" ] && {
omrtracebox="$(omr-tracebox-mptcp $serverip $OMR_TRACKER_DEVICE)"
[ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox"
}
#if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
network_device=$(find_network_device ${OMR_TRACKER_INTERFACE})
if [ -n "$network_device" ] && [ -n "$(uci -q get network.${network_device}.mtu)" ]; then
mtu=$(uci -q get network.$(find_network_device ${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
}
elif [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
[ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && {
local mtu=$(omr-mtu6 $OMR_TRACKER_DEVICE_IP6 $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-mtu6 $OMR_TRACKER_DEVICE_IP6 2606:4700:4700::1111)
[ -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
}
config_list_foreach $1 ip omr_tracebox_mtu
}
config_load openmptcprouter
config_foreach traceboxmtutest server
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
}
if [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get openmptcprouter.settings.external_check)" = "0" ]; then
if ping -B -I $OMR_TRACKER_DEVICE -c 1 $(uci -q get shadowsocks-libev.sss0.server) 2>&1 >/dev/null; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
fi
fi
proto="$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)"
#if [ "$proto" = "qmi" ]; then
# intfdata="$(omr-qmi $OMR_TRACKER_DEVICE all | tr -d '\n')"
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.operator=$(echo $intfdata | awk -F";" '{print $2}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.number=$(echo $intfdata | awk -F";" '{print $3}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state=$(echo $intfdata | awk -F";" '{print $4}')
#elif [ "$proto" = "modemmanager" ]; then
# intfdata="$(omr-modemmanager $OMR_TRACKER_DEVICE all)"
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.operator=$(echo $intfdata | awk -F";" '{print $2}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.number=$(echo $intfdata | awk -F";" '{print $3}')
# uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state=$(echo $intfdata | awk -F";" '{print $4}')
#else
if [ "$proto" != "qmi" ] && [ "$proto" != "modemmanager" ]; then
if [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ] && [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$(curl --interface $OMR_TRACKER_DEVICE_IP -s -m 2 -X GET http://$OMR_TRACKER_DEVICE_GATEWAY/api/webserver/SesTokInfo)" ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.manufacturer='huawei'
else
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.manufacturer
fi
fi
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(date +"%s") - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(( $(date +"%s") - 3400 ))
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Get status and settings for $OMR_TRACKER_INTERFACE... Failed"
uci -q commit openmptcprouter
else
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Get status and settings for $OMR_TRACKER_INTERFACE... Done"
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
if [ "$(pgrep -f 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

View file

@ -0,0 +1,61 @@
#
# Copyright (C) 2018-2023 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 save latencies and set additionnal latencies if set on interface
[ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ -z "$OMR_TRACKER_INTERFACE" ] && exit 0
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
[ "$interface_up" != "true" ] && exit 0
[ -n "$OMR_TRACKER_INTERFACE" ] && [ -n "$OMR_TRACKER_LATENCY" ] && {
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency)" != "" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency_previous="$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency)"
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
#[ -z "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max="$OMR_TRACKER_LATENCY"
#[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max)" -lt "$OMR_TRACKER_LATENCY" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max="$OMR_TRACKER_LATENCY"
if [ "$multipath_config" = "on" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath)" != "master" ] && ([ "$(uci -q get openmptcprouter.settings.master)" = "dynamic" ] || ( ( [ "$(uci -q get openmptcprouter.settings.master)" = "change" ] || [ "$(uci -q get openmptcprouter.settings.master)" = "" ] ) && [ "$(uci -q get openmptcprouter.settings.master_lcintf | grep $OMR_TRACKER_INTERFACE)" = "" ] ) ); then
masterintf="$(uci -q show openmptcprouter | grep -m 1 multipath=\'master\' | cut -d'.' -f2)"
[ -z "$masterintf" ] && masterintf="$(uci -q show network | grep -m 1 multipath=\'master\' | cut -d'.' -f2)"
masterlatency="$(uci -q get openmptcprouter.$masterintf.latency | tr -d '\n')"
if [ -z "$masterlatency" ] || ([ -n "$masterintf" ] && [ "$(uci -q get openmptcprouter.$masterintf.state)" = "down" ]); then
masterlatency=1000
fi
if [ -n "$masterintf" ] && ([ "$masterlatency" != "" ] || [ "$(uci -q get openmptcprouter.$masterintf.state)" = "down" ]); then
if ( ( [ "$(uci -q get openmptcprouter.settings.master)" = "change" ] || [ "$(uci -q get openmptcprouter.settings.master)" = "" ] ) && [ "$OMR_TRACKER_LATENCY" -lt $(awk "BEGIN {printf \"%i\",${masterlatency}/1.5}") ] ) || ( [ "$(uci -q get openmptcprouter.settings.master)" = "dynamic" ] && [ "$OMR_TRACKER_LATENCY" -lt "$((masterlatency/2))" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_previous)" -lt "$((masterlatency/2))" ] ); then
uci -q set network.$masterintf.multipath='on'
uci -q set openmptcprouter.$masterintf.multipath='on'
uci -q set network.$OMR_TRACKER_INTERFACE.multipath='master'
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.multipath='master'
if [ "$(uci -q get openmptcprouter.settings.master_lcintf | grep $OMR_TRACKER_INTERFACE)" = "" ]; then
uci -q add_list openmptcprouter.settings.master_lcintf="$OMR_TRACKER_INTERFACE"
fi
if [ "$(uci -q get openmptcprouter.settings.master)" = "" ]; then
uci -q set openmptcprouter.settings.master="change"
fi
if [ "$(uci -q get openmptcprouter.settings.master)" != "dynamic" ]; then
[ -n "$(uci -q changes network)" ] && uci -q commit network
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi
_log "Change master interface from $masterintf ($masterlatency ms) to $OMR_TRACKER_INTERFACE ($OMR_TRACKER_LATENCY ms)"
fi
fi
fi
}
if [ -n "$OMR_TRACKER_INTERFACE" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
addlatency=$(uci -q get network.${OMR_TRACKER_INTERFACE}.addlatency)
[ -z "$addlatency" ] && addlatency="0"
if [ "$addlatency" = "0" ] && [ "$(tc qdisc show dev $OMR_TRACKER_DEVICE | grep delay)" != "" ]; then
tc qdisc del dev ${OMR_TRACKER_DEVICE} root netem 2>&1 >/dev/null
fi
if [ "$addlatency" != "0" ]; then
if [ "$(tc qdisc show dev $OMR_TRACKER_DEVICE | grep delay)" = "" ]; then
tc qdisc add dev ${OMR_TRACKER_DEVICE} root netem delay ${addlatency}ms 2>&1 >/dev/null
elif [ "$(tc qdisc show dev $OMR_TRACKER_DEVICE | awk '/delay/ { print $10 }' | sed 's/ms//')" != "$addlatency" ]; then
tc qdisc replace dev ${OMR_TRACKER_DEVICE} root netem delay ${addlatency}ms 2>&1 >/dev/null
fi
fi
fi

View file

@ -0,0 +1,65 @@
#
# Copyright (C) 2018-2023 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 launch a speedtest if the option is enabled on the interface
[ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ -z "$OMR_TRACKER_INTERFACE" ] && exit 0
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
[ "$interface_up" != "true" ] && exit 0
if [ -n "$OMR_TRACKER_INTERFACE" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(pgrep -f omr-test-speed-server)" = "" ] && [ "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.testspeed)" = "1" ] && [ -z "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.testspeed_lc)" ]; then
launch_speedtest() {
local server=$1
[ "$(uci -q get openmptcprouter.${server}.current)" != "1" ] && return
download_speed=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest)
download_speed2=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest)
download_speed3=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest)
[ "$download_speed2" -gt "$download_speed" ] && download_speed=${download_speed2}
[ "$download_speed3" -gt "$download_speed" ] && download_speed=${download_speed3}
download_speed=$((download_speed*8/1000))
if [ -n "$download_speed" ] && [ "$download_speed" != "0" ]; then
upload_speed=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest upload)
upload_speed2=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest upload)
upload_speed3=$(/bin/omr-test-speed-server ${server} ${OMR_TRACKER_DEVICE} fasttest upload)
[ "$upload_speed2" -gt "$upload_speed" ] && upload_speed=${upload_speed2}
[ "$upload_speed3" -gt "$upload_speed" ] && upload_speed=${upload_speed3}
# Set Download speed settings
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ]; then
uci -q set sqm.${OMR_TRACKER_INTERFACE}.download=$((download_speed*65/100))
uci -q set sqm.${OMR_TRACKER_INTERFACE}.max_download=${download_speed}
uci -q set sqm.${OMR_TRACKER_INTERFACE}.min_download=$((download_speed*10/100))
else
uci -q set sqm.${OMR_TRACKER_INTERFACE}.download=$((download_speed*95/100))
fi
_log "Calculated ${OMR_TRACKER_INTERFACE} download speed: ${download_speed}"
uci -q set network.${OMR_TRACKER_INTERFACE}.downloadspeed=${download_speed}
# Set Upload speed settings
upload_speed=$((upload_speed*8/1000))
if [ -n "$upload_speed" ] && [ "$upload_speed" != "0" ]; then
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ]; then
uci -q set sqm.${OMR_TRACKER_INTERFACE}.upload=$((upload_speed*65/100))
uci -q set sqm.${OMR_TRACKER_INTERFACE}.max_upload=${upload_speed}
uci -q set sqm.${OMR_TRACKER_INTERFACE}.min_upload=$((upload_speed*10/100))
else
uci -q set sqm.${OMR_TRACKER_INTERFACE}.upload=$((upload_speed*95/100))
fi
_log "Calculated ${OMR_TRACKER_INTERFACE} upload speed: ${upload_speed}"
uci -q set network.${OMR_TRACKER_INTERFACE}.uploadspeed=${upload_speed}
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.testspeed_lc=$(date +"%s")
uci commit network
uci commit sqm
uci commit openmptcprouter
fi
fi
}
config_load openmptcprouter
config_foreach launch_speedtest server
sleep 5
fi

View file

@ -0,0 +1,95 @@
#
# Copyright (C) 2018-2023 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 set lights on RUTX device
if [ -n "$(grep RUTX /etc/board.json)" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ "$OMR_TRACKER_DEVICE" = "wwan0" ]; then
modemdata=$(omr-modemmanager '/sys/devices/platform/soc/60f8800.usb2/6000000.dwc3/xhci-hcd.1.auto/usb3/3-1' all)
gen=$(echo $modemdata | cut -d ';' -f 5 | tr -d '\n')
if [ "$gen" = "gsm" ]; then
echo "default-on" > /sys/class/leds/mob_gen_2/trigger
echo "none" > /sys/class/leds/mob_gen_3/trigger
echo "none" > /sys/class/leds/mob_gen_4/trigger
elif [ "$gen" = "umts" ]; then
echo "none" > /sys/class/leds/mob_gen_2/trigger
echo "default-on" > /sys/class/leds/mob_gen_3/trigger
echo "none" > /sys/class/leds/mob_gen_4/trigger
elif [ "$gen" = "lte" ]; then
echo "none" > /sys/class/leds/mob_gen_2/trigger
echo "none" > /sys/class/leds/mob_gen_3/trigger
echo "default-on" > /sys/class/leds/mob_gen_4/trigger
fi
bar=$(echo $modemdata | cut -d ';' -f 1 | tr -d '\n')
if [ "$bar" -gt "0" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_1/trigger
else
echo "none" > /sys/class/leds/mob_ssid_1/trigger
fi
if [ "$bar" -gt "30" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_2/trigger
else
echo "none" > /sys/class/leds/mob_ssid_2/trigger
fi
if [ "$bar" -gt "50" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_3/trigger
else
echo "none" > /sys/class/leds/mob_ssid_3/trigger
fi
if [ "$bar" -gt "70" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_4/trigger
else
echo "none" > /sys/class/leds/mob_ssid_4/trigger
fi
if [ "$bar" -gt "90" ]; then
echo "default-on" > /sys/class/leds/mob_ssid_5/trigger
else
echo "none" > /sys/class/leds/mob_ssid_5/trigger
fi
elif [ "$OMR_TRACKER_DEVICE" = "wwan1" ]; then
modemdata=$(omr-modemmanager '/sys/devices/platform/soc/8af8800.usb3/8a00000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1.2' all)
gen=$(echo $modemdata | cut -d ';' -f 5 | tr -d '\n')
if [ "$gen" = "gsm" ]; then
echo "default-on" > /sys/class/leds/mob2_gen_2/trigger
echo "none" > /sys/class/leds/mob2_gen_3/trigger
echo "none" > /sys/class/leds/mob2_gen_4/trigger
elif [ "$gen" = "umts" ]; then
echo "none" > /sys/class/leds/mob2_gen_2/trigger
echo "default-on" > /sys/class/leds/mob2_gen_3/trigger
echo "none" > /sys/class/leds/mob2_gen_4/trigger
elif [ "$gen" = "lte" ]; then
echo "none" > /sys/class/leds/mob2_gen_2/trigger
echo "none" > /sys/class/leds/mob2_gen_3/trigger
echo "default-on" > /sys/class/leds/mob2_gen_4/trigger
fi
bar=$(echo $modemdata | cut -d ';' -f 1 | tr -d '\n')
if [ "$bar" -gt "0" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_1/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_1/trigger
fi
if [ "$bar" -gt "30" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_2/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_2/trigger
fi
if [ "$bar" -gt "50" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_3/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_3/trigger
fi
if [ "$bar" -gt "70" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_4/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_4/trigger
fi
if [ "$bar" -gt "90" ]; then
echo "default-on" > /sys/class/leds/mob2_ssid_5/trigger
else
echo "none" > /sys/class/leds/mob2_ssid_5/trigger
fi
fi
fi

View file

@ -1,19 +1,19 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=netifd
PKG_RELEASE:=1
PKG_RELEASE:=3
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
PKG_SOURCE_DATE:=2021-07-26
PKG_SOURCE_VERSION:=440eb0647708274cc8d7d9e7c2bb0cfdfba90023
PKG_MIRROR_HASH:=eed957036ab608fdc49bdf801fc5b4405fcd2a3a5e5d3343ec39898e156c10e9
PKG_SOURCE_DATE:=2023-08-31
PKG_SOURCE_VERSION:=1a07f1dff32b3af49e39533e33e8964b59535662
PKG_MIRROR_HASH:=dc621dd04c3c9631002f929cf10a4620f57af8b0baf614c590bda17957fa6201
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=lto
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
@ -32,10 +32,7 @@ endef
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include/libnl-tiny \
-I$(STAGING_DIR)/usr/include \
-flto
TARGET_LDFLAGS += -flto -fuse-linker-plugin
-I$(STAGING_DIR)/usr/include
CMAKE_OPTIONS += \
-DLIBNL_LIBS=-lnl-tiny \

View file

@ -0,0 +1,18 @@
#!/bin/sh /etc/rc.common
START=25
USE_PROCD=1
start_service() {
reload_service
}
service_triggers() {
procd_add_reload_trigger "network"
procd_add_reload_trigger "firewall"
procd_add_raw_trigger "interface.*" 1000 /etc/init.d/packet_steering reload
}
reload_service() {
/usr/libexec/network/packet-steering.sh
}

View file

@ -61,6 +61,7 @@ setup_interface() {
[ -n "$message" ] && json_add_string message "$message"
[ -n "$timezone" ] && json_add_int timezone "$timezone"
[ -n "$lease" ] && json_add_int leasetime "$lease"
[ -n "$serverid" ] && json_add_string dhcpserver "$serverid"
proto_close_data
proto_send_update "$INTERFACE"

View file

@ -1,6 +1,6 @@
#!/bin/sh
[ -L /sbin/udhcpc ] || exit 0
[ -x /sbin/udhcpc ] || exit 0
. /lib/functions.sh
. ../netifd-proto.sh
@ -68,7 +68,7 @@ proto_dhcp_setup() {
-p /var/run/udhcpc-$iface.pid \
-s /lib/netifd/dhcp.script \
-f -t 0 -i "$iface" \
${ipaddr:+-r $ipaddr} \
${ipaddr:+-r ${ipaddr/\/*/}} \
${hostname:+-x "hostname:$hostname"} \
${vendorid:+-V "$vendorid"} \
$clientid $defaultreqopts $broadcast $norelease $dhcpopts

View file

@ -1,6 +1,4 @@
#!/bin/sh
[ "$ACTION" = add ] || exit
NPROCS="$(grep -c "^processor.*:" /proc/cpuinfo)"
[ "$NPROCS" -gt 1 ] || exit
@ -40,6 +38,11 @@ packet_steering="$(uci get "network.@globals[0].packet_steering")"
exec 512>/var/lock/smp_tune.lock
flock 512 || exit 1
[ -e "/usr/libexec/platform/packet-steering.sh" ] && {
/usr/libexec/platform/packet-steering.sh
exit 0
}
for dev in /sys/class/net/*; do
[ -d "$dev" ] || continue

View file

@ -0,0 +1,13 @@
--- a/system-linux.c 2023-09-13 10:44:22.163111635 +0200
+++ b/system-linux.c 2023-09-13 10:44:47.562696256 +0200
@@ -2720,7 +2720,9 @@
system_if_dump_info(struct device *dev, struct blob_buf *b)
{
__u32 *supported, *advertising, *lp_advertising;
- bool rx_pause, tx_pause, pause_autoneg;
+ bool rx_pause = false;
+ bool tx_pause = false;
+ bool pause_autoneg = false;
struct {
struct ethtool_link_settings req;
__u32 link_mode_data[3 * 127];

View file

@ -13,16 +13,16 @@ MP=false
if [ -n "$KEY" ] && [ -n "$HOST" ] && [ -n "$PORT" ]; then
trap : HUP INT TERM
[ -z "$FASTTEST" ] && echo "Disable SQM bandwidth limit on $INTERFACE"
[ -n "$(tc qdisc | grep $INTERFACE | grep bandwidth)" ] && {
export SQM_VERBOSITY_MIN=10
export SQM_VERBOSITY_MAX=0
export SQM_SYSLOG=1
/etc/init.d/sqm stop $INTERFACE 2>&1 >/dev/null
#tc qdisc delete dev $INTERFACE root 2>&1 >/dev/null
#tc qdisc delete dev ifb4$INTERFACE root 2>&1 >/dev/null
}
[ -z "$FASTTEST" ] && echo "Download test via server ${SERVER}:"
if [ -n "$INTERFACE" ]; then
[ -n "$(tc qdisc | grep $INTERFACE | grep bandwidth)" ] && {
export SQM_VERBOSITY_MIN=10
export SQM_VERBOSITY_MAX=0
export SQM_SYSLOG=1
/etc/init.d/sqm stop $INTERFACE 2>&1 >/dev/null
#tc qdisc delete dev $INTERFACE root 2>&1 >/dev/null
#tc qdisc delete dev ifb4$INTERFACE root 2>&1 >/dev/null
}
#if [ "$(multipath ${INTERFACE} | grep default)" ]; then
# MP=true
# /etc/init.d/omr-tracker stop 2>&1 >/dev/null
@ -47,9 +47,9 @@ if [ -n "$KEY" ] && [ -n "$HOST" ] && [ -n "$PORT" ]; then
# multipath ${INTERFACE} on
# /etc/init.d/omr-tracker start & 2>&1 >/dev/null
#fi
[ -z "$FASTTEST" ] && echo "Restart SQM on $INTERFACE"
/etc/init.d/sqm start $INTERFACE 2>&1 >/dev/null
else
curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo
fi
[ -z "$FASTTEST" ] && echo "Restart SQM on $INTERFACE"
/etc/init.d/sqm start $INTERFACE 2>&1 >/dev/null
fi

View file

@ -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

View file

@ -84,7 +84,6 @@ mptcp_over_vpn() {
set openvpn.${interface}.remote="${remoteip}"
set openvpn.${interface}.local="${localip}"
set openvpn.${interface}.lport='0'
set openvpn.${interface}.ncp_disable='1'
set openvpn.${interface}.auth_nocache='1'
set openvpn.${interface}.proto='udp'
set openvpn.${interface}.client='1'

View file

@ -1426,7 +1426,7 @@ _set_config_from_vps() {
if ([ -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+1))"
set v2ray.omrout.s_socks_port="$((v2ray_port+3))"
set v2ray.omrout.s_trojan_user_id="$v2ray_key"
set v2ray.omrout.s_trojan_port="$((v2ray_port+1))"
set v2ray.omrout.s_vmess_user_id="$v2ray_key"
@ -1770,6 +1770,7 @@ _backup_get() {
_backup_get_and_apply() {
servername=$1
backupfile=$2
token=""
vps_config=""
_login
@ -1780,7 +1781,12 @@ _backup_get_and_apply() {
EOF
return
}
vps_backup=$(_get_json "backupget")
if [ -n "$backupfile" ]; then
echo "get $backupfile"
vps_backup=$(_get_json "backupget?filename=${backupfile}")
else
vps_backup=$(_get_json "backupget")
fi
[ -z "$vps_backup" ] && return
backup_data="$(echo "$vps_backup" | jsonfilter -q -e '@.data')"
backup_sha256sum="$(echo "$vps_backup" | jsonfilter -q -e '@.sha256sum')"
@ -1791,11 +1797,16 @@ _backup_get_and_apply() {
}
backup_get() {
lastbackup=""
serverbackup=""
config_load openmptcprouter
config_foreach _backup_get server
[ -n "$serverbackup" ] && _backup_get_and_apply $serverbackup
backuptoapply=$2
if [ -n "$backuptoapply" ]; then
_backup_get_and_apply $1 $2
else
lastbackup=""
serverbackup=""
config_load openmptcprouter
config_foreach _backup_get server
[ -n "$serverbackup" ] && _backup_get_and_apply $serverbackup
fi
}
_backup_list() {
@ -1819,6 +1830,13 @@ _backup_list() {
backup_lastmodif="$(echo "$vps_backup" | jsonfilter -q -e '@.modif')"
[ -n "$backup_lastmodif" ] && {
uci -q set openmptcprouter.$servername.lastbackup=$backup_lastmodif
backup_all="$(echo "$vps_backup" | jsonfilter -q -e '@.sorted[*]')"
uci -q del openmptcprouter.$servername.allbackup
echo "$vps_backup" | jsonfilter -q -e '@.sorted[*]' | while read backup; do
name=$(echo "$backup" | jsonfilter -q -e '@[0]' | tr -d '\n')
modiftime=$(echo "$backup" | jsonfilter -q -e '@[1]' | tr -d '\n')
uci -q add_list openmptcprouter.$servername.allbackup="${name}|${modiftime}"
done
}
}

View file

@ -149,16 +149,16 @@ if [ "$(uci -q get network.tun0.mtu)" = "1200" ] || [ -z "$(uci -q get network.t
uci -q batch <<-EOF >/dev/null
set network.tun0=device
set network.tun0.name='tun0'
set network.tun0.mtu=9000
set network.tun0.mtu=1500
commit network
EOF
fi
if [ "$(uci -q get openmptcprouter.settings.vpn)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set openmptcprouter.settings.vpn='glorytun_udp'
set glorytun-udp.vpn.enable='1'
commit glorytun-udp
set openmptcprouter.settings.vpn='glorytun_tcp'
set glorytun.vpn.enable='1'
commit glorytun
commit openmptcprouter
EOF
fi

View file

@ -24,26 +24,22 @@ config OPENVPN_mbedtls_ENABLE_FRAGMENT
bool "Enable internal fragmentation support (--fragment)"
default y
config OPENVPN_mbedtls_ENABLE_MULTIHOME
bool "Enable multi-homed UDP server support (--multihome)"
default y
config OPENVPN_mbedtls_ENABLE_PORT_SHARE
bool "Enable TCP server port-share support (--port-share)"
default y
config OPENVPN_mbedtls_ENABLE_DEF_AUTH
bool "Enable deferred authentication"
default y
config OPENVPN_mbedtls_ENABLE_PF
bool "Enable internal packet filter"
default y
config OPENVPN_mbedtls_ENABLE_IPROUTE2
bool "Enable support for iproute2"
default n
config OPENVPN_mbedtls_ENABLE_DCO
depends on !OPENVPN_mbedtls_ENABLE_IPROUTE2
bool "Enable support for data channel offload"
default n if OPENVPN_mbedtls_ENABLE_IPROUTE2
help
enable data channel offload support
using the ovpn-dco-v2 kernel module
config OPENVPN_mbedtls_ENABLE_SMALL
bool "Enable size optimization"
default y

View file

@ -28,26 +28,22 @@ config OPENVPN_openssl_ENABLE_FRAGMENT
bool "Enable internal fragmentation support (--fragment)"
default y
config OPENVPN_openssl_ENABLE_MULTIHOME
bool "Enable multi-homed UDP server support (--multihome)"
default y
config OPENVPN_openssl_ENABLE_PORT_SHARE
bool "Enable TCP server port-share support (--port-share)"
default y
config OPENVPN_openssl_ENABLE_DEF_AUTH
bool "Enable deferred authentication"
default y
config OPENVPN_openssl_ENABLE_PF
bool "Enable internal packet filter"
default y
config OPENVPN_openssl_ENABLE_IPROUTE2
bool "Enable support for iproute2"
default n
config OPENVPN_openssl_ENABLE_DCO
depends on !OPENVPN_openssl_ENABLE_IPROUTE2
bool "Enable support for data channel offload"
default n if OPENVPN_openssl_ENABLE_IPROUTE2
help
enable data channel offload support
using the ovpn-dco-v2 kernel module
config OPENVPN_openssl_ENABLE_SMALL
bool "Enable size optimization"
default y

View file

@ -33,26 +33,22 @@ config OPENVPN_wolfssl_ENABLE_FRAGMENT
bool "Enable internal fragmentation support (--fragment)"
default y
config OPENVPN_wolfssl_ENABLE_MULTIHOME
bool "Enable multi-homed UDP server support (--multihome)"
default y
config OPENVPN_wolfssl_ENABLE_PORT_SHARE
bool "Enable TCP server port-share support (--port-share)"
default y
config OPENVPN_wolfssl_ENABLE_DEF_AUTH
bool "Enable deferred authentication"
default y
config OPENVPN_wolfssl_ENABLE_PF
bool "Enable internal packet filter"
default y
config OPENVPN_wolfssl_ENABLE_IPROUTE2
bool "Enable support for iproute2"
default n
config OPENVPN_wolfssl_ENABLE_DCO
depends on !OPENVPN_wolfssl_ENABLE_IPROUTE2
bool "Enable support for data channel offload"
default n if OPENVPN_openssl_ENABLE_IPROUTE2
help
enable data channel offload support
using the ovpn-dco-v2 kernel module
config OPENVPN_wolfssl_ENABLE_SMALL
bool "Enable size optimization"
default y

View file

@ -9,14 +9,14 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=openvpn
PKG_VERSION:=2.5.8
PKG_RELEASE:=3
PKG_VERSION:=2.6.5
PKG_RELEASE:=1
PKG_SOURCE_URL:=\
https://build.openvpn.net/downloads/releases/ \
https://swupdate.openvpn.net/community/releases/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_HASH:=2bbd0026469902037ee6499b68283d5ab36c74e36cae3112082cfdf6c77a0c57
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=e34efdb9a3789a760cfc91d57349dfb1e31da169c98c06cb490c6a8a015638e2
PKG_MAINTAINER:=Magnus Kroken <mkroken@gmail.com>
@ -36,14 +36,14 @@ define Package/openvpn/Default
URL:=http://openvpn.net
SUBMENU:=VPN
MENU:=1
DEPENDS:=+kmod-tun +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_IPROUTE2:ip $(3)
DEPENDS:=+kmod-tun +libcap-ng +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_LZ4:liblz4 +OPENVPN_$(1)_ENABLE_IPROUTE2:ip +OPENVPN_$(1)_ENABLE_DCO:libnl-genl $(3)
VARIANT:=$(1)
PROVIDES:=openvpn openvpn-crypto
endef
Package/openvpn-openssl=$(call Package/openvpn/Default,openssl,OpenSSL,+PACKAGE_openvpn-openssl:libopenssl)
Package/openvpn-mbedtls=$(call Package/openvpn/Default,mbedtls,mbedTLS,+PACKAGE_openvpn-mbedtls:libmbedtls)
Package/openvpn-wolfssl=$(call Package/openvpn/Default,wolfssl,WolfSSL \(experimental\),+PACKAGE_openvpn-wolfssl:libwolfssl)
Package/openvpn-wolfssl=$(call Package/openvpn/Default,wolfssl,WolfSSL,+PACKAGE_openvpn-wolfssl:libwolfssl)
define Package/openvpn/config/Default
source "$(SOURCE)/Config-$(1).in"
@ -80,11 +80,9 @@ define Build/Configure
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_X509_ALT_USERNAME),--enable,--disable)-x509-alt-username \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MANAGEMENT),--enable,--disable)-management \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_FRAGMENT),--enable,--disable)-fragment \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MULTIHOME),--enable,--disable)-multihome \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_IPROUTE2),--enable,--disable)-iproute2 \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DEF_AUTH),--enable,--disable)-def-auth \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PF),--enable,--disable)-pf \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PORT_SHARE),--enable,--disable)-port-share \
$(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DCO),--enable,--disable)-dco \
$(if $(CONFIG_OPENVPN_OPENSSL),--with-crypto-library=openssl --with-openssl-engine=no) \
$(if $(CONFIG_OPENVPN_MBEDTLS),--with-crypto-library=mbedtls) \
$(if $(CONFIG_OPENVPN_WOLFSSL),--with-crypto-library=wolfssl) \

View file

@ -54,7 +54,6 @@ iroute_ipv6
keepalive
key
key_direction
keysize
learn_address
link_mtu
lladdr

View file

@ -1,10 +0,0 @@
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -105,7 +105,6 @@ const char title_string[] =
#endif
#endif
" [AEAD]"
- " built on " __DATE__
;
#ifndef ENABLE_SMALL

View file

@ -1,190 +0,0 @@
From: Gert Doering <gert@greenie.muc.de>
Support for wolfSSL in OpenVPN
This patch adds support for wolfSSL in OpenVPN. Support is added by using
wolfSSL's OpenSSL compatibility layer. Function calls are left unchanged
and instead the OpenSSL includes point to wolfSSL headers and OpenVPN is
linked against the wolfSSL library. The wolfSSL installation directory is
detected using pkg-config.
As requested by OpenVPN maintainers, this patch does not include
wolfssl/options.h on its own. By defining the macro EXTERNAL_OPTS_OPENVPN
in the configure script wolfSSL will include wolfssl/options.h on its own
(change added in wolfSSL/wolfssl#2825). The patch
adds an option '--disable-wolfssl-options-h' in case the user would like
to supply their own settings file for wolfSSL.
wolfSSL:
Support added in: wolfSSL/wolfssl#2503
git clone https://github.com/wolfSSL/wolfssl.git
cd wolfssl
./autogen.sh
./configure --enable-openvpn
make
sudo make install
OpenVPN:
autoreconf -i -v -f
./configure --with-crypto-library=wolfssl
make
make check
sudo make install
Signed-off-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210317181153.83716-1-juliusz@wolfssl.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21686.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
configure.ac | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/openvpn/syshead.h | 3 ++-
2 files changed, 110 insertions(+), 3 deletions(-)
--- a/configure.ac
+++ b/configure.ac
@@ -271,16 +271,23 @@ AC_ARG_WITH(
AC_ARG_WITH(
[crypto-library],
- [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|mbedtls @<:@default=openssl@:>@])],
+ [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|mbedtls|wolfssl @<:@default=openssl@:>@])],
[
case "${withval}" in
- openssl|mbedtls) ;;
+ openssl|mbedtls|wolfssl) ;;
*) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;;
esac
],
[with_crypto_library="openssl"]
)
+AC_ARG_ENABLE(
+ [wolfssl-options-h],
+ [AS_HELP_STRING([--disable-wolfssl-options-h], [Disable including options.h in wolfSSL @<:@default=yes@:>@])],
+ ,
+ [enable_wolfssl_options_h="yes"]
+)
+
AC_ARG_WITH(
[openssl-engine],
[AS_HELP_STRING([--with-openssl-engine], [enable engine support with OpenSSL. Default enabled for OpenSSL < 3.0, auto,yes,no @<:@default=auto@:>@])],
@@ -1054,6 +1061,105 @@ elif test "${with_crypto_library}" = "mb
AC_DEFINE([ENABLE_CRYPTO_MBEDTLS], [1], [Use mbed TLS library])
CRYPTO_CFLAGS="${MBEDTLS_CFLAGS}"
CRYPTO_LIBS="${MBEDTLS_LIBS}"
+
+elif test "${with_crypto_library}" = "wolfssl"; then
+ AC_ARG_VAR([WOLFSSL_CFLAGS], [C compiler flags for wolfssl. The include directory should
+ contain the regular wolfSSL header files but also the
+ wolfSSL OpenSSL header files. Ex: -I/usr/local/include
+ -I/usr/local/include/wolfssl])
+ AC_ARG_VAR([WOLFSSL_LIBS], [linker flags for wolfssl])
+
+ saved_CFLAGS="${CFLAGS}"
+ saved_LIBS="${LIBS}"
+
+ if test -z "${WOLFSSL_CFLAGS}" -a -z "${WOLFSSL_LIBS}"; then
+ # if the user did not explicitly specify flags, try to autodetect
+ PKG_CHECK_MODULES(
+ [WOLFSSL],
+ [wolfssl],
+ [],
+ [AC_MSG_ERROR([Could not find wolfSSL.])]
+ )
+ PKG_CHECK_VAR(
+ [WOLFSSL_INCLUDEDIR],
+ [wolfssl],
+ [includedir],
+ [],
+ [AC_MSG_ERROR([Could not find wolfSSL includedir variable.])]
+ )
+ WOLFSSL_CFLAGS="${WOLFSSL_CFLAGS} -I${WOLFSSL_INCLUDEDIR}/wolfssl"
+ fi
+ saved_CFLAGS="${CFLAGS}"
+ saved_LIBS="${LIBS}"
+ CFLAGS="${CFLAGS} ${WOLFSSL_CFLAGS}"
+ LIBS="${LIBS} ${WOLFSSL_LIBS}"
+
+ AC_CHECK_LIB(
+ [wolfssl],
+ [wolfSSL_Init],
+ [],
+ [AC_MSG_ERROR([Could not link wolfSSL library.])]
+ )
+ AC_CHECK_HEADER([wolfssl/options.h],,[AC_MSG_ERROR([wolfSSL header wolfssl/options.h not found!])])
+
+ # wolfSSL signal EKM support
+ have_export_keying_material="yes"
+
+ AC_DEFINE([HAVE_HMAC_CTX_NEW], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_HMAC_CTX_FREE], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_HMAC_CTX_RESET], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_MD_CTX_NEW], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_MD_CTX_FREE], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_MD_CTX_RESET], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_CIPHER_CTX_RESET], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_OPENSSL_VERSION], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_SSL_CTX_GET_DEFAULT_PASSWD_CB], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_SSL_CTX_GET_DEFAULT_PASSWD_CB_USERDATA], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_SSL_CTX_SET_SECURITY_LEVEL], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_X509_GET0_NOTBEFORE], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_X509_GET0_NOTAFTER], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_X509_GET0_PUBKEY], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_X509_STORE_GET0_OBJECTS], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_X509_OBJECT_FREE], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_X509_OBJECT_GET_TYPE], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_PKEY_ID], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_PKEY_GET0_RSA], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_PKEY_GET0_DSA], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EVP_PKEY_GET0_EC_KEY], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_SET_FLAGS], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_BITS], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_GET0_KEY], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_SET0_KEY], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_DSA_GET0_PQG], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_DSA_BITS], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_NEW], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_FREE], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET_PUB_ENC], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET_PUB_DEC], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET_PRIV_ENC], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET_PRIV_DEC], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET_INIT], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET_SIGN], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET_FINISH], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_SET0_APP_DATA], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_RSA_METH_GET0_APP_DATA], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+ AC_DEFINE([HAVE_EC_GROUP_ORDER_BITS], [1], [Emulate AC_CHECK_FUNCS since these are defined as macros])
+
+ if test "${enable_wolfssl_options_h}" = "yes"; then
+ AC_DEFINE([EXTERNAL_OPTS_OPENVPN], [1], [Include options.h from wolfSSL library])
+ else
+ AC_DEFINE([WOLFSSL_USER_SETTINGS], [1], [Use custom user_settings.h file for wolfSSL library])
+ fi
+
+ have_export_keying_material="yes"
+
+ CFLAGS="${saved_CFLAGS}"
+ LIBS="${saved_LIBS}"
+
+ AC_DEFINE([ENABLE_CRYPTO_WOLFSSL], [1], [Use wolfSSL crypto library])
+ AC_DEFINE([ENABLE_CRYPTO_OPENSSL], [1], [Use wolfSSL openssl compatibility layer])
+ CRYPTO_CFLAGS="${WOLFSSL_CFLAGS}"
+ CRYPTO_LIBS="${WOLFSSL_LIBS}"
else
AC_MSG_ERROR([Invalid crypto library: ${with_crypto_library}])
fi
--- a/src/openvpn/syshead.h
+++ b/src/openvpn/syshead.h
@@ -582,7 +582,8 @@ socket_defined(const socket_descriptor_t
/*
* Do we have CryptoAPI capability?
*/
-#if defined(_WIN32) && defined(ENABLE_CRYPTO_OPENSSL)
+#if defined(_WIN32) && defined(ENABLE_CRYPTO_OPENSSL) && \
+ !defined(ENABLE_CRYPTO_WOLFSSL)
#define ENABLE_CRYPTOAPI
#endif

View file

@ -1,6 +1,6 @@
--- a/src/openvpn/ssl_mbedtls.c
+++ b/src/openvpn/ssl_mbedtls.c
@@ -1539,7 +1539,7 @@ const char *
@@ -1535,7 +1535,7 @@ const char *
get_ssl_library_version(void)
{
static char mbedtls_version[30];

View file

@ -0,0 +1,20 @@
--- a/src/openvpn/crypto_openssl.c
+++ b/src/openvpn/crypto_openssl.c
@@ -51,7 +51,7 @@
#include <openssl/rand.h>
#include <openssl/ssl.h>
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(ENABLE_CRYPTO_WOLFSSL) && !defined(LIBRESSL_VERSION_NUMBER)
#include <openssl/kdf.h>
#endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -1419,7 +1419,7 @@ engine_load_key(const char *file, SSL_CT
#endif /* if HAVE_OPENSSL_ENGINE */
}
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(ENABLE_CRYPTO_WOLFSSL) && !defined(LIBRESSL_VERSION_NUMBER)
bool
ssl_tls1_PRF(const uint8_t *seed, int seed_len, const uint8_t *secret,
int secret_len, uint8_t *output, int output_len)

View file

@ -0,0 +1,20 @@
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -1351,7 +1351,7 @@ err:
return 0;
}
-#if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_EC)
+#if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_EC) && !defined(ENABLE_CRYPTO_WOLFSSL)
/* called when EC_KEY is destroyed */
static void
@@ -1512,7 +1512,7 @@ tls_ctx_use_management_external_key(stru
goto cleanup;
}
}
-#if (OPENSSL_VERSION_NUMBER > 0x10100000L) && !defined(OPENSSL_NO_EC)
+#if (OPENSSL_VERSION_NUMBER > 0x10100000L) && !defined(OPENSSL_NO_EC) && !defined(ENABLE_CRYPTO_WOLFSSL)
#if OPENSSL_VERSION_NUMBER < 0x30000000L
else if (EVP_PKEY_id(pkey) == EVP_PKEY_EC)
#else /* OPENSSL_VERSION_NUMBER < 0x30000000L */

View file

@ -0,0 +1,12 @@
--- a/src/openvpn/ssl_verify_openssl.c
+++ b/src/openvpn/ssl_verify_openssl.c
@@ -269,6 +269,9 @@ backend_x509_get_username(char *common_n
return FAILURE;
}
}
+#if defined(ENABLE_CRYPTO_WOLFSSL)
+ #define LN_serialNumber "serialNumber"
+#endif
else if (strcmp(LN_serialNumber, x509_username_field) == 0)
{
ASN1_INTEGER *asn1_i = X509_get_serialNumber(peer_cert);

View file

@ -1,74 +0,0 @@
--- a/configure.ac
+++ b/configure.ac
@@ -1211,68 +1211,15 @@ dnl
AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4])
AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4])
if test "$enable_lz4" = "yes" && test "$enable_comp_stub" = "no"; then
- if test -z "${LZ4_CFLAGS}" -a -z "${LZ4_LIBS}"; then
- # if the user did not explicitly specify flags, try to autodetect
- PKG_CHECK_MODULES([LZ4],
- [liblz4 >= 1.7.1 liblz4 < 100],
- [have_lz4="yes"],
- [LZ4_LIBS="-llz4"] # If this fails, we will do another test next.
- # We also add set LZ4_LIBS otherwise the
- # linker will not know about the lz4 library
- )
- fi
saved_CFLAGS="${CFLAGS}"
saved_LIBS="${LIBS}"
CFLAGS="${CFLAGS} ${LZ4_CFLAGS}"
LIBS="${LIBS} ${LZ4_LIBS}"
- # If pkgconfig check failed or LZ4_CFLAGS/LZ4_LIBS env vars
- # are used, check the version directly in the LZ4 include file
- if test "${have_lz4}" != "yes"; then
- AC_CHECK_HEADERS([lz4.h],
- [have_lz4h="yes"],
- [])
-
- if test "${have_lz4h}" = "yes" ; then
- AC_MSG_CHECKING([additionally if system LZ4 version >= 1.7.1])
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[
-#include <lz4.h>
- ]],
- [[
-/* Version encoding: MMNNPP (Major miNor Patch) - see lz4.h for details */
-#if LZ4_VERSION_NUMBER < 10701L
-#error LZ4 is too old
-#endif
- ]]
- )],
- [
- AC_MSG_RESULT([ok])
- have_lz4="yes"
- ],
- [AC_MSG_RESULT([system LZ4 library is too old])]
- )
- fi
- fi
-
- # Double check we have a few needed functions
- if test "${have_lz4}" = "yes" ; then
- AC_CHECK_LIB([lz4],
- [LZ4_compress_default],
- [],
- [have_lz4="no"])
- AC_CHECK_LIB([lz4],
- [LZ4_decompress_safe],
- [],
- [have_lz4="no"])
- fi
-
- if test "${have_lz4}" != "yes" ; then
- AC_MSG_RESULT([ usable LZ4 library or header not found, using version in src/compat/compat-lz4.*])
- AC_DEFINE([NEED_COMPAT_LZ4], [1], [use copy of LZ4 source in compat/])
- LZ4_LIBS=""
- fi
+ AC_MSG_RESULT([ usable LZ4 library or header not found, using version in src/compat/compat-lz4.*])
+ AC_DEFINE([NEED_COMPAT_LZ4], [1], [use copy of LZ4 source in compat/])
+ LZ4_LIBS=""
OPTIONAL_LZ4_CFLAGS="${LZ4_CFLAGS}"
OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
AC_DEFINE(ENABLE_LZ4, [1], [Enable LZ4 compression library])

View file

@ -1,74 +0,0 @@
--- a/src/openvpn/syshead.h
+++ b/src/openvpn/syshead.h
@@ -572,7 +572,7 @@ socket_defined(const socket_descriptor_t
/*
* Should we include NTLM proxy functionality
*/
-#define NTLM 1
+//#define NTLM 1
/*
* Should we include proxy digest auth functionality
--- a/src/openvpn/crypto_mbedtls.c
+++ b/src/openvpn/crypto_mbedtls.c
@@ -396,6 +396,7 @@ int
key_des_num_cblocks(const mbedtls_cipher_info_t *kt)
{
int ret = 0;
+#ifdef MBEDTLS_DES_C
if (kt->type == MBEDTLS_CIPHER_DES_CBC)
{
ret = 1;
@@ -408,6 +409,7 @@ key_des_num_cblocks(const mbedtls_cipher
{
ret = 3;
}
+#endif
dmsg(D_CRYPTO_DEBUG, "CRYPTO INFO: n_DES_cblocks=%d", ret);
return ret;
@@ -416,6 +418,7 @@ key_des_num_cblocks(const mbedtls_cipher
bool
key_des_check(uint8_t *key, int key_len, int ndc)
{
+#ifdef MBEDTLS_DES_C
int i;
struct buffer b;
@@ -444,11 +447,15 @@ key_des_check(uint8_t *key, int key_len,
err:
return false;
+#else
+ return true;
+#endif
}
void
key_des_fixup(uint8_t *key, int key_len, int ndc)
{
+#ifdef MBEDTLS_DES_C
int i;
struct buffer b;
@@ -463,6 +470,7 @@ key_des_fixup(uint8_t *key, int key_len,
}
mbedtls_des_key_set_parity(key);
}
+#endif
}
/*
@@ -783,10 +791,12 @@ cipher_des_encrypt_ecb(const unsigned ch
unsigned char *src,
unsigned char *dst)
{
+#ifdef MBEDTLS_DES_C
mbedtls_des_context ctx;
ASSERT(mbed_ok(mbedtls_des_setkey_enc(&ctx, key)));
ASSERT(mbed_ok(mbedtls_des_crypt_ecb(&ctx, src, dst)));
+#endif
}

View file

@ -1,8 +1,8 @@
diff --git a/configure.ac b/configure.ac
index 2f5f6bc7..d15c0910 100644
index 16c40bb5..04609ebf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -293,6 +293,12 @@ AC_ARG_WITH(
@@ -314,6 +314,12 @@ AC_ARG_WITH(
[with_openssl_engine="auto"]
)
@ -15,9 +15,9 @@ index 2f5f6bc7..d15c0910 100644
AC_ARG_VAR([PLUGINDIR], [Path of plug-in directory @<:@default=LIBDIR/openvpn/plugins@:>@])
if test -n "${PLUGINDIR}"; then
plugindir="${PLUGINDIR}"
@@ -846,6 +852,22 @@ PKG_CHECK_MODULES(
[]
)
@@ -879,6 +885,22 @@ case "$host" in
esac
+dnl
+dnl Checking Multipath TCP support on Linux
@ -39,50 +39,47 @@ index 2f5f6bc7..d15c0910 100644
AC_ARG_VAR([OPENSSL_CFLAGS], [C compiler flags for OpenSSL])
AC_ARG_VAR([OPENSSL_LIBS], [linker flags for OpenSSL])
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index be8ff80f..b4fe11e2 100644
index d358ad00..6e5b2d3b 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -3449,6 +3449,9 @@ do_init_socket_1(struct context *c, const int mode)
c->c1.socks_proxy,
@@ -3359,7 +3359,6 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
#ifdef ENABLE_DEBUG
c->options.gremlin,
+#endif
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+ c->options.enable_mptcp,
to.gremlin = c->options.gremlin;
#endif
c->options.ce.bind_local,
c->options.ce.remote_float,
-
to.plugins = c->plugins;
#ifdef ENABLE_MANAGEMENT
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 20d1273f..3222fda6 100644
index 2c51efa6..dac82a68 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -130,6 +130,9 @@ static const char usage_message[] =
@@ -137,6 +137,9 @@ static const char usage_message[] =
" udp6, tcp6-server, tcp6-client\n"
"--proto-force p : only consider protocol p in list of connection profiles.\n"
" p = udp or tcp\n"
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+ "--mptcp : Enable Multipath TCP on the TCP connections.\n"
+#endif
"--connect-retry n [m] : For client, number of seconds to wait between\n"
" connection retries (default=%d). On repeated retries\n"
" the wait time is exponentially increased to a maximum of m\n"
@@ -903,6 +906,11 @@ init_options(struct options *o, const bool init_gc)
@@ -908,7 +911,9 @@ init_options(struct options *o, const bool init_gc)
}
#endif /* _WIN32 */
o->allow_recursive_routing = false;
+
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
-
+#if defined(ENABLE_MPTCP)
+ o->enable_mptcp = false;
+#endif
+
}
void
@@ -8834,6 +8842,18 @@ add_option(struct options *options,
#ifndef ENABLE_DCO
o->tuntap_options.disable_dco = true;
#endif /* ENABLE_DCO */
@@ -9475,6 +9480,18 @@ add_option(struct options *options,
goto err;
}
}
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+ else if (streq(p[0], "mptcp"))
+ {
+ VERIFY_PERMISSION(OPT_P_GENERAL);
@ -98,10 +95,10 @@ index 20d1273f..3222fda6 100644
{
int i;
diff --git a/src/openvpn/options.h b/src/openvpn/options.h
index 37220904..465eff52 100644
index f5890b90..765ce90e 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/options.h
@@ -430,6 +430,9 @@ struct options
@@ -461,6 +461,9 @@ struct options
#define SF_NO_PUSH_ROUTE_GATEWAY (1<<2)
unsigned int server_flags;
@ -112,7 +109,7 @@ index 37220904..465eff52 100644
bool server_bridge_defined;
diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c
index e79cb0d3..754cdfc5 100644
index 3609630a..c5f364ff 100644
--- a/src/openvpn/ps.c
+++ b/src/openvpn/ps.c
@@ -39,6 +39,14 @@
@ -120,7 +117,7 @@ index e79cb0d3..754cdfc5 100644
#include "memdbg.h"
+
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+#ifndef IPPROTO_MPTCP
+#define IPPROTO_MPTCP 262
+#endif
@ -134,7 +131,7 @@ index e79cb0d3..754cdfc5 100644
struct proxy_connection *cp;
/* connect to port share server */
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+ if ((sd_server = socket(PF_INET, SOCK_STREAM, IPPROTO_MPTCP)) < 0)
+#else
if ((sd_server = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
@ -143,27 +140,27 @@ index e79cb0d3..754cdfc5 100644
msg(M_WARN|M_ERRNO, "PORT SHARE PROXY: cannot create socket");
return false;
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 28fabe76..e7242020 100644
index fc643c1c..fba2cdc5 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -55,6 +55,12 @@ const int proto_overhead[] = { /* indexed by PROTO_x */
IPv6_TCP_HEADER_SIZE,
};
@@ -61,6 +61,12 @@ sf2gaf(const unsigned int getaddr_flags,
}
}
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+#ifndef IPPROTO_MPTCP
+#define IPPROTO_MPTCP 262
+#endif
+#endif
+
/*
* Convert sockflags/getaddr_flags into getaddr_flags
* Functions related to the translation of DNS names to IP addresses.
*/
@@ -1093,6 +1099,39 @@ create_socket_udp(struct addrinfo *addrinfo, const unsigned int flags)
@@ -1085,6 +1091,39 @@ create_socket_udp(struct addrinfo *addrinfo, const unsigned int flags)
return sd;
}
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+socket_descriptor_t
+create_socket_mptcp(struct addrinfo *addrinfo)
+{
@ -199,11 +196,11 @@ index 28fabe76..e7242020 100644
static void
bind_local(struct link_socket *sock, const sa_family_t ai_family)
{
@@ -1136,6 +1175,21 @@ create_socket(struct link_socket *sock, struct addrinfo *addr)
@@ -1128,6 +1167,21 @@ create_socket(struct link_socket *sock, struct addrinfo *addr)
}
else if (addr->ai_protocol == IPPROTO_TCP || addr->ai_socktype == SOCK_STREAM)
{
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+ if(sock->info.multipath)
+ {
+ sock->sd = create_socket_mptcp(addr);
@ -221,63 +218,51 @@ index 28fabe76..e7242020 100644
sock->sd = create_socket_tcp(addr);
}
else
@@ -1891,6 +1945,9 @@ link_socket_init_phase1(struct link_socket *sock,
struct socks_proxy_info *socks_proxy,
@@ -1858,7 +1912,9 @@ link_socket_init_phase1(struct context *c, int mode)
#ifdef ENABLE_DEBUG
int gremlin,
+#endif
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+ bool enable_mptcp,
sock->gremlin = o->gremlin;
#endif
bool bind_local,
bool remote_float,
@@ -1920,7 +1977,11 @@ link_socket_init_phase1(struct link_socket *sock,
sock->inetd = inetd;
sock->resolve_retry_seconds = resolve_retry_seconds;
sock->mtu_discover_type = mtu_discover_type;
-
+
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+ sock->info.multipath = enable_mptcp;
+#if defined(ENABLE_MPTCP)
+ sock->info.multipath = o->enable_mptcp;
+#endif
+
#ifdef ENABLE_DEBUG
sock->gremlin = gremlin;
sock->socket_buffer_sizes.rcvbuf = o->rcvbuf;
sock->socket_buffer_sizes.sndbuf = o->sndbuf;
@@ -2213,7 +2269,7 @@ link_socket_init_phase2(struct context *c)
else
#endif
@@ -2305,7 +2366,7 @@ link_socket_init_phase2(struct link_socket *sock,
/* If a valid remote has been found, create the socket with its addrinfo */
if (sock->info.lsa->current_remote)
{
- create_socket(sock, sock->info.lsa->current_remote);
+ create_socket(sock, sock->info.lsa->current_remote);
}
/* If socket has not already been created create it now */
}
diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h
index 2ad6155f..0dcb0655 100644
index bfc1253b..7009daf0 100644
--- a/src/openvpn/socket.h
+++ b/src/openvpn/socket.h
@@ -120,6 +120,9 @@ struct link_socket_info
@@ -121,6 +121,9 @@ struct link_socket_info
sa_family_t af; /* Address family like AF_INET, AF_INET6 or AF_UNSPEC*/
bool bind_ipv6_only;
int mtu_changed; /* Set to true when mtu value is changed */
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+#if defined(ENABLE_MPTCP)
+ bool multipath;
+#endif
};
/*
@@ -315,6 +318,9 @@ link_socket_init_phase1(struct link_socket *sock,
struct socks_proxy_info *socks_proxy,
@@ -244,6 +247,9 @@ struct link_socket
#ifdef ENABLE_DEBUG
int gremlin,
+#endif
+#if defined(TARGET_LINUX) && defined(ENABLE_MPTCP)
+ bool enable_mptcp,
int gremlin; /* --gremlin bits */
#endif
bool bind_local,
bool remote_float,
@@ -476,6 +482,10 @@ bool ipv6_addr_safe(const char *ipv6_text_addr);
+#if defined(ENABLE_MPTCP)
+ bool enable_mptcp;
+#endif
};
/*
@@ -469,6 +475,10 @@ bool ipv6_addr_safe(const char *ipv6_text_addr);
socket_descriptor_t create_socket_tcp(struct addrinfo *);

View file

@ -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

View file

@ -446,11 +446,11 @@ add_v2ray_redirect_rules() {
# This part need a rewrite
v2ray-rules -f
logger -t "v2ray" "v2ray-rules -l ${port} -L ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward"
#logger -t "v2ray" "v2ray-rules -l ${port} -L ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward"
commandline="-l ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward"
[ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && ([ "$(uci -q get v2ray.omrout.protocol)" = "vless" ] || [ "$(uci -q get v2ray.omrout.protocol)" = "vmess" ]) && commandline="$commandline -L ${port}"
[ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "socks" ] && commandline="$commandline -L ${port}"
v2ray-rules $commandline
[ "$(uci -q get v2ray.main.inbounds | grep omr6)" != "" ] && {
[ "$(uci -q get v2ray.main.inbounds | grep omr6)" != "" ] && [ -n "$OUTBOUND_SERVERS_V6" ] && {
v2ray-rules6 -f
commandline="-l $((port+1)) -L $((port+1)) -s $OUTBOUND_SERVERS_V6 --rule-name def --src-default forward --dst-default forward --local-default forward"
[ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && ([ "$(uci -q get v2ray.omrout.protocol)" = "vless" ] || [ "$(uci -q get v2ray.omrout.protocol)" = "vmess" ]) && commandline="$commandline -L ${port+1}"
@ -1885,7 +1885,7 @@ init_transparent_proxy() {
TRANSPARENT_PROXY_PORT="$redirect_port"
TRANSPARENT_PROXY_USE_TPROXY="$use_tproxy"
if [ "x$redirect_udp" = "x1" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "trojan" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "socks" ]; then
if [ "x$redirect_udp" = "x1" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "socks" ]; then
TRANSPARENT_PROXY_ADDITION="udp"
elif [ "x$redirect_dns" = "x1" ] ; then
TRANSPARENT_PROXY_ADDITION="dns"

View file

@ -6,7 +6,7 @@ if [ -z "$(uci -q get v2ray.main)" ]; then
set v2ray.main=v2ray
set v2ray.main.v2ray_file='/usr/bin/v2ray'
set v2ray.main.mem_percentage='0'
set v2ray.main.loglevel='debug'
set v2ray.main.loglevel='error'
set v2ray.main.access_log='/dev/null'
set v2ray.main.error_log='/dev/null'
set v2ray.main.enabled='0'
@ -30,7 +30,7 @@ if [ -z "$(uci -q get v2ray.main)" ]; then
set v2ray.main_transparent_proxy.proxy_mode='default'
set v2ray.main_transparent_proxy.apnic_delegated_mirror='apnic'
set v2ray.main_transparent_proxy.gfwlist_mirror='github'
set v2ray.main_transparent_proxy.redirect_udp='1'
set v2ray.main_transparent_proxy.redirect_udp='0'
set v2ray.main_transparent_proxy.redirect_port='1897'
set v2ray.omrout=outbound
set v2ray.omrout.tag='omrout_tunnel'
@ -197,5 +197,4 @@ if [ "$(uci -q get v2ray.omrout.s_socks_port)" = "" ]; then
EOF
fi
fi
exit 0

View file

@ -52,7 +52,7 @@ Usage: v2ray-rules6 [options]
--local-default <bypass|forward|checkdst>
Default action for local out TCP traffic
The following ipsets will be created by ss-rules. They are also intended to be
The following ipsets will be created by v2ray-rules. They are also intended to be
populated by other programs like dnsmasq with ipset support
v2ray_rules6_src_bypass
@ -73,7 +73,7 @@ o_dst_default=bypass
o_local_default=bypass
__errmsg() {
echo "ss-rules6: $*" >&2
echo "v2ray-rules6: $*" >&2
}
v2ray_rules6_parse_args() {

View file

@ -2444,7 +2444,7 @@ index 729899015..41f70be7b 100644
+ if x != nil {
+ return x.Mptcp
+ }
+ return false
+ return true
+}
+
var File_transport_internet_config_proto protoreflect.FileDescriptor
@ -2921,3 +2921,47 @@ index 5b03acb7e..ff62bc2fa 100644
}
var (
From c9306fdb1886424f186680acbc5f889319f2dadd Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 3 Aug 2023 17:09:55 +0800
Subject: [PATCH] fix mptcp dial
---
transport/internet/system_dialer.go | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go
index 6d1ef739..a7ebf75c 100644
--- a/transport/internet/system_dialer.go
+++ b/transport/internet/system_dialer.go
@@ -77,14 +77,6 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
dialer.Control = func(network, address string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
if sockopt != nil {
- if dest.Network == net.Network_TCP && sockopt.Mptcp {
- if dialer.MultipathTCP() {
- newError("Dialer MultipathTCP is enable").WriteToLog(session.ExportIDToError(ctx))
- } else {
- newError("Dialer MultipathTCP is disable,we are enable it").WriteToLog(session.ExportIDToError(ctx))
- dialer.SetMultipathTCP(true) // 主动启用mptcp
- }
- }
if err := applyOutboundSocketOptions(network, address, fd, sockopt); err != nil {
newError("failed to apply socket options").Base(err).WriteToLog(session.ExportIDToError(ctx))
}
@@ -104,6 +96,15 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
}
}
+ if sockopt != nil && dest.Network == net.Network_TCP && sockopt.Mptcp {
+ if dialer.MultipathTCP() {
+ newError("Dialer MultipathTCP is enable").WriteToLog(session.ExportIDToError(ctx))
+ } else {
+ newError("Dialer MultipathTCP is disable,we are enable it").WriteToLog(session.ExportIDToError(ctx))
+ dialer.SetMultipathTCP(true) // 主动启用mptcp
+ }
+ }
+
return dialer.DialContext(ctx, dest.Network.SystemString(), dest.NetAddr())
}