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 1411a56dd..fe5fa30db 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -82,66 +82,34 @@ local doh_validate = function(self, value, t) return value end end - return nil, translate("DoH request address") .. " " .. translate("Format must be:") .. " URL,IP" + return nil, translatef("%s request address","DoH") .. " " .. translate("Format must be:") .. " URL,IP" 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) + if s:sub(1, 6) ~= "tls://" then return false end + local address = s:sub(7) 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 + local ip, port + local domain = at_index and address:sub(1, at_index - 1) or nil + ip = at_index and address:sub(at_index + 1, (hash_index or 0) - 1) or address:sub(1, (hash_index or 0) - 1) + port = hash_index and address:sub(hash_index + 1) or nil + local num_port = tonumber(port) + if (port and (not num_port or num_port <= 0 or num_port >= 65536)) or + (domain and domain == "") or + (not datatypes.ipaddr(ip) and not datatypes.ip6addr(ip)) then return false end return true end - if value ~= "" then value = api.trim(value) if isValidDoTString(value) then return value end end - return nil, translate("Direct DNS") .. " DoT " .. translate("Format must be:") .. " tls://Domain@IP(#Port) or tls://IP(#Port)" + return nil, translatef("%s request address","DoT") .. " " .. translate("Format must be:") .. " tls://" .. translate("Domain") .. "@IP[#Port] | tls://IP[#Port]" end m:append(Template(appname .. "/global/status")) diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 723d13c74..962ad13b6 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -142,6 +142,9 @@ msgstr "配置不当" msgid "Make sure socks service is available on this address." msgstr "请确保此 Socks 服务可用。" +msgid "%s request address" +msgstr "%s 请求地址" + msgid "Format must be:" msgstr "格式必须为:" diff --git a/patch-luci-app-passwall.patch b/patch-luci-app-passwall.patch index d3eb63b30..c241946d2 100644 --- a/patch-luci-app-passwall.patch +++ b/patch-luci-app-passwall.patch @@ -24,10 +24,10 @@ index 03006a6..f384bbc 100644 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..1411a56 100644 +index 806095f..fe5fa30 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua -@@ -435,6 +435,12 @@ o:value("9.9.9.9", "9.9.9.9 (Quad9-Recommended)") +@@ -403,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)")