mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add IPv6 enable/disable setting to wizard page
This commit is contained in:
parent
af7dfc1499
commit
1a4fef4b0e
2 changed files with 40 additions and 20 deletions
|
@ -93,6 +93,14 @@ function wizard_add()
|
||||||
ucic:save("network")
|
ucic:save("network")
|
||||||
ucic:commit("network")
|
ucic:commit("network")
|
||||||
|
|
||||||
|
-- Enable/disable IPv6
|
||||||
|
local disable_ipv6 = "0"
|
||||||
|
local enable_ipv6 = luci.http.formvalue("enable_ipv6") or "1"
|
||||||
|
if enable_ipv6 == "0" then
|
||||||
|
disable_pv6 = "1"
|
||||||
|
end
|
||||||
|
set_ipv6_state(disable_ipv6)
|
||||||
|
|
||||||
-- Get VPN set by default
|
-- Get VPN set by default
|
||||||
local default_vpn = luci.http.formvalue("default_vpn") or "glorytun_tcp"
|
local default_vpn = luci.http.formvalue("default_vpn") or "glorytun_tcp"
|
||||||
local vpn_port = ""
|
local vpn_port = ""
|
||||||
|
@ -312,23 +320,7 @@ function settings_add()
|
||||||
|
|
||||||
-- Disable IPv6
|
-- Disable IPv6
|
||||||
local disable_ipv6 = luci.http.formvalue("disable_ipv6") or 0
|
local disable_ipv6 = luci.http.formvalue("disable_ipv6") or 0
|
||||||
luci.sys.exec("sysctl -w net.ipv6.conf.all.disable_ipv6=%s" % disable_ipv6)
|
set_ipv6_state(disable_ipv6)
|
||||||
luci.sys.exec("sed -i 's:^net.ipv6.conf.all.disable_ipv6=[0-9]*:net.ipv6.conf.all.disable_ipv6=%s:' /etc/sysctl.d/zzz_openmptcprouter.conf" % disable_ipv6)
|
|
||||||
ucic:set("firewall",ucic:get_first("firewall","defaults"),"disable_ipv6",disable_ipv6)
|
|
||||||
ucic:save("firewall")
|
|
||||||
ucic:commit("firewall")
|
|
||||||
ucic:set("dhcp","lan","ra_default",disable_ipv6)
|
|
||||||
if disable_ipv6 == 1 then
|
|
||||||
luci.sys.call("uci -q del dhcp.lan.dhcpv6")
|
|
||||||
luci.sys.call("uci -q del dhcp.lan.ra")
|
|
||||||
ucic:set("shadowsocks-libev","hi","local_address","0.0.0.0")
|
|
||||||
else
|
|
||||||
ucic:set("dhcp","lan","dhcpv6","server")
|
|
||||||
ucic:set("dhcp","lan","ra","server")
|
|
||||||
ucic:set("shadowsocks-libev","hi","local_address","::")
|
|
||||||
end
|
|
||||||
ucic:save("dhcp")
|
|
||||||
ucic:commit("dhcp")
|
|
||||||
|
|
||||||
local obfs = luci.http.formvalue("obfs") or 0
|
local obfs = luci.http.formvalue("obfs") or 0
|
||||||
ucic:foreach("shadowsocks-libev", "ss_redir", function (section)
|
ucic:foreach("shadowsocks-libev", "ss_redir", function (section)
|
||||||
|
@ -699,8 +691,7 @@ function interfaces_status()
|
||||||
|
|
||||||
-- Detect if WAN get an IPv6
|
-- Detect if WAN get an IPv6
|
||||||
local ipv6_discover = "NONE"
|
local ipv6_discover = "NONE"
|
||||||
if ifname ~= nil then
|
if ifname ~= nil and mArray.openmptcprouter["ipv6"] == "enabled" then
|
||||||
if mArray.openmptcprouter["ipv6"] == "enabled" then
|
|
||||||
local ipv6_result = _ipv6_discover(ifname)
|
local ipv6_result = _ipv6_discover(ifname)
|
||||||
if type(ipv6_result) == "table" and #ipv6_result > 0 then
|
if type(ipv6_result) == "table" and #ipv6_result > 0 then
|
||||||
local ipv6_addr_test
|
local ipv6_addr_test
|
||||||
|
@ -718,7 +709,6 @@ function interfaces_status()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local publicIP = ut.trim(sys.exec("omr-ip-intf " .. ifname))
|
local publicIP = ut.trim(sys.exec("omr-ip-intf " .. ifname))
|
||||||
|
@ -842,4 +832,24 @@ function mptcp_check_trace(interface)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function set_ipv6_state(disable_ipv6)
|
||||||
|
luci.sys.exec("sysctl -w net.ipv6.conf.all.disable_ipv6=%s" % disable_ipv6)
|
||||||
|
luci.sys.exec("sed -i 's:^net.ipv6.conf.all.disable_ipv6=[0-9]*:net.ipv6.conf.all.disable_ipv6=%s:' /etc/sysctl.d/zzz_openmptcprouter.conf" % disable_ipv6)
|
||||||
|
ucic:set("firewall",ucic:get_first("firewall","defaults"),"disable_ipv6",disable_ipv6)
|
||||||
|
ucic:save("firewall")
|
||||||
|
ucic:commit("firewall")
|
||||||
|
ucic:set("dhcp","lan","ra_default",disable_ipv6)
|
||||||
|
if disable_ipv6 == 1 then
|
||||||
|
luci.sys.call("uci -q del dhcp.lan.dhcpv6")
|
||||||
|
luci.sys.call("uci -q del dhcp.lan.ra")
|
||||||
|
ucic:set("shadowsocks-libev","hi","local_address","0.0.0.0")
|
||||||
|
else
|
||||||
|
ucic:set("dhcp","lan","dhcpv6","server")
|
||||||
|
ucic:set("dhcp","lan","ra","server")
|
||||||
|
ucic:set("shadowsocks-libev","hi","local_address","::")
|
||||||
|
end
|
||||||
|
ucic:save("dhcp")
|
||||||
|
ucic:commit("dhcp")
|
||||||
end
|
end
|
|
@ -114,6 +114,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="cbi-value">
|
||||||
|
<label class="cbi-value-title"><%:Enable IPv6%></label>
|
||||||
|
<div class="cbi-value-field">
|
||||||
|
<input class="cbi-input-checkbox" type="checkbox" name="enableipv6" value="1" <% if tonumber((luci.sys.exec("sysctl net.ipv6.conf.all.disable_ipv6")):match(" %d+")) == 0 then %>checked<% end %> />
|
||||||
|
<br />
|
||||||
|
<div class="cbi-value-description">
|
||||||
|
<%:You should disable IPv6 here if server doesn't provide IPv6.%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="cbi-section" id="interfaces">
|
<fieldset class="cbi-section" id="interfaces">
|
||||||
<legend><%:Interfaces settings%></legend>
|
<legend><%:Interfaces settings%></legend>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue