diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 4b41cee..b3e867e 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -171,7 +171,6 @@ define Package/$(PKG_NAME)/conffiles /usr/share/passwall/rules/lanlist_ipv4 /usr/share/passwall/rules/lanlist_ipv6 /usr/share/passwall/rules/domains_excluded -/www/luci-static/resources/qrcode.min.js endef include $(TOPDIR)/feeds/luci/luci.mk diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua index 6a38b20..be9dd12 100644 --- a/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua @@ -260,12 +260,12 @@ function connect_status() local socks_port = uci:get(appname, "@global[0]", "tcp_node_socks_port") if enabled ~= 0 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 - url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url + url = "--socks5 127.0.0.1:" .. socks_port .. " " .. url elseif baidu == nil then - url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url + url = "--socks5 127.0.0.1:" .. socks_port .. " " .. url end end - local result = luci.sys.exec('curl --connect-timeout 3 -o /dev/null -I -sk -w "%{http_code}:%{time_appconnect}" ' .. url) + local result = luci.sys.exec('curl --connect-timeout 3 -o /dev/null -I -sk -w "%{http_code}:%{time_starttransfer}" ' .. url) local code = tonumber(luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $1}'") or "0") if code ~= 0 then local use_time = luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $2}'") diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua index 6df0021..20b594c 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -86,62 +86,32 @@ local doh_validate = function(self, value, t) end local chinadns_dot_validate = function(self, value, t) - local function isValidDoTString(s) - local prefix = "tls://" - if s:sub(1, #prefix) ~= prefix then - return false - end - local address = s:sub(#prefix + 1) - local at_index = address:find("@") - local hash_index = address:find("#") - local domain, ip, port - if at_index then - if hash_index then - domain = address:sub(1, at_index - 1) - ip = address:sub(at_index + 1, hash_index - 1) - port = address:sub(hash_index + 1) - else - domain = address:sub(1, at_index - 1) - ip = address:sub(at_index + 1) - port = nil - end - else - if hash_index then - ip = address:sub(1, hash_index - 1) - port = address:sub(hash_index + 1) - else - ip = address - port = nil - end - end - local function isValidPort(port) - if not port then return true end - local num = tonumber(port) - return num and num > 0 and num < 65536 - end - local function isValidDomain(domain) - if not domain then return true end - return #domain > 0 - end - local function isValidIP(ip) - return datatypes.ipaddr(ip) or datatypes.ip6addr(ip) - end - if not isValidIP(ip) or not isValidPort(port) then - return false - end - if not isValidDomain(domain) then - return false - end - return true - end - if value ~= "" then value = api.trim(value) - if isValidDoTString(value) then - return value + -- Define patterns for IPv4, IPv6, domain, and port + local ipv4_pattern = "(%d+%.%d+%.%d+%.%d+)" + local ipv6_pattern = "([%[%]a-fA-F0-9:]+)" -- IPv6 addresses are wrapped in [] + local domain_pattern = "([%w-_%.]+)" + local port_pattern = "(%d+)" + -- Define patterns for the different formats + local patterns = { + "^tls://" .. domain_pattern .. "@" .. ipv4_pattern .. "#" .. port_pattern .. "$", -- tls://域名@ip#端口 + "^tls://" .. ipv4_pattern .. "#" .. port_pattern .. "$", -- tls://ip#端口 + "^tls://" .. domain_pattern .. "@" .. ipv4_pattern .. "$", -- tls://域名@ip + "^tls://" .. ipv4_pattern .. "$", -- tls://ip + "^tls://" .. domain_pattern .. "@" .. ipv6_pattern .. "#" .. port_pattern .. "$", -- tls://域名@[IPv6]#端口 + "^tls://" .. ipv6_pattern .. "#" .. port_pattern .. "$", -- tls://[IPv6]#端口 + "^tls://" .. domain_pattern .. "@" .. ipv6_pattern .. "$", -- tls://域名@[IPv6] + "^tls://" .. ipv6_pattern .. "$" -- tls://[IPv6] + } + -- Check if the string matches any of the patterns + for _, pattern in ipairs(patterns) do + if value:match(pattern) then + return value + end end + return nil, translate("Direct DNS") .. " DoT " .. translate("Format must be:") .. " tls://Domain@IP(#Port) or tls://IP(#Port)" end - return nil, translate("Direct DNS") .. " DoT " .. translate("Format must be:") .. " tls://Domain@IP(#Port) or tls://IP(#Port)" end m:append(Template(appname .. "/global/status")) @@ -328,10 +298,10 @@ dns_shunt:value("chinadns-ng", "Dnsmasq + ChinaDNS-NG") o = s:taboption("DNS", ListValue, "direct_dns_mode", translate("Direct DNS") .. " " .. translate("Request protocol")) o.default = "" o:value("", translate("Auto")) -o:value("udp", translatef("Requery DNS By %s", "UDP")) -o:value("tcp", translatef("Requery DNS By %s", "TCP")) +o:value("udp", "UDP") +o:value("tcp", "TCP") if os.execute("chinadns-ng -V | grep -i wolfssl >/dev/null") == 0 then - o:value("dot", translatef("Requery DNS By %s", "DoT")) + o:value("dot", "DoT") end --TO DO --o:value("doh", "DoH") @@ -364,8 +334,6 @@ o:value("tls://dot.pub@1.12.12.12") o:value("tls://dot.pub@120.53.53.53") o:value("tls://dot.360.cn@36.99.170.86") o:value("tls://dot.360.cn@101.198.191.4") -o:value("tls://dns.alidns.com@2400:3200::1") -o:value("tls://dns.alidns.com@2400:3200:baba::1") o.validate = chinadns_dot_validate o:depends("direct_dns_mode", "dot") @@ -435,6 +403,12 @@ o:value("9.9.9.9", "9.9.9.9 (Quad9-Recommended)") o:value("149.112.112.112", "149.112.112.112 (Quad9-Recommended)") o:value("208.67.220.220", "208.67.220.220 (OpenDNS)") o:value("208.67.222.222", "208.67.222.222 (OpenDNS)") +if nixio.fs.access("/usr/share/mosdns/mosdns.sh") then + local mosdns_port = string.gsub(luci.sys.exec("uci -q get mosdns.config.listen_port"), "\n", "") + if mosdns_port ~= nil and result ~= "" then + o:value("127.0.0.1:" .. mosdns_port, "127.0.0.1:" .. mosdns_port .. " (MosDNS)") + end +end o:depends({dns_mode = "dns2socks"}) o:depends({dns_mode = "tcp"}) o:depends({dns_mode = "udp"}) diff --git a/luci-app-passwall/luasrc/view/passwall/app_update/app_version.htm b/luci-app-passwall/luasrc/view/passwall/app_update/app_version.htm index c49ab6f..1591b79 100644 --- a/luci-app-passwall/luasrc/view/passwall/app_update/app_version.htm +++ b/luci-app-passwall/luasrc/view/passwall/app_update/app_version.htm @@ -177,12 +177,10 @@ local version = {}
-
- 【 <%=api.get_version()%> 】 - - -
+ 【 <%=api.get_version()%> 】 + +
@@ -193,12 +191,10 @@ local version = {} <%:Version%>
-
- 【 <%=version[k] ~="" and version[k] or translate("Null") %> 】 - - -
+ 【 <%=version[k] ~="" and version[k] or translate("Null") %> 】 + +
<%end%> diff --git a/luci-app-passwall/luasrc/view/passwall/global/status.htm b/luci-app-passwall/luasrc/view/passwall/global/status.htm index 00f79ff..452d369 100644 --- a/luci-app-passwall/luasrc/view/passwall/global/status.htm +++ b/luci-app-passwall/luasrc/view/passwall/global/status.htm @@ -1,5 +1,11 @@ <% local api = require "luci.passwall.api" +local fs = require "nixio.fs" +local uci = require 'luci.model.uci'.cursor() +local mode = 'normal' +if fs.access('/etc/config/argon') then + mode = uci:get_first('argon', 'global', 'mode') +end -%>