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:
parent
1bdb327224
commit
602aa8a127
7 changed files with 83 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
||||||
local ucic = luci.model.uci.cursor()
|
local ucic = luci.model.uci.cursor()
|
||||||
|
local dt = require "luci.cbi.datatypes"
|
||||||
module("luci.controller.omr-bypass", package.seeall)
|
module("luci.controller.omr-bypass", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
|
@ -12,16 +13,29 @@ function bypass_add()
|
||||||
if (type(hosts) ~= "table") then
|
if (type(hosts) ~= "table") then
|
||||||
hosts = {hosts}
|
hosts = {hosts}
|
||||||
end
|
end
|
||||||
local ipset = ""
|
local domains_ipset = ""
|
||||||
|
local ip_ipset = {}
|
||||||
for _, k in pairs(hosts) do
|
for _, k in pairs(hosts) do
|
||||||
if k ~= "" then
|
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
|
||||||
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:save("dhcp")
|
||||||
ucic:commit("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"))
|
luci.http.redirect(luci.dispatcher.build_url("admin/services/omr-bypass"))
|
||||||
return
|
return
|
||||||
end
|
end
|
|
@ -5,6 +5,7 @@
|
||||||
<%
|
<%
|
||||||
local uci = require("luci.model.uci").cursor()
|
local uci = require("luci.model.uci").cursor()
|
||||||
local hosts = uci:get_list("dhcp", uci:get_first("dhcp","dnsmasq"), "ipset")
|
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 %>
|
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
|
||||||
|
@ -12,15 +13,14 @@
|
||||||
<div class="cbi-map">
|
<div class="cbi-map">
|
||||||
<h2 name="content"><%:Bypass%></h2>
|
<h2 name="content"><%:Bypass%></h2>
|
||||||
<fieldset class="cbi-section" id="hosts">
|
<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)%>">
|
<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 class="cbi-value-field">
|
||||||
<div data-prefix="cbid.omr-bypass.hosts" data-browser-path="" data-dynlist="[[],[],null,false]" data-placeholder="google.com">
|
<div data-prefix="cbid.omr-bypass.hosts" data-browser-path="" data-dynlist="[[],[],null,false]" data-placeholder="google.com">
|
||||||
<%
|
<%
|
||||||
local j = 1
|
local j = 1
|
||||||
for _ , host in pairs(hosts) do
|
for _ , host in pairs(hosts) do
|
||||||
%><%=host%><%
|
|
||||||
j = j+1
|
j = j+1
|
||||||
for hst in string.gmatch(host,"([^/]*)/") do
|
for hst in string.gmatch(host,"([^/]*)/") do
|
||||||
if hst ~= "" then
|
if hst ~= "" then
|
||||||
|
@ -30,6 +30,12 @@
|
||||||
end
|
end
|
||||||
end
|
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
|
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 />
|
<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 />
|
||||||
|
|
|
@ -1,25 +1,31 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"POT-Creation-Date: \n"
|
"POT-Creation-Date: \n"
|
||||||
"PO-Revision-Date: \n"
|
"PO-Revision-Date: \n"
|
||||||
|
"Last-Translator: Ycarus <ycarus@zugaina.org>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
|
"Language: fr\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"X-Generator: Poedit 2.0.6\n"
|
"X-Generator: Poedit 2.0.6\n"
|
||||||
"Last-Translator: Ycarus <ycarus@zugaina.org>\n"
|
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
"Language: fr\n"
|
|
||||||
|
|
||||||
msgid "Bypass"
|
msgid "Bypass"
|
||||||
msgstr "Contourne"
|
msgstr "Contourne"
|
||||||
|
|
||||||
msgid "Domains"
|
msgid "Domain, IP or network"
|
||||||
msgstr "Domaines"
|
msgstr "Domaine, IP ou réseau"
|
||||||
|
|
||||||
msgid "OMR-Bypass"
|
msgid "OMR-Bypass"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Set domains name you want to bypass."
|
msgid "Set domains name, ips or networks you want to bypass."
|
||||||
msgstr "Configurer les domaines que vous voulez contourner."
|
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."
|
||||||
|
|
|
@ -4,11 +4,11 @@ msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||||
msgid "Bypass"
|
msgid "Bypass"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Domains"
|
msgid "Domain, IP or network"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "OMR-Bypass"
|
msgid "OMR-Bypass"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Set domains name you want to bypass."
|
msgid "Set domains name, ips or networks you want to bypass."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
1
luci-app-omr-bypass/root/etc/config/omr-bypass
Normal file
1
luci-app-omr-bypass/root/etc/config/omr-bypass
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config bypass 'ips'
|
29
luci-app-omr-bypass/root/etc/init.d/omr-bypass
Executable file
29
luci-app-omr-bypass/root/etc/init.d/omr-bypass
Executable 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
|
||||||
|
}
|
11
luci-app-omr-bypass/root/etc/uci-defaults/41_omr-bypass
Normal file
11
luci-app-omr-bypass/root/etc/uci-defaults/41_omr-bypass
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue