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
ucic:set_list("dhcp",ucic:get_first("dhcp","dnsmasq"),"ipset",ipset .. "/ss_rules_dst_bypass")
end
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

View file

@ -5,6 +5,7 @@
<%
local uci = require("luci.model.uci").cursor()
local hosts = uci:get_list("dhcp", uci:get_first("dhcp","dnsmasq"), "ipset")
local ips = uci:get_list("omr-bypass", "ips", "ip")
%>
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
@ -12,15 +13,14 @@
<div class="cbi-map">
<h2 name="content"><%:Bypass%></h2>
<fieldset class="cbi-section" id="hosts">
<div class="cbi-section-descr"><%:Set domains name you want to bypass.%></div>
<div class="cbi-section-descr"><%:Set domains name, ips or networks you want to bypass.%></div>
<div class="cbi-value cbi-value-last" id="cbi-omr-tracker-hosts" data-depends="[]" data-index="<%=table.getn(hosts)%>">
<label class="cbi-value-title" for="cbid.omr-tracker.hosts"><%:Domains%></label>
<label class="cbi-value-title" for="cbid.omr-tracker.hosts"><%:Domain, IP or network%></label>
<div class="cbi-value-field">
<div data-prefix="cbid.omr-bypass.hosts" data-browser-path="" data-dynlist="[[],[],null,false]" data-placeholder="google.com">
<%
local j = 1
for _ , host in pairs(hosts) do
%><%=host%><%
j = j+1
for hst in string.gmatch(host,"([^/]*)/") do
if hst ~= "" then
@ -30,6 +30,12 @@
end
end
end
for _ , ip in pairs(ips) do
j = j+1
%>
<input class="cbi-input-text" value="<%=ip%>" data-update="change" type="text" id="cbid.omr-bypass.hosts.<%=j%>" name="cbid.omr-bypass.hosts" placeholder="google.com" /><br />
<%
end
if j == 1 then
%>
<input class="cbi-input-text" value="" data-update="change" type="text" id="cbid.omr-bypass.hosts.1" name="cbid.omr-bypass.hosts" placeholder="google.com" /><br />

View file

@ -1,25 +1,31 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: Ycarus <ycarus@zugaina.org>\n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"Last-Translator: Ycarus <ycarus@zugaina.org>\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr\n"
msgid "Bypass"
msgstr "Contourne"
msgid "Domains"
msgstr "Domaines"
msgid "Domain, IP or network"
msgstr "Domaine, IP ou réseau"
msgid "OMR-Bypass"
msgstr ""
msgid "Set domains name you want to bypass."
msgstr "Configurer les domaines que vous voulez contourner."
msgid "Set domains name, ips or networks you want to bypass."
msgstr "Configurer les domaines, adresses IPs ou réseaux que vous voulez contourner."
#~ msgid "Domains"
#~ msgstr "Domaines"
#~ msgid "Set domains name you want to bypass."
#~ msgstr "Configurer les domaines que vous voulez contourner."

View file

@ -4,11 +4,11 @@ msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Bypass"
msgstr ""
msgid "Domains"
msgid "Domain, IP or network"
msgstr ""
msgid "OMR-Bypass"
msgstr ""
msgid "Set domains name you want to bypass."
msgid "Set domains name, ips or networks you want to bypass."
msgstr ""

View file

@ -0,0 +1 @@
config bypass 'ips'

View file

@ -0,0 +1,29 @@
#!/bin/sh /etc/rc.common
# shellcheck disable=SC2039
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
# shellcheck disable=SC2034
{
START=90
STOP=10
USE_PROCD=1
}
_bypass_ip() {
local ip="$1"
ipset add ss_rules_dst_bypass $ip
}
start_service() {
config_load omr-bypass
config_list_foreach ips "ip" _bypass_ip
}
service_triggers() {
procd_add_reload_trigger omr-bypass shadowsocks-libev
}
reload_service() {
stop
start
}

View file

@ -0,0 +1,11 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@omr-bypass[-1]
add ucitrack omr-bypass
set ucitrack.@omr-bypass[-1].init=omr-bypass
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0