From abdeca1ff8e8cc4c9571b23788964fd945be4159 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Fri, 10 Apr 2020 01:07:41 +0800 Subject: [PATCH] luci-app-passwall: sync with upstream source --- package/lienol/luci-app-passwall/Makefile | 4 +- .../luasrc/controller/passwall.lua | 10 +- .../model/cbi/passwall/api/gen_v2ray.lua | 6 +- .../cbi/passwall/api/gen_v2ray_balancing.lua | 8 +- .../cbi/passwall/api/gen_v2ray_shunt.lua | 8 +- .../luasrc/model/cbi/passwall/global.lua | 20 +-- .../model/cbi/passwall/node_subscribe.lua | 4 + .../luasrc/model/cbi/passwall/other.lua | 21 +-- .../luasrc/view/passwall/global/status.htm | 24 +-- .../luasrc/view/passwall/global/status2.htm | 24 +-- .../view/passwall/node_list/node_list.htm | 8 +- .../luci-app-passwall/po/zh-cn/passwall.po | 22 ++- .../root/etc/config/passwall | 11 +- .../root/etc/uci-defaults/luci-app-passwall | 3 +- .../root/usr/share/passwall/app.sh | 153 +++++++----------- .../root/usr/share/passwall/config.default | 9 +- .../root/usr/share/passwall/iptables.sh | 4 +- .../root/usr/share/passwall/monitor.sh | 14 +- .../root/usr/share/passwall/subscribe.lua | 31 ++-- .../root/usr/share/passwall/test.sh | 33 ++-- 20 files changed, 205 insertions(+), 212 deletions(-) diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index 072fd9f99b..df4303141f 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=3.6 -PKG_RELEASE:=38 -PKG_DATE:=20200406 +PKG_RELEASE:=39 +PKG_DATE:=20200408 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua index ef070663ce..71c6ee56aa 100644 --- a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua +++ b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua @@ -149,17 +149,17 @@ function status() appname, i)) == 0 end - local socks5_node_num = luci.sys.exec( - "echo -n $(uci -q get %s.@global_other[0].socks5_node_num)" % + local socks_node_num = luci.sys.exec( + "echo -n $(uci -q get %s.@global_other[0].socks_node_num)" % appname) - for i = 1, socks5_node_num, 1 do + for i = 1, socks_node_num, 1 do e["kcptun_socks_node%s_status" % i] = luci.sys.call(string.format( "ps -w | grep -v grep | grep '%s/bin/' | grep 'kcptun_socks_%s' >/dev/null", appname, i)) == 0 - e["socks5_node%s_status" % i] = luci.sys.call( + e["socks_node%s_status" % i] = luci.sys.call( string.format( - "ps -w | grep -v grep | grep -v kcptun | grep '%s/bin/' | grep -i -E 'SOCKS_%s|SOCKS5_%s' >/dev/null", + "ps -w | grep -v grep | grep -v kcptun | grep '%s/bin/' | grep -i 'SOCKS_%s' >/dev/null", appname, i, i)) == 0 end luci.http.prepare_content("application/json") diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua index 6d44745638..20da449e07 100755 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua @@ -3,7 +3,7 @@ local json = require "luci.jsonc" local node_section = arg[1] local proto = arg[2] local redir_port = arg[3] -local socks5_proxy_port = arg[4] +local socks_proxy_port = arg[4] local node = ucursor:get_all("passwall", node_section) local inbounds = {} local outbounds = {} @@ -103,10 +103,10 @@ local function gen_outbound(node) return result end -if socks5_proxy_port ~= "nil" then +if socks_proxy_port ~= "nil" then table.insert(inbounds, { listen = "0.0.0.0", - port = socks5_proxy_port, + port = socks_proxy_port, protocol = "socks", settings = {auth = "noauth", udp = true, ip = "127.0.0.1"} }) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_balancing.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_balancing.lua index 40524ae44e..c7c6b4dd70 100755 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_balancing.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_balancing.lua @@ -4,7 +4,7 @@ local json = require "luci.jsonc" local node_section = arg[1] local proto = arg[2] local redir_port = arg[3] -local socks5_proxy_port = arg[4] +local socks_proxy_port = arg[4] local node = ucursor:get_all("passwall", node_section) local inbounds = {} local outbounds = {} @@ -27,7 +27,7 @@ local function gen_outbound(node) node.port = new_port sys.call(string.format( "/usr/share/passwall/app.sh gen_start_config %s %s %s %s %s %s", - node_id, new_port, "SOCKS5", + node_id, new_port, "SOCKS", "/var/etc/passwall/v2_balancing_" .. node_type .. "_" .. node_id .. ".json", "4", "127.0.0.1")) node.v2ray_protocol = "socks" @@ -121,10 +121,10 @@ local function gen_outbound(node) return result end -if socks5_proxy_port ~= "nil" then +if socks_proxy_port ~= "nil" then table.insert(inbounds, { listen = "0.0.0.0", - port = socks5_proxy_port, + port = socks_proxy_port, protocol = "socks", settings = {auth = "noauth", udp = true, ip = "127.0.0.1"} }) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_shunt.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_shunt.lua index c7335cea0e..2326208489 100755 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_shunt.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_shunt.lua @@ -4,7 +4,7 @@ local json = require "luci.jsonc" local node_section = arg[1] local proto = arg[2] local redir_port = arg[3] -local socks5_proxy_port = arg[4] +local socks_proxy_port = arg[4] local node = ucursor:get_all("passwall", node_section) local inbounds = {} local outbounds = {} @@ -27,7 +27,7 @@ local function gen_outbound(node, tag) node.port = new_port sys.call(string.format( "/usr/share/passwall/app.sh gen_start_config %s %s %s %s %s %s", - node_id, new_port, "SOCKS5", + node_id, new_port, "SOCKS", "/var/etc/passwall/v2_shunt_" .. node_type .. "_" .. node_id .. ".json", "4", "127.0.0.1")) node.v2ray_protocol = "socks" @@ -121,10 +121,10 @@ local function gen_outbound(node, tag) return result end -if socks5_proxy_port ~= "nil" then +if socks_proxy_port ~= "nil" then table.insert(inbounds, { listen = "0.0.0.0", - port = socks5_proxy_port, + port = socks_proxy_port, protocol = "socks", settings = {auth = "noauth", udp = true, ip = "127.0.0.1"} }) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua index 78ab289c89..a27605f548 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua @@ -88,18 +88,18 @@ for i = 1, udp_node_num, 1 do for _, key in pairs(key_table) do o:value(key, n[key]) end end ----- Socks5 Node -local socks5_node_num = tonumber(api.uci_get_type("global_other", - "socks5_node_num", 1)) -for i = 1, socks5_node_num, 1 do +---- Socks Node +local socks_node_num = tonumber(api.uci_get_type("global_other", + "socks_node_num", 1)) +for i = 1, socks_node_num, 1 do if i == 1 then - o = s:option(ListValue, "socks5_node" .. i, translate("Socks5 Node")) - -- o.description = translate("The client can use the router's Socks5 proxy.") + o = s:option(ListValue, "socks_node" .. i, translate("Socks Node")) + -- o.description = translate("The client can use the router's Socks proxy.") o:value("nil", translate("Close")) o:value("tcp", translate("Same as the tcp node")) else - o = s:option(ListValue, "socks5_node" .. i, - translate("Socks5 Node") .. " " .. i) + o = s:option(ListValue, "socks_node" .. i, + translate("Socks Node") .. " " .. i) o:value("nil", translate("Close")) end for _, key in pairs(key_table) do o:value(key, n[key]) end @@ -131,7 +131,7 @@ if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then end if is_finded("dns2socks") then o:value("dns2socks", - "dns2socks + " .. translate("Use Socks5 Node Resolve DNS")) + "dns2socks + " .. translate("Use Socks Node Resolve DNS")) end o:value("local_7913", translate("Use local port 7913 as DNS")) o:value("nonuse", translate("No patterns are used")) @@ -146,7 +146,7 @@ if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then end if is_finded("dns2socks") then o:value("dns2socks", - "dns2socks + " .. translate("Use Socks5 Node Resolve DNS")) + "dns2socks + " .. translate("Use Socks Node Resolve DNS")) end o:value("8.8.4.4,8.8.8.8", "8.8.4.4, 8.8.8.8 (Google DNS)") o:value("208.67.222.222,208.67.220.220", diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_subscribe.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_subscribe.lua index 3c741018a1..8d6b972e2c 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_subscribe.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_subscribe.lua @@ -52,6 +52,10 @@ function o.write(e, e) "log")) end +filter_enabled = s:option(Flag, "filter_enabled", translate("Filter keyword switch"), translate("When checked, below options can only be take effect.")) +o.default = 1 +o.rmempty = false + filter_keyword = s:option(DynamicList, "filter_keyword", translate("Filter keyword")) o = s:option(Flag, "filter_keyword_discarded", translate("Filter keyword discarded"), translate("When checked, the keywords in the list are discarded. Otherwise, it is not discarded.")) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/other.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/other.lua index 584690272a..7732738daf 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/other.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/other.lua @@ -1,6 +1,4 @@ -local fs = require "nixio.fs" -local net = require"luci.model.network".init() -local ifaces = require"luci.sys".net:devices() +local api = require "luci.model.cbi.passwall.api.api" m = Map("passwall") @@ -94,11 +92,14 @@ o:value("2", "2 " .. translate("Process")) o:value("3", "3 " .. translate("Process")) o:value("4", "4 " .. translate("Process")) ----- Socks5 Proxy Port -o = s:option(Value, "socks5_proxy_port", translate("Socks5 Proxy Port")) -o.datatype = "port" -o.default = 1081 -o.rmempty = true +---- Socks Proxy Port +local socks_node_num = tonumber(api.uci_get_type("global_other", + "socks_node_num", 1)) +for i = 1, socks_node_num, 1 do + o = s:option(Value, "socks_proxy_port" .. i, translate("Socks Proxy Port")) + o.datatype = "port" + o.default = "108" .. i +end ---- Proxy IPv6 o = s:option(Flag, "proxy_ipv6", translate("Proxy IPv6"), @@ -149,8 +150,8 @@ o:value("1") o:value("2") o:value("3") ----- Socks5 Node Number Option -o = s:option(ListValue, "socks5_node_num", "Socks5" .. translate("Node Number")) +---- Socks Node Number Option +o = s:option(ListValue, "socks_node_num", "Socks" .. translate("Node Number")) o.default = "1" o.rmempty = false o:value("1") diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm index 51207299c5..e609a7f7ff 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm @@ -13,7 +13,7 @@ end local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1) local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1) -local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1) +local socks_node_num = api.uci_get_type("global_other", "socks_node_num", 1) local status_show_check_port = api.uci_get_type("global_other", "status_show_check_port", 0) local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111", 0) @@ -142,7 +142,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
-

Socks5
<%:NOT RUNNING%>

+

Socks
<%:NOT RUNNING%>

@@ -327,26 +327,26 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md } } - var socks5_node_num = <%=socks5_node_num%>; - if (socks5_node_num >= 1) { - var status_socks5_node = document.getElementById('status_socks5_node'); - if (status_socks5_node) { - var text = 'Socks5
'; - if (socks5_node_num == 1) { - if (data["socks5_node1_status"]) + var socks_node_num = <%=socks_node_num%>; + if (socks_node_num >= 1) { + var status_socks_node = document.getElementById('status_socks_node'); + if (status_socks_node) { + var text = 'Socks
'; + if (socks_node_num == 1) { + if (data["socks_node1_status"]) text += '<%:RUNNING%>'; else text += '<%:NOT RUNNING%>'; } else { - for(var i = 0; i < socks5_node_num; i++) { + for(var i = 0; i < socks_node_num; i++) { var k = i + 1; - if (data["socks5_node" + k + "_status"]) + if (data["socks_node" + k + "_status"]) text += ''; else text += ' X'; } } - status_socks5_node.innerHTML = text; + status_socks_node.innerHTML = text; } } diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm index dd504d3153..f7827712b6 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm @@ -13,7 +13,7 @@ end local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1) local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1) -local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1) +local socks_node_num = api.uci_get_type("global_other", "socks_node_num", 1) local status_show_check_port = api.uci_get_type("global_other", "status_show_check_port", 0) local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111", 0) @@ -83,10 +83,10 @@ local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111",
-