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

Add backup to VPS interface and simplify IPv6 enable/disable

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-10-09 18:40:05 +02:00
parent e9556c107c
commit 88706de9b2
9 changed files with 142 additions and 116 deletions

View file

@ -449,7 +449,10 @@ end
function disableipv6(disable_ipv6)
-- Disable IPv6
set_ipv6_state(disable_ipv6)
ucic:set("openmptcprouter","settings","disable_ipv6",disable_ipv6)
ucic:save("openmptcprouter")
ucic:commit("openmptcprouter")
luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null")
end
function externalcheck(externalcheck)
@ -1042,7 +1045,7 @@ function interfaces_status()
local ipv6_discover = "NONE"
if ifname ~= "" and ifname ~= nil and mArray.openmptcprouter["ipv6"] == "enabled" then
local ipv6_result = ""
--local ipv6_result = _ipv6_discover(ifname)
local ipv6_result = _ipv6_discover(ifname)
if type(ipv6_result) == "table" and #ipv6_result > 0 then
local ipv6_addr_test
for k,v in ipairs(ipv6_result) do
@ -1051,9 +1054,9 @@ function interfaces_status()
ipv6_addr_test = sys.exec("ip -6 addr | grep " .. v.RecursiveDnsServer)
if ipv6_addr_test == "" then
ipv6_discover = "DETECTED"
if connectivity == "OK" then
connectivity = "WARNING"
end
--if connectivity == "OK" then
-- connectivity = "WARNING"
--end
end
end
end
@ -1183,67 +1186,6 @@ function _ipv6_discover(interface)
return ra6_result
end
function set_ipv6_state(disable_ipv6)
-- Disable/Enable IPv6 support
luci.sys.exec("sysctl -qw 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)
--luci.sys.exec("sysctl -qw net.ipv6.conf.all.disable_ipv6=" % disable_ipv6)
--luci.sys.exec("sed -i 's:^net.ipv6.conf.all.disable_ipv6=[0-9]*:net.ipv6.conf.all.disable_ipv6=0:' /etc/sysctl.d/zzz_openmptcprouter.conf" % disable_ipv6)
-- Disable/Enable IPv6 for firewall
ucic:set("firewall",ucic:get_first("firewall","defaults"),"disable_ipv6",disable_ipv6)
ucic:save("firewall")
ucic:commit("firewall")
-- Disable/Enable IPv6 in OpenMPTCProuter settings
ucic:set("openmptcprouter","settings","disable_ipv6",disable_ipv6)
ucic:save("openmptcprouter")
ucic:commit("openmptcprouter")
-- Disable/Enable route announce of IPv6
if disable_ipv6 == "1" then
ucic:set("dhcp","lan","ra_default","0")
ucic:set("network","lan","ipv6","0")
--luci.sys.call("uci -q del network.lan.ipifaceid")
else
-- ucic:set("dhcp","lan","ra_default","1")
ucic:set("network","lan","ipv6","1")
ucic:set("network","lan","delegate","0")
--ucic:set("network","lan","ipifaceid","random")
end
ucic:save("network")
ucic:commit("network")
-- Disable/Enable IPv6 DHCP and change Shadowsocks listen address
if disable_ipv6 == "1" then
luci.sys.call("uci -q del dhcp.lan.dhcpv6")
luci.sys.call("uci -q del dhcp.lan.ra")
luci.sys.call("uci -q del dhcp.lan.ra_default")
luci.sys.call("uci -q del dhcp.lan.ra_management")
luci.sys.call("uci -q del dhcp.lan.ra_preference")
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("dhcp","lan","ra_default","1")
ucic:set("dhcp","lan","ra_preference","high")
ucic:set("dhcp","lan","ra_management","1")
ucic:set("shadowsocks-libev","hi","local_address","::")
end
ucic:save("shadowsocks-libev")
ucic:commit("shadowsocks-libev")
ucic:save("dhcp")
ucic:commit("dhcp")
luci.sys.exec("/etc/init.d/omr-6in4 restart >/dev/null 2>&1")
--if disable_ipv6 == "1" then
-- luci.sys.exec("/etc/init.d/odhcpd stop >/dev/null 2>&1")
-- luci.sys.exec("/etc/init.d/odhcpd disable >/dev/null 2>&1")
--else
-- luci.sys.exec("/etc/init.d/odhcpd start >/dev/null 2>&1")
-- luci.sys.exec("/etc/init.d/odhcpd enable >/dev/null 2>&1")
--end
end
local methods = {
status = {
call = function()