mirror of
https://github.com/kenzok8/small.git
synced 2025-01-09 04:29:21 +08:00
update 2024-09-01 20:20:56
This commit is contained in:
parent
f087c95d4d
commit
74ff301348
@ -82,66 +82,34 @@ local doh_validate = function(self, value, t)
|
|||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
local chinadns_dot_validate = function(self, value, t)
|
local chinadns_dot_validate = function(self, value, t)
|
||||||
local function isValidDoTString(s)
|
local function isValidDoTString(s)
|
||||||
local prefix = "tls://"
|
if s:sub(1, 6) ~= "tls://" then return false end
|
||||||
if s:sub(1, #prefix) ~= prefix then
|
local address = s:sub(7)
|
||||||
return false
|
|
||||||
end
|
|
||||||
local address = s:sub(#prefix + 1)
|
|
||||||
local at_index = address:find("@")
|
local at_index = address:find("@")
|
||||||
local hash_index = address:find("#")
|
local hash_index = address:find("#")
|
||||||
local domain, ip, port
|
local ip, port
|
||||||
if at_index then
|
local domain = at_index and address:sub(1, at_index - 1) or nil
|
||||||
if hash_index then
|
ip = at_index and address:sub(at_index + 1, (hash_index or 0) - 1) or address:sub(1, (hash_index or 0) - 1)
|
||||||
domain = address:sub(1, at_index - 1)
|
port = hash_index and address:sub(hash_index + 1) or nil
|
||||||
ip = address:sub(at_index + 1, hash_index - 1)
|
local num_port = tonumber(port)
|
||||||
port = address:sub(hash_index + 1)
|
if (port and (not num_port or num_port <= 0 or num_port >= 65536)) or
|
||||||
else
|
(domain and domain == "") or
|
||||||
domain = address:sub(1, at_index - 1)
|
(not datatypes.ipaddr(ip) and not datatypes.ip6addr(ip)) then
|
||||||
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
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if value ~= "" then
|
if value ~= "" then
|
||||||
value = api.trim(value)
|
value = api.trim(value)
|
||||||
if isValidDoTString(value) then
|
if isValidDoTString(value) then
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
m:append(Template(appname .. "/global/status"))
|
m:append(Template(appname .. "/global/status"))
|
||||||
|
@ -142,6 +142,9 @@ msgstr "配置不当"
|
|||||||
msgid "Make sure socks service is available on this address."
|
msgid "Make sure socks service is available on this address."
|
||||||
msgstr "请确保此 Socks 服务可用。"
|
msgstr "请确保此 Socks 服务可用。"
|
||||||
|
|
||||||
|
msgid "%s request address"
|
||||||
|
msgstr "%s 请求地址"
|
||||||
|
|
||||||
msgid "Format must be:"
|
msgid "Format must be:"
|
||||||
msgstr "格式必须为:"
|
msgstr "格式必须为:"
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ function gen_config(var)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
--[[
|
||||||
if default_outboundTag or default_balancerTag then
|
if default_outboundTag or default_balancerTag then
|
||||||
table.insert(rules, {
|
table.insert(rules, {
|
||||||
_flag = "default",
|
_flag = "default",
|
||||||
@ -1020,7 +1020,7 @@ function gen_config(var)
|
|||||||
network = "tcp,udp"
|
network = "tcp,udp"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
routing = {
|
routing = {
|
||||||
domainStrategy = node.domainStrategy or "AsIs",
|
domainStrategy = node.domainStrategy or "AsIs",
|
||||||
domainMatcher = node.domainMatcher or "hybrid",
|
domainMatcher = node.domainMatcher or "hybrid",
|
||||||
|
Loading…
Reference in New Issue
Block a user