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

Merge pull request #72 from Ysurac/develop

sync
This commit is contained in:
suyuan 2021-02-16 02:35:53 +08:00 committed by GitHub
commit a09dcf3302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 15 deletions

View file

@ -240,6 +240,7 @@ function wizard_add()
local netmask = luci.http.formvalue("cbid.network.%s.netmask" % intf) or "" local netmask = luci.http.formvalue("cbid.network.%s.netmask" % intf) or ""
local gateway = luci.http.formvalue("cbid.network.%s.gateway" % intf) or "" local gateway = luci.http.formvalue("cbid.network.%s.gateway" % intf) or ""
local ip6gw = luci.http.formvalue("cbid.network.%s.ip6gw" % intf) or "" local ip6gw = luci.http.formvalue("cbid.network.%s.ip6gw" % intf) or ""
local ipv6 = luci.http.formvalue("cbid.network.%s.ipv6" % intf) or "0"
local apn = luci.http.formvalue("cbid.network.%s.apn" % intf) or "" local apn = luci.http.formvalue("cbid.network.%s.apn" % intf) or ""
local pincode = luci.http.formvalue("cbid.network.%s.pincode" % intf) or "" local pincode = luci.http.formvalue("cbid.network.%s.pincode" % intf) or ""
local delay = luci.http.formvalue("cbid.network.%s.delay" % intf) or "" local delay = luci.http.formvalue("cbid.network.%s.delay" % intf) or ""
@ -282,6 +283,7 @@ function wizard_add()
ucic:set("network",intf,"auth",auth) ucic:set("network",intf,"auth",auth)
ucic:set("network",intf,"mode",mode) ucic:set("network",intf,"mode",mode)
ucic:set("network",intf,"label",label) ucic:set("network",intf,"label",label)
ucic:set("network",intf,"ipv6",ipv6)
if lan == "1" then if lan == "1" then
ucic:set("network",intf,"multipath","off") ucic:set("network",intf,"multipath","off")
else else
@ -635,11 +637,13 @@ function wizard_add()
local encryption = luci.http.formvalue("encryption") local encryption = luci.http.formvalue("encryption")
if encryption == "none" then if encryption == "none" then
ucic:set("shadowsocks-libev","sss0","method","none") ucic:set("shadowsocks-libev","sss0","method","none")
ucic:set("shadowsocks-libev","sss1","method","none")
ucic:set("openvpn","omr","cipher","none") ucic:set("openvpn","omr","cipher","none")
ucic:set("v2ray","omrout","s_vmess_user_security","none") ucic:set("v2ray","omrout","s_vmess_user_security","none")
ucic:set("v2ray","omrout","s_vless_user_security","none") ucic:set("v2ray","omrout","s_vless_user_security","none")
elseif encryption == "aes-256-gcm" then elseif encryption == "aes-256-gcm" then
ucic:set("shadowsocks-libev","sss0","method","aes-256-gcm") ucic:set("shadowsocks-libev","sss0","method","aes-256-gcm")
ucic:set("shadowsocks-libev","sss1","method","aes-256-gcm")
ucic:set("glorytun","vpn","chacha20","0") ucic:set("glorytun","vpn","chacha20","0")
ucic:set("glorytun-udp","vpn","chacha","0") ucic:set("glorytun-udp","vpn","chacha","0")
ucic:set("openvpn","omr","cipher","AES-256-GCM") ucic:set("openvpn","omr","cipher","AES-256-GCM")
@ -647,6 +651,7 @@ function wizard_add()
ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm") ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm")
elseif encryption == "aes-256-cfb" then elseif encryption == "aes-256-cfb" then
ucic:set("shadowsocks-libev","sss0","method","aes-256-cfb") ucic:set("shadowsocks-libev","sss0","method","aes-256-cfb")
ucic:set("shadowsocks-libev","sss1","method","aes-256-cfb")
ucic:set("glorytun","vpn","chacha20","0") ucic:set("glorytun","vpn","chacha20","0")
ucic:set("glorytun-udp","vpn","chacha","0") ucic:set("glorytun-udp","vpn","chacha","0")
ucic:set("openvpn","omr","cipher","AES-256-CFB") ucic:set("openvpn","omr","cipher","AES-256-CFB")
@ -654,6 +659,7 @@ function wizard_add()
ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm") ucic:set("v2ray","omrout","s_vless_user_security","aes-128-gcm")
elseif encryption == "chacha20-ietf-poly1305" then elseif encryption == "chacha20-ietf-poly1305" then
ucic:set("shadowsocks-libev","sss0","method","chacha20-ietf-poly1305") ucic:set("shadowsocks-libev","sss0","method","chacha20-ietf-poly1305")
ucic:set("shadowsocks-libev","sss1","method","chacha20-ietf-poly1305")
ucic:set("glorytun","vpn","chacha20","1") ucic:set("glorytun","vpn","chacha20","1")
ucic:set("glorytun-udp","vpn","chacha","1") ucic:set("glorytun-udp","vpn","chacha","1")
ucic:set("openvpn","omr","cipher","AES-256-CBC") ucic:set("openvpn","omr","cipher","AES-256-CBC")
@ -674,6 +680,7 @@ function wizard_add()
--end --end
if shadowsocks_key ~= "" then if shadowsocks_key ~= "" then
ucic:set("shadowsocks-libev","sss0","key",shadowsocks_key) ucic:set("shadowsocks-libev","sss0","key",shadowsocks_key)
ucic:set("shadowsocks-libev","sss1","key",shadowsocks_key)
--ucic:set("shadowsocks-libev","sss0","method","chacha20-ietf-poly1305") --ucic:set("shadowsocks-libev","sss0","method","chacha20-ietf-poly1305")
--ucic:set("shadowsocks-libev","sss0","server_port","65101") --ucic:set("shadowsocks-libev","sss0","server_port","65101")
--ucic:set("shadowsocks-libev","sss0","disabled",shadowsocks_disable) --ucic:set("shadowsocks-libev","sss0","disabled",shadowsocks_disable)
@ -685,8 +692,10 @@ function wizard_add()
else else
if serversnb == 0 then if serversnb == 0 then
ucic:set("shadowsocks-libev","sss0","disabled",shadowsocks_disable) ucic:set("shadowsocks-libev","sss0","disabled",shadowsocks_disable)
ucic:set("shadowsocks-libev","sss1","disabled",shadowsocks_disable)
end end
ucic:set("shadowsocks-libev","sss0","key","") ucic:set("shadowsocks-libev","sss0","key","")
ucic:set("shadowsocks-libev","sss1","key","")
ucic:save("shadowsocks-libev") ucic:save("shadowsocks-libev")
ucic:commit("shadowsocks-libev") ucic:commit("shadowsocks-libev")
luci.sys.call("/etc/init.d/shadowsocks rules_down >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/shadowsocks rules_down >/dev/null 2>/dev/null")
@ -965,7 +974,7 @@ function settings_add()
local disableserverping = luci.http.formvalue("disableserverping") or "0" local disableserverping = luci.http.formvalue("disableserverping") or "0"
ucic:set("openmptcprouter","settings","disableserverping",disableserverping) ucic:set("openmptcprouter","settings","disableserverping",disableserverping)
-- Enable/disable shadowsocks upd -- Enable/disable shadowsocks udp
local shadowsocksudp = luci.http.formvalue("shadowsocksudp") or "0" local shadowsocksudp = luci.http.formvalue("shadowsocksudp") or "0"
ucic:set("openmptcprouter","settings","shadowsocksudp",shadowsocksudp) ucic:set("openmptcprouter","settings","shadowsocksudp",shadowsocksudp)
@ -1070,7 +1079,13 @@ end
function get_device(interface) function get_device(interface)
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {}) local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
if dump ~= nil then if dump ~= nil then
return dump['l3_device'] if dump['l3_device'] ~= nil then
return dump['l3_device']
elseif dump['device'] ~= nil then
return dump['device']
else
return ""
end
else else
return "" return ""
end end

View file

@ -561,12 +561,14 @@
<% <%
iffind=0 iffind=0
uciifname=uci:get("network",ifname,"ifname") uciifname=uci:get("network",ifname,"ifname")
if uciifname:match("/") then if uciifname ~= nil then
realifname=uciifname if uciifname:match("/") then
vlan="" realifname=uciifname
else vlan=""
realifname=splitstring(uciifname,'.')[1] or "" else
vlan=splitstring(uciifname,'.')[2] or "" realifname=splitstring(uciifname,'.')[1] or ""
vlan=splitstring(uciifname,'.')[2] or ""
end
end end
for _, ifacea in ipairs(ifaces) do for _, ifacea in ipairs(ifaces) do
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.*") or ifacea:match("^tun.*")) and device_notvirtual(ifacea) then 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.*") or ifacea:match("^tun.*")) and device_notvirtual(ifacea) then
@ -671,6 +673,13 @@
<% <%
end end
%> %>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;}]" data-index="10">
<label class="cbi-value-title"><%:Accept IPv6 RA%></label>
<div class="cbi-value-field">
<input type="checkbox" id="cbid.network.<%=ifname%>.ipv6" name="cbid.network.<%=ifname%>.ipv6" value="1" <% if uci:get("network",ifname,"ipv6") == "1" then %>checked<% end %> />
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-ncm" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;}]" data-index="5"> <div class="cbi-value" id="cbi-network-<%=ifname%>-device-ncm" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;}]" data-index="5">
<label class="cbi-value-title"><%:Device%></label> <label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field"> <div class="cbi-value-field">

View file

@ -60,25 +60,25 @@ omr_set_settings() {
config_get device "$1" device config_get device "$1" device
config_get proto "$1" proto config_get proto "$1" proto
config_get type "$1" type config_get type "$1" type
config_get ipv6 "$1" ipv6
config_get addlatency "$1" addlatency config_get addlatency "$1" addlatency
[ -z "$multipath" ] || [ "$multipath" = "off" ] && [ "$1" != "omrvpn" ] && [ "$1" != "glorytun" ] && return [ -z "$multipath" ] || [ "$multipath" = "off" ] && [ "$1" != "omrvpn" ] && [ "$1" != "glorytun" ] && return
uci -q set openmptcprouter.$1=interface uci -q set openmptcprouter.$1=interface
uci -q set openmptcprouter.$1.multipath="$multipath" uci -q set openmptcprouter.$1.multipath="$multipath"
config_get disable_ipv6 settings disable_ipv6 "0" config_get disable_ipv6 settings disable_ipv6 "0"
if [ "$proto" != "dhcpv6" ] && ([ "$disable_ipv6" = "1" ] || [ "$1" != "omr6in4" ]); then if [ "$disable_ipv6" = "1" ]; then
uci -q set network.$1.ipv6=0 uci -q set network.$1.ipv6=0
else
uci -q set network.$1.ipv6=1
fi fi
[ -z "$addlatency" ] && addlatency=0 [ -z "$addlatency" ] && addlatency=0
devicename=$(echo "$device" | cut -d'/' -f3) devicename=$(echo "$device" | cut -d'/' -f3)
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]') [ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
[ -n "$(echo $ifname | grep '@')" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
if [ -n "$ifname" ]; then if [ -n "$ifname" ]; then
if [ "$proto" = "dhcpv6" ]; then if [ "$proto" = "dhcpv6" ] || [ "$ipv6" = "1" ]; then
# Change interface name for sysctl in case of VLAN (eth0.2 => eth0/2) # Change interface name for sysctl in case of VLAN (eth0.2 => eth0/2)
ifnamesys=$(echo $ifname | sed 's:\.:/:') ifnamesys=$(echo $ifname | sed 's:\.:/:')
sysctl -qw net.ipv6.conf.${ifnamesys}.disable_ipv6=0 sysctl -qw net.ipv6.conf.${ifnamesys}.disable_ipv6=0

View file

@ -646,9 +646,9 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
config_foreach set_route interface $OMR_TRACKER_INTERFACE config_foreach set_route interface $OMR_TRACKER_INTERFACE
config_foreach set_route6 interface $OMR_TRACKER_INTERFACE config_foreach set_route6 interface $OMR_TRACKER_INTERFACE
fi fi
if [ "$(uci -q get openmptcprouter.settings.shadowsocksudp)" = "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get openmptcprouter.omr.shadowsocks)" = "up" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q get shadowsocks-libev.hi2.mode)" = "tcp_and_udp" ] && [ "$(uci -q get shadowsocks-libev.sss0.obfs)" != "1" ]; then if [ "$(uci -q get openmptcprouter.settings.shadowsocksudp)" = "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get openmptcprouter.omr.shadowsocks)" = "up" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q get shadowsocks-libev.hi1.mode)" = "tcp_and_udp" ] && [ "$(uci -q get shadowsocks-libev.sss0.obfs)" != "1" ]; then
_log "Tunnel down use ShadowSocks for UDP" _log "Tunnel down use ShadowSocks for UDP"
uci -q set shadowsocks-libev.ss_rules.redir_udp='hi2' uci -q set shadowsocks-libev.ss_rules.redir_udp='hi1'
if /etc/init.d/shadowsocks-libev rules_exist ; then if /etc/init.d/shadowsocks-libev rules_exist ; then
/etc/init.d/shadowsocks-libev rules_down /etc/init.d/shadowsocks-libev rules_down
/etc/init.d/shadowsocks-libev rules_up /etc/init.d/shadowsocks-libev rules_up
@ -699,7 +699,7 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
ip route replace default scope global nexthop via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE ip route replace default scope global nexthop via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE
/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 /etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1
fi fi
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "hi2" ]; then if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "hi1" ]; then
_log "Tunnel up disable use of ShadowSocks for UDP" _log "Tunnel up disable use of ShadowSocks for UDP"
uci -q delete shadowsocks-libev.ss_rules.redir_udp uci -q delete shadowsocks-libev.ss_rules.redir_udp
if /etc/init.d/shadowsocks-libev rules_exist ; then if /etc/init.d/shadowsocks-libev rules_exist ; then

View file

@ -412,6 +412,13 @@ while true; do
sleep "$OMR_TRACKER_INTERVAL_TRIES" sleep "$OMR_TRACKER_INTERVAL_TRIES"
done done
fi fi
if [ -z "$OMR_TRACKER_DEVICE_IP" ] || [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ -z "$OMR_TRACKER_DEVICE_IP6" ] || [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; then
[ -z "$OMR_TRACKER_STATUS_MSG" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_INTERFACE have ip issues"
[ -z "$OMR_TRACKER_DEVICE_IP" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv4"
[ -z "$OMR_TRACKER_DEVICE_GATEWAY" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv4 gateway"
[ -z "$OMR_TRACKER_DEVICE_IP6" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv6"
[ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv6 gateway"
fi
else else
OMR_TRACKER_STATUS_MSG="link down" OMR_TRACKER_STATUS_MSG="link down"
fi fi