From 9e4b4d7fdcb4a99dd59b6c9432198689147c1632 Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Sat, 9 Sep 2023 20:54:11 +0800 Subject: [PATCH] luci: fix know bugs --- luci-app-passwall2/luasrc/passwall2/api.lua | 6 +- .../luasrc/passwall2/util_sing-box.lua | 17 +- .../passwall2/node_list/link_share_man.htm | 156 +++++++++--------- .../root/etc/uci-defaults/luci-passwall2 | 2 + .../root/usr/share/passwall2/subscribe.lua | 6 +- 5 files changed, 102 insertions(+), 85 deletions(-) diff --git a/luci-app-passwall2/luasrc/passwall2/api.lua b/luci-app-passwall2/luasrc/passwall2/api.lua index db13b2601..f74f6770d 100644 --- a/luci-app-passwall2/luasrc/passwall2/api.lua +++ b/luci-app-passwall2/luasrc/passwall2/api.lua @@ -384,7 +384,11 @@ end function finded_com(e) local bin = get_app_path(e) if not bin then return end - return luci.sys.exec('echo -n $(type -t -p "%s" | head -n1)' % { bin }) + local s = luci.sys.exec('echo -n $(type -t -p "%s" | head -n1)' % { bin }) + if s == "" then + s = nil + end + return s end function finded(e) diff --git a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua index d83f9e5d3..7b80750e8 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua @@ -1129,6 +1129,7 @@ function gen_config(var) tag = dns_tag, address_strategy = "prefer_ipv4", strategy = remote_strategy, + address_resolver = "direct", detour = dns_outTag, } @@ -1147,7 +1148,9 @@ function gen_config(var) server.address = remote_dns_doh_url end - table.insert(dns.servers, server) + if server.address then + table.insert(dns.servers, server) + end if remote_dns_fake then dns.fakeip = { @@ -1155,14 +1158,20 @@ function gen_config(var) inet4_range = "198.18.0.0/16", inet6_range = "fc00::/18", } - + + local fakedns_tag = dns_tag .. "_fakeip" + + if not server.address then + fakedns_tag = dns_tag + end + table.insert(dns.servers, { - tag = dns_tag .. "_fakeip", + tag = fakedns_tag, address = "fakeip", strategy = remote_strategy, }) - rule_server = dns_tag .. "_fakeip" + rule_server = fakedns_tag if tags and tags:find("with_clash_api") then if not experimental then diff --git a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm index e920c3898..a6224ddc8 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm @@ -1,10 +1,11 @@ <%+cbi/valueheader%> <% local api = require "luci.passwall2.api" -local has_singbox = api.finded_com("singbox") -local has_xray = api.finded_com("xray") -%>