Compare commits

...

4 Commits

Author SHA1 Message Date
NewUse
23879741fb
Update zapret-tpws.lua
add error message
2024-09-26 11:14:51 +03:00
NewUse
7c7d66d4ef
Update zapret-tpws.lua
change error message
2024-09-26 10:21:53 +03:00
NewUse
bbb337e5d5
Update zapret-tpws.lua
fix return value
2024-09-26 10:11:39 +03:00
NewUse
bc4ed19080
Update zapret-tpws.lua
fix validation function
2024-09-26 09:03:28 +03:00

View File

@ -1,24 +1,23 @@
m = Map("zapret", translate("TPWS Proxy Settings")) m = Map("zapret", translate("TPWS Proxy Settings"))c = m:section(NamedSection, "tpws", "zapret", translate("Configuration"))
c = m:section(NamedSection, "tpws", "zapret", translate("Configuration"))
opt = c:option(Value, "opts", translate("TPWS Options")) opt = c:option(Value, "opts", translate("TPWS Options"))
opt.placeholder = "--split-pos=2" opt.placeholder = "--split-pos=2"
function checkDoubleMinus(inputString) function opt.validate(self, value)
-- Split the string into words -- Split the string into words
local words = {} local words = {}
for word in inputString:gmatch("%S+") do for word in value:gmatch("%S+") do
table.insert(words, word) table.insert(words, word)
end end
-- Check each word -- Check each word
for _, word in ipairs(words) do for _, word in ipairs(words) do
if not word:sub(1, 2) == "--" then if not word:sub(1, 2) == "--" then
return false, translate("Error: Not all words start with double minuses.") return nil, opt.error = translate("Error: Not all options start with double dash.")
end end
end end
return true return value
end end
opt.validate = checkDoubleMinus(opt.Value)
b = c:option(Flag, "block_quic", "Block QUIC", translate("Block QUIC protocol to come outside")) b = c:option(Flag, "block_quic", "Block QUIC", translate("Block QUIC protocol to come outside"))
lp = c:option(Value, "port", translate("Listen Port")) lp = c:option(Value, "port", translate("Listen Port"))
lp.datatype = "port" lp.datatype = "port"