Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luci-app-passwall: bump to 24.12.17 #482

Merged
merged 23 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c974866
luci-app-passwall: fix xray SniffingObject generate
SakuraFallingMad Dec 11, 2024
7dd2359
luci-app-passwall: Fix incomplete import Trojan URL
SakuraFallingMad Dec 11, 2024
169c684
luci-app-passwall: Xray ws Forbid "host" in headers, read serverName …
SakuraFallingMad Dec 12, 2024
a6a6f79
luci-app-passwall: optimize and fix code
SakuraFallingMad Dec 13, 2024
34081b2
luci-app-passwall: optimize and improve
SakuraFallingMad Dec 13, 2024
85f1bbf
luci-app-passwall: dynamically read rule list
SakuraFallingMad Dec 13, 2024
13d1449
luci-app-passwall: fix Xray TCP DNS port
SakuraFallingMad Dec 13, 2024
1e65b55
luci-app-passwall: some page detail optimize
SakuraFallingMad Dec 14, 2024
8659a12
luci-app-passwall: optimize and fix DNS leak
SakuraFallingMad Dec 15, 2024
7db94d6
luci-app-passwall: improve
SakuraFallingMad Dec 15, 2024
8100885
luci-app-passwall: fix error sync upstream files
SakuraFallingMad Dec 15, 2024
f60b2a3
luci-app-passwall: optimize and improve
SakuraFallingMad Dec 15, 2024
c57467c
luci-app-passwall: Fix import error when VLESS subscribe link encrypt…
SakuraFallingMad Dec 15, 2024
d5e7a80
luci-app-passwall: add missing code
SakuraFallingMad Dec 16, 2024
fe0aa68
luci-app-passwall: add DNS Redirect option
SakuraFallingMad Dec 16, 2024
9a606e7
luci-app-passwall: optimize code
SakuraFallingMad Dec 16, 2024
5e7c3b9
luci-app-passwall: add preproxy option for Xray/Sing-Box node
SakuraFallingMad Dec 16, 2024
f434a5f
luci-app-passwall: update some configuration logic
SakuraFallingMad Dec 16, 2024
63ee615
luci-app-passwall: optimize code
SakuraFallingMad Dec 16, 2024
9d6dca5
luci-app-passwall: fix nftables DNS Redirect code
SakuraFallingMad Dec 16, 2024
9621c51
luci-app-passwall: bump to 24.12.17
SakuraFallingMad Dec 17, 2024
6f71598
luci-app-passwall: fix variable error
SakuraFallingMad Dec 17, 2024
851b11c
luci-app-passwall: 24.12.17-r2 release
SakuraFallingMad Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions applications/luci-app-passwall/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-passwall
PKG_VERSION:=24.12.08
PKG_RELEASE:=1
PKG_VERSION:=24.12.17
PKG_RELEASE:=2

PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy \
Expand Down
54 changes: 42 additions & 12 deletions applications/luci-app-passwall/luasrc/controller/passwall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ function index()
entry({"admin", "services", appname, "delete_select_nodes"}, call("delete_select_nodes")).leaf = true
entry({"admin", "services", appname, "update_rules"}, call("update_rules")).leaf = true

--[[rule_list]]
entry({"admin", "services", appname, "read_gfwlist"}, call("read_rulelist", "gfw")).leaf = true
entry({"admin", "services", appname, "read_chnlist"}, call("read_rulelist", "chn")).leaf = true
entry({"admin", "services", appname, "read_chnroute"}, call("read_rulelist", "chnroute")).leaf = true

--[[Components update]]
entry({"admin", "services", appname, "check_passwall"}, call("app_check")).leaf = true
local coms = require "luci.passwall.com"
Expand Down Expand Up @@ -161,13 +166,13 @@ end
function get_now_use_node()
local path = "/tmp/etc/passwall/acl/default"
local e = {}
local data, code, msg = nixio.fs.readfile(path .. "/TCP.id")
if data then
e["TCP"] = util.trim(data)
local tcp_node = api.get_cache_var("GLOBAL_TCP_node")
if tcp_node then
e["TCP"] = tcp_node
end
local data, code, msg = nixio.fs.readfile(path .. "/UDP.id")
if data then
e["UDP"] = util.trim(data)
local udp_node = api.get_cache_var("GLOBAL_UDP_node")
if udp_node then
e["UDP"] = udp_node
end
luci.http.prepare_content("application/json")
luci.http.write_json(e)
Expand Down Expand Up @@ -264,8 +269,8 @@ function connect_status()
local chn_list = uci:get(appname, "@global[0]", "chn_list") or "direct"
local gfw_list = uci:get(appname, "@global[0]", "use_gfw_list") or "1"
local proxy_mode = uci:get(appname, "@global[0]", "tcp_proxy_mode") or "proxy"
local socks_server = luci.sys.exec("[ -f /tmp/etc/passwall/acl/default/TCP_SOCKS_server ] && echo -n $(cat /tmp/etc/passwall/acl/default/TCP_SOCKS_server) || echo -n ''")
if socks_server ~= "" then
local socks_server = api.get_cache_var("GLOBAL_TCP_SOCKS_server")
if socks_server and socks_server ~= "" then
if (chn_list == "proxy" and gfw_list == "0" and proxy_mode ~= "proxy" and baidu ~= nil) or (chn_list == "0" and gfw_list == "0" and proxy_mode == "proxy") then
-- 中国列表+百度 or 全局
url = "-x socks5h://" .. socks_server .. " " .. url
Expand Down Expand Up @@ -369,8 +374,8 @@ function clear_all_nodes()
uci:delete(appname, t[".name"])
end)
uci:foreach(appname, "acl_rule", function(t)
uci:set(appname, t[".name"], "tcp_node", "default")
uci:set(appname, t[".name"], "udp_node", "default")
uci:set(appname, t[".name"], "tcp_node", "nil")
uci:set(appname, t[".name"], "udp_node", "nil")
end)
uci:foreach(appname, "nodes", function(node)
uci:delete(appname, node['.name'])
Expand Down Expand Up @@ -408,10 +413,20 @@ function delete_select_nodes()
end)
uci:foreach(appname, "acl_rule", function(t)
if t["tcp_node"] == w then
uci:set(appname, t[".name"], "tcp_node", "default")
uci:set(appname, t[".name"], "tcp_node", "nil")
end
if t["udp_node"] == w then
uci:set(appname, t[".name"], "udp_node", "default")
uci:set(appname, t[".name"], "udp_node", "nil")
end
end)
uci:foreach(appname, "nodes", function(t)
if t["preproxy_node"] == w then
uci:delete(appname, t[".name"], "preproxy_node")
uci:delete(appname, t[".name"], "chain_proxy")
end
if t["to_node"] == w then
uci:delete(appname, t[".name"], "to_node")
uci:delete(appname, t[".name"], "chain_proxy")
end
end)
uci:delete(appname, w)
Expand Down Expand Up @@ -475,3 +490,18 @@ function com_update(comname)

http_write_json(json)
end

function read_rulelist(list)
local rule_path
if list == "gfw" then
rule_path = "/usr/share/passwall/rules/gfwlist"
elseif list == "chn" then
rule_path = "/usr/share/passwall/rules/chnlist"
else
rule_path = "/usr/share/passwall/rules/chnroute"
end
if api.fs.access(rule_path) then
luci.http.prepare_content("text/plain")
luci.http.write(api.fs.readfile(rule_path))
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,9 @@ if api.is_finded("smartdns") then
o:depends({dns_shunt = "smartdns", tcp_proxy_mode = "proxy", chn_list = "direct"})
end

o = s:taboption("DNS", Flag, "dns_redirect", "DNS " .. translate("Redirect"), translate("Force Router DNS server to all local devices."))
o.default = "0"
o = s:taboption("DNS", Flag, "dns_redirect", translate("DNS Redirect"), translate("Force special DNS server to need proxy devices."))
o.default = "1"
o.rmempty = false

if (uci:get(appname, "@global_forwarding[0]", "use_nft") or "0") == "1" then
o = s:taboption("DNS", Button, "clear_ipset", translate("Clear NFTSET"), translate("Try this feature if the rule modification does not take effect."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ if has_xray then

o = s_xray:option(Flag, "sniffing_override_dest", translate("Override the connection destination address"))
o.default = 0
o.description = translate("Override the connection destination address with the sniffed domain.<br />When enabled, traffic will match only by domain, ignoring IP rules.<br />If using shunt nodes, configure the domain shunt rules correctly.")
o.description = translate("Override the connection destination address with the sniffed domain.<br />Otherwise use sniffed domain for routing only.<br />If using shunt nodes, configure the domain shunt rules correctly.")

local domains_excluded = string.format("/usr/share/%s/rules/domains_excluded", appname)
o = s_xray:option(TextValue, "excluded_domains", translate("Excluded Domains"), translate("If the traffic sniffing result is in this list, the destination address will not be overridden."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,71 +273,41 @@ end

if api.fs.access(gfwlist_path) then
s:tab("gfw_list", translate("GFW List"))
o = s:taboption("gfw_list", TextValue, "gfw_list", "")
o.readonly = true
o.rows = 45
o.wrap = "off"
o.cfgvalue = function(self, section)
local limit = 100 -- 限制行数
local cmd = string.format("head -n %d %s", limit, gfwlist_path)
return api.sys.exec(cmd) or ""
-- return fs.readfile(gfwlist_path) or ""
end
local total_lines_cmd = string.format("wc -l < %s", gfwlist_path)
local total_lines = tonumber(api.sys.exec(total_lines_cmd)) or 0
local displayed_lines = 100

local total_lines_label = s:taboption("gfw_list", DummyValue, "total_lines", translate("Total Lines"))
total_lines_label.value = translatef("%d lines", total_lines)

local displayed_lines_label = s:taboption("gfw_list", DummyValue, "displayed_lines", translate("Displayed Lines"))
displayed_lines_label.value = translatef("%d lines", displayed_lines)
o = s:taboption("gfw_list", DummyValue, "_gfw_fieldset")
o.rawhtml = true
o.default = string.format([[
<div style="display: flex; align-items: center;">
<input class="btn cbi-button cbi-button-add" type="button" onclick="read_gfw()" value="%s" />
<label id="gfw_total_lines" style="margin-left: auto; margin-right: 10px;"></label>
</div>
<textarea id="gfw_textarea" class="cbi-input-textarea" style="width: 100%%; margin-top: 10px;" rows="40" wrap="off" readonly="readonly"></textarea>
]], translate("Read List"))
end

if api.fs.access(chnlist_path) then
s:tab("chn_list", translate("China List") .. "(" .. translate("Domain") .. ")")
o = s:taboption("chn_list", TextValue, "chn_list", "")
o.readonly = true
o.rows = 45
o.wrap = "off"
o.cfgvalue = function(self, section)
local limit = 100 -- 限制行数
local cmd = string.format("head -n %d %s", limit, chnlist_path)
return api.sys.exec(cmd) or ""
-- return fs.readfile(chnlist_path) or ""
end
local total_lines_cmd = string.format("wc -l < %s", chnlist_path)
local total_lines = tonumber(api.sys.exec(total_lines_cmd)) or 0
local displayed_lines = 100

local total_lines_label = s:taboption("chn_list", DummyValue, "total_lines", translate("Total Lines"))
total_lines_label.value = translatef("%d lines", total_lines)

local displayed_lines_label = s:taboption("chn_list", DummyValue, "displayed_lines", translate("Displayed Lines"))
displayed_lines_label.value = translatef("%d lines", displayed_lines)
o = s:taboption("chn_list", DummyValue, "_chn_fieldset")
o.rawhtml = true
o.default = string.format([[
<div style="display: flex; align-items: center;">
<input class="btn cbi-button cbi-button-add" type="button" onclick="read_chn()" value="%s" />
<label id="chn_total_lines" style="margin-left: auto; margin-right: 10px;"></label>
</div>
<textarea id="chn_textarea" class="cbi-input-textarea" style="width: 100%%; margin-top: 10px;" rows="40" wrap="off" readonly="readonly"></textarea>
]], translate("Read List"))
end

if api.fs.access(chnroute_path) then
s:tab("chnroute_list", translate("China List") .. "(IP)")
o = s:taboption("chnroute_list", TextValue, "chnroute_list", "")
o.readonly = true
o.rows = 45
o.wrap = "off"
o.cfgvalue = function(self, section)
local limit = 100 -- 限制行数
local cmd = string.format("head -n %d %s", limit, chnroute_path)
return api.sys.exec(cmd) or ""
-- return fs.readfile(chnroute_path) or ""
end
local total_lines_cmd = string.format("wc -l < %s", chnroute_path)
local total_lines = tonumber(api.sys.exec(total_lines_cmd)) or 0
local displayed_lines = 100

local total_lines_label = s:taboption("chnroute_list", DummyValue, "total_lines", translate("Total Lines"))
total_lines_label.value = translatef("%d lines", total_lines)

local displayed_lines_label = s:taboption("chnroute_list", DummyValue, "displayed_lines", translate("Displayed Lines"))
displayed_lines_label.value = translatef("%d lines", displayed_lines)
o = s:taboption("chnroute_list", DummyValue, "_chnroute_fieldset")
o.rawhtml = true
o.default = string.format([[
<div style="display: flex; align-items: center;">
<input class="btn cbi-button cbi-button-add" type="button" onclick="read_chnroute()" value="%s" />
<label id="chnroute_total_lines" style="margin-left: auto; margin-right: 10px;"></label>
</div>
<textarea id="chnroute_textarea" class="cbi-input-textarea" style="width: 100%%; margin-top: 10px;" rows="40" wrap="off" readonly="readonly"></textarea>
]], translate("Read List"))
end

m:append(Template(appname .. "/rule_list/js"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ o.default = 1
o.rmempty = false

local auto_switch_tip
local current_node_file = string.format("/tmp/etc/%s/id/socks_%s", appname, arg[1])
local current_node = luci.sys.exec(string.format("[ -f '%s' ] && echo -n $(cat %s)", current_node_file, current_node_file))
if current_node and current_node ~= "" and current_node ~= "nil" then
local current_node = api.get_cache_var("socks_" .. arg[1])
if current_node then
local n = uci:get_all(appname, current_node)
if n then
if tonumber(m:get(arg[1], "enable_autoswitch") or 0) == 1 then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,20 +646,34 @@ o.default = 0
o = s:option(Flag, option_name("tcpNoDelay"), "tcpNoDelay")
o.default = 0

o = s:option(ListValue, option_name("to_node"), translate("Landing node"), translate("Only support a layer of proxy."))
o.default = ""
o = s:option(ListValue, option_name("chain_proxy"), translate("Chain Proxy"))
o:value("", translate("Close(Not use)"))
o:value("1", translate("Preproxy Node"))
o:value("2", translate("Landing Node"))
for i, v in ipairs(s.fields[option_name("protocol")].keylist) do
if not v:find("_") then
o:depends({ [option_name("protocol")] = v })
end
end

o = s:option(ListValue, option_name("preproxy_node"), translate("Preproxy Node"), translate("Only support a layer of proxy."))
o:depends({ [option_name("chain_proxy")] = "1" })

o = s:option(ListValue, option_name("to_node"), translate("Landing Node"), translate("Only support a layer of proxy."))
o:depends({ [option_name("chain_proxy")] = "2" })

for k, v in pairs(nodes_table) do
if v.type == "Xray" then
o:value(v.id, v.remark)
if v.type == "Xray" and v.id ~= arg[1] then
s.fields[option_name("preproxy_node")]:value(v.id, v.remark)
s.fields[option_name("to_node")]:value(v.id, v.remark)
end
end

for i, v in ipairs(s.fields[option_name("protocol")].keylist) do
if not v:find("_") then
s.fields[option_name("tcpMptcp")]:depends({ [option_name("protocol")] = v })
s.fields[option_name("tcpNoDelay")]:depends({ [option_name("protocol")] = v })
s.fields[option_name("to_node")]:depends({ [option_name("protocol")] = v })
s.fields[option_name("chain_proxy")]:depends({ [option_name("protocol")] = v })
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,27 @@ o:depends({ [option_name("protocol")] = "vless" })
o:depends({ [option_name("protocol")] = "tuic" })
o:depends({ [option_name("protocol")] = "hysteria2" })

o = s:option(ListValue, option_name("to_node"), translate("Landing node"), translate("Only support a layer of proxy."))
o.default = ""
o = s:option(ListValue, option_name("chain_proxy"), translate("Chain Proxy"))
o:value("", translate("Close(Not use)"))
for k, v in pairs(nodes_table) do
if v.type == "sing-box" then
o:value(v.id, v.remark)
end
end
o:value("1", translate("Preproxy Node"))
o:value("2", translate("Landing Node"))
for i, v in ipairs(s.fields[option_name("protocol")].keylist) do
if not v:find("_") then
o:depends({ [option_name("protocol")] = v })
end
end

o = s:option(ListValue, option_name("preproxy_node"), translate("Preproxy Node"), translate("Only support a layer of proxy."))
o:depends({ [option_name("chain_proxy")] = "1" })

o = s:option(ListValue, option_name("to_node"), translate("Landing Node"), translate("Only support a layer of proxy."))
o:depends({ [option_name("chain_proxy")] = "2" })

for k, v in pairs(nodes_table) do
if v.type == "sing-box" and v.id ~= arg[1] then
s.fields[option_name("preproxy_node")]:value(v.id, v.remark)
s.fields[option_name("to_node")]:value(v.id, v.remark)
end
end

api.luci_types(arg[1], m, s, type_name, option_prefix)
18 changes: 15 additions & 3 deletions applications/luci-app-passwall/luasrc/passwall/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ OPENWRT_ARCH = nil
DISTRIB_ARCH = nil
OPENWRT_BOARD = nil

LOG_FILE = "/tmp/log/" .. appname .. ".log"
CACHE_PATH = "/tmp/etc/" .. appname .. "_tmp"
LOG_FILE = "/tmp/log/" .. appname .. ".log"
TMP_PATH = "/tmp/etc/" .. appname
TMP_IFACE_PATH = TMP_PATH .. "/iface"

function log(...)
local result = os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({...}, " ")
Expand All @@ -28,6 +30,16 @@ function log(...)
end
end

function set_cache_var(key, val)
sys.call(string.format('/usr/share/passwall/app.sh set_cache_var %s "%s"', key, val))
end

function get_cache_var(key)
local val = sys.exec(string.format('echo -n $(/usr/share/passwall/app.sh get_cache_var %s)', key))
if val == "" then val = nil end
return val
end

function exec_call(cmd)
local process = io.popen(cmd .. '; echo -e "\n$?"')
local lines = {}
Expand Down Expand Up @@ -97,8 +109,8 @@ end

function curl_proxy(url, file, args)
--使用代理
local socks_server = luci.sys.exec("[ -f /tmp/etc/passwall/acl/default/TCP_SOCKS_server ] && echo -n $(cat /tmp/etc/passwall/acl/default/TCP_SOCKS_server) || echo -n ''")
if socks_server ~= "" then
local socks_server = get_cache_var("GLOBAL_TCP_SOCKS_server")
if socks_server and socks_server ~= "" then
if not args then args = {} end
local tmp_args = clone(args)
tmp_args[#tmp_args + 1] = "-x socks5h://" .. socks_server
Expand Down
Loading
Loading