mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Merge branch 'test' into develop
This commit is contained in:
commit
510a9df2d7
15 changed files with 192 additions and 93 deletions
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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="[{"enableipv6":"0"},{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="8">
|
||||
<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-depends="[{"enableipv6":"0","cbid.network.<%=ifname%>.proto":"static"},{"enableipv6":"0","cbid.network.<%=ifname%>.type":"macvlan"}]" 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="[{"enableipv6":"0"},{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="9">
|
||||
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-depends="[{"enableipv6":"0","cbid.network.<%=ifname%>.proto":"static"},{"enableipv6":"0","cbid.network.<%=ifname%>.type":"macvlan"}]" 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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue