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

Add bypass IPs and network support

This commit is contained in:
Ycarus 2018-05-15 17:20:49 +02:00
parent 1bdb327224
commit 602aa8a127
7 changed files with 83 additions and 16 deletions

View file

@ -1,4 +1,5 @@
local ucic = luci.model.uci.cursor()
local dt = require "luci.cbi.datatypes"
module("luci.controller.omr-bypass", package.seeall)
function index()
@ -12,16 +13,29 @@ function bypass_add()
if (type(hosts) ~= "table") then
hosts = {hosts}
end
local ipset = ""
local domains_ipset = ""
local ip_ipset = {}
for _, k in pairs(hosts) do
if k ~= "" then
ipset = ipset .. '/' .. k
if dt.ipaddr(k) then
table.insert(ip_ipset, k)
else
domains_ipset = domains_ipset .. '/' .. k
end
end
end
ucic:set_list("dhcp",ucic:get_first("dhcp","dnsmasq"),"ipset",ipset .. "/ss_rules_dst_bypass")
ucic:delete("omr-bypass","ips","ip")
if table.getn(ip_ipset) > 0 then
for _, i in pairs(ip_ipset) do
ucic:set_list("omr-bypass","ips","ip",ip_ipset)
end
end
ucic:save("omr-bypass")
ucic:commit("omr-bypass")
ucic:set_list("dhcp",ucic:get_first("dhcp","dnsmasq"),"ipset",domains_ipset .. "/ss_rules_dst_bypass")
ucic:save("dhcp")
ucic:commit("dhcp")
luci.sys.exec("/etc/init.d/dnsmasq restart")
--luci.sys.exec("/etc/init.d/dnsmasq restart")
luci.http.redirect(luci.dispatcher.build_url("admin/services/omr-bypass"))
return
end