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

Merge branch 'pr/63' into test

This commit is contained in:
suyuan 2021-01-30 01:11:57 +08:00
commit 59cde48b17
15 changed files with 192 additions and 93 deletions

View file

@ -98,6 +98,7 @@ jobs:
user: deploy
port: ${{ secrets.OMR_DEPLOY_PORT }}
key: ${{ secrets.PRIVATE_KEY }}
args: -tt
- if: steps.branch_name.outputs.SOURCE_BRANCH != ''
name: Deploy - Create directory
uses: ysurac/ssh-action@master
@ -112,6 +113,7 @@ jobs:
user: deploy
port: ${{ secrets.OMR_DEPLOY_PORT }}
key: ${{ secrets.PRIVATE_KEY }}
args: -tt
- name: Move binaries for rsync
working-directory: ../../omr
env:

View file

@ -50,7 +50,8 @@ _bypass_domains() {
_bypass_domain() {
local domain=$1
local intf=$2
intf=$(echo $intf | sed -e 's/\./_/')
[ -z "$intf" ] && intf="all"
if [ -n "$domain" ]; then
domain=$(echo $domain | sed 's:^\.::')
@ -68,7 +69,7 @@ _bypass_domain() {
fi
fi
if [ "$(uci -q get dhcp.@dnsmasq[0].ipset | grep /$domain/)" = "" ]; then
uci -q add_list dhcp.@dnsmasq[0].ipset="/$domain/omr_dst_bypass_$intf,omr6_dst_bypass_$intf"
uci -q add_list dhcp.@dnsmasq[0].ipset="/$domain/omr_dst_bypass_$intfuci,omr6_dst_bypass_$intf"
else
dnsmasqipset=$(uci -q get dhcp.@dnsmasq[0].ipset | sed 's/ /\n/g')
for dnsipset in $dnsmasqipset; do
@ -90,8 +91,8 @@ _bypass_mac() {
config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
intfuci=$(echo $intf | sed 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intfuci.id)"
intf=$(echo $intf | sed -e 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all"
[ -z "$mac" ] && return
@ -132,8 +133,8 @@ _bypass_lan_ip() {
config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
intfuci=$(echo $intf | sed 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intfuci.id)"
intf=$(echo $intf | sed -e 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all"
[ -z "$ip" ] && return
@ -190,8 +191,8 @@ _bypass_dest_port() {
config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
intfuci=$(echo $intf | sed 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intfuci.id)"
intf=$(echo $intf | sed -e 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all"
[ -z "$dport" ] && return
@ -246,8 +247,8 @@ _bypass_src_port() {
config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
intfuci=$(echo $intf | sed 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intfuci.id)"
intf=$(echo $intf | sed -e 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all"
[ -z "$sport" ] && return
@ -300,8 +301,8 @@ _bypass_proto() {
config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
intfuci=$(echo $intf | sed 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intfuci.id)"
intf=$(echo $intf | sed -e 's/\./_/')
local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all"
[ -z "$proto" ] && return
@ -459,6 +460,7 @@ _intf_rule() {
#[ "$mode" = "off" ] && return
[ -z "$count" ] && return
[ -z "$intf" ] && return
intf=$(echo $intf | sed -e 's/\./_/')
[ "$(echo $1 | grep _dev)" != "" ] && return
[ -z "$RELOAD" ] || [ "$(ipset --list | grep omr_dst_bypass_$intf)" = "" ] && {
unset RELOAD
@ -498,9 +500,8 @@ _intf_rule() {
config_foreach _intf_rule_ss_rules ss_rules
_intf_rule_v2ray_rules
intfuci=$(echo $intf | sed 's/\./_/')
uci -q set omr-bypass.$intfuci=interface
uci -q set omr-bypass.$intfuci.id=$count
uci -q set omr-bypass.$intf=interface
uci -q set omr-bypass.$intf.id=$count
}
_bypass_ip_set() {

View file

@ -66,7 +66,8 @@ function wizard_add()
ucic:foreach("openmptcprouter", "server", function(s)
local servername = s[".name"]
nbserver = nbserver + 1
server_ip = ucic:get("openmptcprouter",servername,"ip")
server_ips = ucic:get_list("openmptcprouter",servername,"ip")
server_ip = server_ips[1]
end)
if nbserver == 1 and server_ip ~= "" and server_ip ~= nil then
ucic:set("shadowsocks-libev","sss0","server",server_ip)
@ -425,8 +426,14 @@ function wizard_add()
local disablednb = 0
local servers = luci.http.formvaluetable("server")
for server, _ in pairs(servers) do
local server_ip = {}
server_ip[1] = luci.http.formvalue("%s.server_ip" % server) or ""
local serverips = luci.http.formvaluetable("%s.serverip" % server) or {}
local aserverips = {}
for _, ip in pairs(serverips) do
if ip ~= "" and ip ~= nil then
table.insert(aserverips,ip)
end
end
local master = luci.http.formvalue("master") or ""
-- OpenMPTCProuter VPS
@ -447,14 +454,14 @@ function wizard_add()
if openmptcprouter_vps_disabled == "1" then
disablednb = disablednb + 1
end
if server_ip[1] ~= "" then
if next(aserverips) ~= nil then
serversnb = serversnb + 1
end
ucic:set("openmptcprouter",server,"server")
ucic:set("openmptcprouter",server,"username",openmptcprouter_vps_username)
ucic:set("openmptcprouter",server,"password",openmptcprouter_vps_key)
ucic:set("openmptcprouter",server,"disabled",openmptcprouter_vps_disabled)
ucic:set_list("openmptcprouter",server,"ip",server_ip)
ucic:set_list("openmptcprouter",server,"ip",aserverips)
ucic:set("openmptcprouter",server,"port","65500")
ucic:save("openmptcprouter")
end
@ -488,6 +495,13 @@ function wizard_add()
ucic:save("shadowsocks-libev")
ucic:save("v2ray")
ucic:foreach("shadowsocks-libev","server", function(s)
local sectionname = s[".name"]
if sectionname:match("^sss.*") then
ucic:delete("shadowsocks-libev",sectionname,"ip")
ucic:set("shadowsocks-libev",sectionname,"disabled","1")
end
end)
local ss_servers_nginx = {}
local ss_servers_ha = {}
@ -497,14 +511,20 @@ function wizard_add()
for server, _ in pairs(servers) do
local master = luci.http.formvalue("master") or ""
local server_ip = luci.http.formvalue("%s.server_ip" % server) or ""
local server_ips = luci.http.formvaluetable("%s.serverip" % server) or {}
local server_ip = ""
for _, ip in pairs(server_ips) do
if server_ip == "" and ip ~= "" and ip ~= nil then
server_ip=ip
end
end
-- We have an IP, so set it everywhere
if server_ip ~= "" and luci.http.formvalue("%s.openmptcprouter_vps_disabled" % server) ~= "1" then
if server_ip ~= "" and server_ip ~= nil and luci.http.formvalue("%s.openmptcprouter_vps_disabled" % server) ~= "1" then
-- Check if we have more than one IP, in this case use Nginx HA
if serversnb > 1 then
if master == server then
ss_ip=server_ip
ucic:set("shadowsocks-libev","sss0","server",server_ip)
--ucic:set("shadowsocks-libev","sss0","server",server_ip)
ucic:set("glorytun","vpn","host",server_ip)
ucic:set("glorytun-udp","vpn","host",server_ip)
ucic:set("dsvpn","vpn","host",server_ip)
@ -516,6 +536,14 @@ function wizard_add()
luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
ucic:set("qos","serverin","srchost",server_ip)
ucic:set("qos","serverout","dsthost",server_ip)
local nbip = 0
for _, ssip in pairs(server_ips) do
ucic:set("shadowsocks-libev","sss" .. nbip,"server",ssip)
if default_proxy == "shadowsocks" then
ucic:set("shadowsocks-libev","sss" .. nbip,"disabled","0")
end
nbip = nbip + 1
end
end
k = k + 1
ucic:set("nginx-ha","ShadowSocks","enable","0")
@ -526,7 +554,7 @@ function wizard_add()
ucic:set("openmptcprouter","settings","ha","0")
ucic:set("nginx-ha","ShadowSocks","enable","0")
ucic:set("nginx-ha","VPN","enable","0")
ucic:set("shadowsocks-libev","sss0","server",server_ip)
--ucic:set("shadowsocks-libev","sss0","server",server_ip)
ucic:set("glorytun","vpn","host",server_ip)
ucic:set("glorytun-udp","vpn","host",server_ip)
ucic:set("dsvpn","vpn","host",server_ip)
@ -538,6 +566,14 @@ function wizard_add()
luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip)
ucic:set("qos","serverin","srchost",server_ip)
ucic:set("qos","serverout","dsthost",server_ip)
local nbip = 0
for _, ssip in pairs(server_ips) do
ucic:set("shadowsocks-libev","sss" .. nbip,"server",ssip)
if default_proxy == "shadowsocks" then
ucic:set("shadowsocks-libev","sss" .. nbip,"disabled","0")
end
nbip = nbip + 1
end
end
end
end

View file

@ -255,7 +255,7 @@
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:When proxy shadowsocks is used, use it for UDP if proxy down%></label>
<label class="cbi-value-title"><%:When proxy shadowsocks is used, use it for UDP if VPN down%></label>
<div class="cbi-value-field">
<input type="checkbox" name="shadowsocksudp" class="cbi-input-checkbox" value="1" <% if luci.model.uci.cursor():get("openmptcprouter","settings","shadowsocksudp") == "1" then %>checked<% end %>>
</div>

View file

@ -55,12 +55,16 @@
<h3><%=servername%></h3>
<div class="cbi-section-node" id="cbi-omr-wizard-<%=servername%>">
<div class="cbi-value">
<label class="cbi-value-title" for="server_ip"><%:Server IP%></label>
<label class="cbi-value-title" for="server_ip.1"><%:Server IP%></label>
<div class="cbi-value-field">
<input name="<%=servername%>.server_ip" id="<%=servername%>.server_ip" placeholder="<%:Server IP%>" class="cbi-input-text" value="<%=uci:get_list("openmptcprouter",servername,"ip")[1]%>" data-optional="false">
<input name="<%=servername%>.serverip.ip1" id="<%=servername%>.server_ip.1" placeholder="<%:Primary server IP%>" class="cbi-input-text" value="<%=uci:get_list("openmptcprouter",servername,"ip")[1]%>" data-optional="false">
<input name="<%=servername%>.serverip.ip2" id="<%=servername%>.server_ip.2" placeholder="<%:Secondary server IP%>" class="cbi-input-text" value="<%=uci:get_list("openmptcprouter",servername,"ip")[2]%>" data-optional="false">
<div class="cbi-value-description">
<%:Server IP will be set for proxy and VPN%>
</div>
<div class="cbi-value-description">
<%:A secondary server IP can be set for dual IPv4/IPv6 server contact if WAN IPv6 are set%>
</div>
</div>
</div>
<br />
@ -147,7 +151,10 @@
<div class="cbi-value">
<label class="cbi-value-title"><%:Enable IPv6%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" id="enableipv6" name="enableipv6" value="0" <% if uci:get("openmptcprouter","settings","disable_ipv6") == "0" then %>checked<% end %> />
<select class="cbi-input-select" name="enableipv6" id="enableipv6" data-update="change" size="1">
<option value="1" <% if uci:get("openmptcprouter","settings","disable_ipv6") ~= "0" then %>selected="selected"<% end %>><%:Disabled%></option>
<option value="0" <% if uci:get("openmptcprouter","settings","disable_ipv6") == "0" then %>selected="selected"<% end %>><%:Enabled%></option>
</select>
<br />
<div class="cbi-value-description">
<%:You should disable IPv6 here if server doesn't provide IPv6.%>
@ -608,7 +615,7 @@
<%
else
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="8">
<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="8">
<label class="cbi-value-title"><%:IPv6 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6addr" name="cbid.network.<%=ifname%>.ip6addr" class="cbi-input-text" value="" data-type="ip6addr">
@ -618,7 +625,7 @@
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="9">
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="9">
<label class="cbi-value-title"><%:IPv6 gateway%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6gw" name="cbid.network.<%=ifname%>.ip6gw" class="cbi-input-text" value="<%=uci:get("network",ifname,"ip6gw")%>" data-type="ip6addr">
@ -874,6 +881,13 @@
if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea == "mlvpn0" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*")) and device_notvirtual(ifacea) then
%>
<option value="<%=ifacea%>"><%=ifacea%></option>
<%
end
end
for _, ifacea in ipairs(net:get_networks()) do
if not (ifacea:name() == "loopback" or ifacea:name() == "omr6in4" or ifacea:name() == "omrvpn" or ifacea:name():match("^omrip.*")) then
%>
<option value="<%='@' .. ifacea:name()%>"><%='@' .. ifacea:name() .. ' (alias)'%></option>
<%
end
end

View file

@ -20,17 +20,22 @@ _set_intf_name() {
fi
[ -n "$modalias" ] && {
if [ -f /sys/class/net/${INTERFACE}/device/uevent ]; then
mac=""
if [ -f /sys/class/net/${INTERFACE}/address ]; then
mac="$(cat /sys/class/net/${INTERFACE}/address | tr -d '\n')"
fi
chk_modalias=$MODALIAS
[ -z "$chk_modalias" ] && chk_modalias="$(cat /sys/class/net/${INTERFACE}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
if [ -n "$chk_modalias" ]; then
chk_modalias="${chk_modalias}-${mac}"
logger -t "OMR-Rename" "modalias: $modalias - chk_modalias: $chk_modalias - ifname: $ifname - INTERFACE: $INTERFACE"
if [ "$modalias" = "$chk_modalias" ] && [ "$INTERFACE" != "$ifname" ]; then
logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}"
existif=0
existif="0"
ip link set ${INTERFACE} down 2>&1 >/dev/null
[ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && {
ip link set ${ifname} name ${ifname}tmp 2>&1 >/dev/null
existif=1
existif="1"
}
ip link set ${INTERFACE} name ${ifname} 2>&1 >/dev/null
ip link set ${ifname} up 2>&1 >/dev/null
@ -48,10 +53,10 @@ _set_intf_name() {
logger -t "OMR-Rename" "device: $device - devpath: $DEVPATH - ifname: $ifname - INTERFACE: $INTERFACE"
logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}"
ip link set ${INTERFACE} down 2>&1 >/dev/null
existif=0
existif="0"
[ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && {
ip link set ${ifname} name ${ifname}tmp 2>&1 >/dev/null
existif=1
existif="1"
}
ip link set ${INTERFACE} name ${ifname} 2>&1 >/dev/null
ip link set ${ifname} up 2>&1 >/dev/null
@ -62,5 +67,5 @@ _set_intf_name() {
if [ "$(uci -q get openmptcprouter.settings.disableintfrename)" != "1" ]; then
config_load network
config_foreach _set_intf_name interface
config_foreach _set_intf_name interface
# config_foreach _set_intf_name interface
fi

View file

@ -27,7 +27,11 @@ omr_intf_set() {
if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
devicepath=$(readlink -f /sys/class/net/${ifname})
if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" = "" ]; then
uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
mac=""
if [ -f /sys/class/net/${ifname}/address ]; then
mac="$(cat /sys/class/net/${ifname}/address | tr -d '\n')"
fi
uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')-$mac"
uci -q set network.$1.product="$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')"
elif [ -n "$devicepath" ] && ([ "$(echo ${devicepath} | grep virtual)" != "" ] || [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" = "" ] || [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" != "" ] || [ "$(cat /sys/class/net/${ifname}tmp/device/uevent)" != "" ]); then
uci -q delete network.$1.device
@ -35,7 +39,11 @@ omr_intf_set() {
uci -q delete network.$1.product
fi
elif [ "$type" != "macvlan" ] && [ -n "$device" ] && [ -f /sys/bus/usb-serial/devices/${devicename}/device/uevent ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ]; then
uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
mac=""
if [ -f /sys/class/net/${ifname}/address ]; then
mac="$(cat /sys/class/net/${ifname}/address | tr -d '\n')"
fi
uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')-$mac"
uci -q set network.$1.product="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')"
else
uci -q delete network.$1.modalias

View file

@ -1115,6 +1115,7 @@ function interfaces_status()
local gateway6 = section["ip6gw"] or ""
local multipath = section["multipath"]
local enabled = section["auto"]
local proto = section["proto"] or ""
--if not ipaddr or not gateway then return end
-- Don't show if0 in the overview
@ -1130,7 +1131,7 @@ function interfaces_status()
duplicateif = false
if ifname ~= "" and ifname ~= nil then
if allintf[ifname] then
if allintf[ifname] and not section["ifname"]:match("^@.*") then
connectivity = "ERROR"
duplicateif = true
else
@ -1144,10 +1145,10 @@ function interfaces_status()
if enabled == "0" then return end
local connectivity = "OK"
if ipaddr == "" and ifname ~= nil and ifname ~= "" then
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 ~= "" then
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 ~= "" then
@ -1195,14 +1196,16 @@ function interfaces_status()
local gw_ping = "UP"
local gw_ping6 = "UP"
if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*")) then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
if proto ~= "dhcpv6" then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
gateway6 = ut.trim(sys.exec("ip -6 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
if gateway == "" then
if gateway == "" and proto ~= "dhcpv6" then
gateway = get_gateway(interface)
end
if gateway == "" and ifname ~= nil and ifname ~= "" then
if gateway == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then
if fs.access("/sys/class/net/" .. ifname) then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep kernel | awk '/proto kernel/ {print $1}' | grep -v / | tr -d '\n'"))
if gateway == "" then
@ -1263,7 +1266,7 @@ function interfaces_status()
end
if ifname ~= "" and ifname ~= nil then
local proto = section['proto']
--local proto = section['proto']
if proto == "qmi" then
local device = section['device']
intfdata = ut.trim(sys.exec("omr-qmi " .. device .. " all"))
@ -1438,6 +1441,7 @@ function interfaces_status()
phonenumber = phonenumber,
donglestate = donglestate,
networktype = networktype,
proto = proto,
rx = rx,
tx = tx,
}

View file

@ -872,6 +872,9 @@ if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
elif [ "$(uci -q get openmptcprouter.settings.master)" != "failover" ]; then
config_foreach set_server_route server
fi
if [ "$(ip r show dev $OMR_TRACKER_DEVICE | grep default)" = "" ] && [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.metric)" != "" ]; then
ip r replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $(uci -q get network.$OMR_TRACKER_INTERFACE.metric) >/dev/null 2>&1
fi
fi
if [ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; then
config_load openmptcprouter
@ -881,6 +884,9 @@ if [ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; th
elif [ "$(uci -q get openmptcprouter.settings.master)" != "failover" ]; then
config_foreach set_server_route6 server
fi
if [ "$(ip -6 r show dev $OMR_TRACKER_DEVICE | grep default)" = "" ] && [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.metric)" != "" ]; then
ip -6 r replace default via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE metric $(uci -q get network.$OMR_TRACKER_INTERFACE.metric) >/dev/null 2>&1
fi
fi
if [ "$multipath_config" = "on" ] || [ "$multipath_config" = "backup" ]; then
@ -891,45 +897,55 @@ if [ "$multipath_config" = "on" ] || [ "$multipath_config" = "backup" ]; then
if [ "$(uci -q show | grep mptcpr)" = "" ]; then
touch /etc/config/openmptcprouter
fi
gtudpst="up"
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" != "1" ] && [ "$multipath_config" = "backup" ] && [ "$(pgrep glorytun-udp)" != "" ] && gtudpst="backup"
if [ "$OMR_TRACKER_DEVICE_IP" != "" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp path | grep $OMR_TRACKER_DEVICE_IP)" = "" ]; then
if [ "$download" != "0" ] && [ "$download" != "" ] && [ "$upload" != "0" ] && [ "$upload" != "" ]; then
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate auto tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate fixed tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
glorytunudppath() {
gtudp_port="$(uci -q get glorytun-udp.vpn.port)"
gtudp_dev="$(uci -q get glorytun-udp.vpn.dev)"
addpath() {
serverip=$1
#gtudpst="up"
#[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" != "1" ] && [ "$multipath_config" = "backup" ] && [ "$(pgrep glorytun-udp)" != "" ] && gtudpst="backup"
if [ "$OMR_TRACKER_DEVICE_IP" != "" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp path | grep $OMR_TRACKER_DEVICE_IP)" = "" ] && [ -n "$(resolveip -4 $serverip)" ]; then
if [ "$download" != "0" ] && [ "$download" != "" ] && [ "$upload" != "0" ] && [ "$upload" != "" ]; then
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate auto tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate fixed tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
fi
else
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate auto tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate fixed tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
fi
fi
fi
else
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate auto tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set up rate fixed tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
if [ "$OMR_TRACKER_DEVICE_IP6" != "" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp path | grep $OMR_TRACKER_DEVICE_IP6)" = "" ] && [ -n "$(resolveip -6 $serverip)" ]; then
if [ "$download" != "0" ] && [ "$download" != "" ] && [ "$upload" != "0" ] && [ "$upload" != "" ]; then
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate auto tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate fixed tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
fi
else
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate auto tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 to addr $serverip dev ${gtudp_dev} port ${gtudp_port} set up rate fixed tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
fi
fi
fi
fi
fi
if [ "$OMR_TRACKER_DEVICE_IP6" != "" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp path | grep $OMR_TRACKER_DEVICE_IP6)" = "" ]; then
if [ "$download" != "0" ] && [ "$download" != "" ] && [ "$upload" != "0" ] && [ "$upload" != "" ]; then
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 dev tun0 set up rate auto tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 dev tun0 set up rate fixed tx $((upload*1000/8)) rx $((download*1000/8)) pref 1 > /dev/null 2>&1
fi
else
if [ "$(uci -q get glorytun-udp.vpn.rateauto)" = "1" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 dev tun0 set up rate auto tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
else
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 dev tun0 set up rate fixed tx 12500000 rx 12500000 pref 1 > /dev/null 2>&1
fi
fi
fi
# if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp set | grep 'kxtimeout 7d')" = "" ]; then
# glorytun-udp set dev tun0 kxtimeout 7d > /dev/null 2>&1
# fi
[ "$multipath_config" = "backup" ] && [ "$(pgrep glorytun-udp)" != "" ] && {
[ -n "$OMR_TRACKER_DEVICE_IP" ] && glorytun-udp path addr $OMR_TRACKER_DEVICE_IP dev tun0 set pref 125 > /dev/null 2>&1
[ -n "$OMR_TRACKER_DEVICE_IP6" ] && glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 dev tun0 set pref 125 > /dev/null 2>&1
# if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" != "1" ] && [ "$(pgrep glorytun-udp)" != "" ] && [ "$(glorytun-udp set | grep 'kxtimeout 7d')" = "" ]; then
# glorytun-udp set dev tun0 kxtimeout 7d > /dev/null 2>&1
# fi
[ "$multipath_config" = "backup" ] && [ "$(pgrep glorytun-udp)" != "" ] && {
[ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$(resolveip -4 $serverip)" ] && glorytun-udp path addr $OMR_TRACKER_DEVICE_IP to addr $serverip port ${gtudp_port} dev ${gtudp_dev} set pref 125 > /dev/null 2>&1
[ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$(resolveip -6 $serverip)" ] && glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 to addr $serverip port ${gtudp_port} dev ${gtudp_dev} set pref 125 > /dev/null 2>&1
}
}
config_list_foreach $1 ip addpath
}
config_load openmptcprouter
config_foreach glorytunudppath server
fi
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" != "1" ] && {
[ "$multipath_status" = "$multipath_config" ] || {
@ -1230,7 +1246,7 @@ if [ "$(pgrep rpcd)" = "" ] && [ -f /etc/init.d/rpcd ]; then
sleep 5
fi
if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -f /etc/init.d/v2ray ] && [ "$(pgrep -f omr-tracker-v2ray)" = "" ]; then
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
fi
@ -1246,7 +1262,7 @@ if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get
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)" = "" ]; then
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
fi

View file

@ -10,8 +10,8 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=ndpi-netfilter2
PKG_RELEASE:=2
PKG_REV:=0a03249da911f4033fd2a0d38a97cdba72eee2b6
PKG_RELEASE:=3
PKG_REV:=25a5c2e1d619aa2d819b18bed8276b3bd7eb4c5b
PKG_VERSION:=3.2-$(PKG_REV)
PKG_SOURCE_PROTO:=git

View file

@ -27,7 +27,12 @@ _get_ip() {
[ -z "$check_ipv4_website" ] && check_ipv4_website="http://ip.openmptcprouter.com"
check_ipv6_website="$(uci -q get openmptcprouter.settings.check_ipv6_website)"
[ -z "$check_ipv6_website" ] && check_ipv6_website="http://ipv6.openmptcprouter.com"
uci -q set openmptcprouter.omr.detected_public_ipv4="$(curl -s -4 -m 3 $check_ipv4_website)"
public_ipv4="$(curl -s -4 -m 3 $check_ipv4_website)"
uci -q set openmptcprouter.omr.detected_public_ipv4="${public_ipv4}"
[ -n "$public_ipv4" ] && {
uci -q set upnpd.config.external_ip="${public_ipv4}"
uci -q commit upnpd
}
if [ "$(uci -q get openmptcprouter.omr.shadowsocks)" != "down" ]; then
uci -q set openmptcprouter.omr.detected_ss_ipv4="$(curl -s -4 --socks5 "${proxy}" --max-time 3 $check_ipv4_website)"
else

View file

@ -27,7 +27,12 @@ _get_ip() {
[ -z "$check_ipv4_website" ] && check_ipv4_website="http://ip.openmptcprouter.com"
check_ipv6_website="$(uci -q get openmptcprouter.settings.check_ipv6_website)"
[ -z "$check_ipv6_website" ] && check_ipv6_website="http://ipv6.openmptcprouter.com"
uci -q set openmptcprouter.omr.detected_public_ipv4="$(curl -s -4 -m 3 $check_ipv4_website)"
public_ipv4="$(curl -s -4 -m 3 $check_ipv4_website)"
uci -q set openmptcprouter.omr.detected_public_ipv4="${public_ipv4}"
[ -n "${public_ipv4}" ] && {
uci -q set upnpd.config.external_ip="${public_ipv4}"
uci -q commit upnpd
}
if [ "$(uci -q get openmptcprouter.omr.v2ray)" != "down" ]; then
uci -q set openmptcprouter.omr.detected_ss_ipv4="$(curl -s -4 --socks5 "${proxy}" --max-time 3 $check_ipv4_website)"
else

View file

@ -9,7 +9,7 @@
}
_getremoteip() {
[ "$(uci -q get openmptcprouter.$1.master)" = "1" ] && remoteip=$(uci -q get openmptcprouter.$1.ip)
[ "$(uci -q get openmptcprouter.$1.master)" = "1" ] && remoteip=$(uci -q get openmptcprouter.$1.ip | awk '{print $1}')
}
mptcp_over_vpn() {
@ -139,8 +139,8 @@ start_service()
elif [ "$(uci -q get glorytun.vpn.host)" = "10.255.250.1" ] && [ "$nbintf" != "$nbintfvpn" ]; then
uci -q batch <<-EOF >/dev/null
delete shadowsocks-libev.sss0.disabled
set glorytun.vpn.host="$(uci -q get openmptcprouter.vps.ip)"
set glorytun-udp.vpn.host="$(uci -q get openmptcprouter.vps.ip)"
set glorytun.vpn.host="$(uci -q get openmptcprouter.vps.ip | awk '{print $1}')"
set glorytun-udp.vpn.host="$(uci -q get openmptcprouter.vps.ip | awk '{print $1}')"
commit glorytun
commit glorytun-udp
EOF

View file

@ -362,10 +362,11 @@ _get_vps_config() {
fi
fi
fi
vpsip="$(uci -q get openmptcprouter.${servername}.ip)"
vpsip="$(uci -q get openmptcprouter.${servername}.ip | awk '{print $1}')"
if [ "$(uci -q get shadowsocks-libev.sss0.server)" != "127.0.0.1" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "$vpsip" ] && [ "$(uci -q get openmptcprouter.settings.ha)" != "1" ]; then
config_foreach _set_ss_server server "server" $vpsip
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.server="$vpsip"
commit shadowsocks-libev
EOF
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" = "0" ]; then
@ -1033,7 +1034,9 @@ _set_ss_server() {
elif [ "$value" = "false" ]; then
value=0
fi
[ "$(echo $1 | grep omr)" != "" ] && uci -q set shadowsocks-libev.$1.$option=$value
if [ "$(echo $1 | grep omr)" != "" ] || [ "$(echo $1 | grep sss)" ]; then
uci -q set shadowsocks-libev.$1.$option=$value
fi
}
_set_config_from_vps() {
@ -1044,7 +1047,7 @@ _set_config_from_vps() {
logger -t "OMR-VPS" "Get config from server ${servername}..."
noerror=1
# get VPS ip
vpsip="$(uci -q get openmptcprouter.${servername}.ip)"
vpsip="$(uci -q get openmptcprouter.${servername}.ip | awk '{print $1}')"
vps_lastchange="$(echo "$vps_config" | jsonfilter -q -e '@.vps.lastchange')"
lastchange="$(uci -q get openmptcprouter.${servername}.lastchange)"
[ -z "$lastchange" ] && lastchange=0

View file

@ -9,7 +9,7 @@
}
_getremoteip() {
[ "$(uci -q get openmptcprouter.$1.master)" = "1" ] && remoteip=$(uci -q get openmptcprouter.$1.ip)
[ "$(uci -q get openmptcprouter.$1.master)" = "1" ] && remoteip=$(uci -q get openmptcprouter.$1.ip | awk '{print $1}')
}
_openvpnbonding() {