mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-04 05:43:56 +08:00
update 2026-08-10 13:20:53
This commit is contained in:
1 parent
d4137a5515
commit
ac2fbbc674
1966 files changed
+1523192
-62
No files matched your search
@@ -49,18 +49,6 @@ m.uci:foreach(appname, "socks", function(s)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
local dynamicList_write = function(self, section, value)
|
||||
local new_t = {}
|
||||
if type(value) == "table" then
|
||||
new_t = api.table_remove_duplicates(value)
|
||||
else
|
||||
new_t = { value }
|
||||
end
|
||||
local new_val = table.concat(new_t, " ")
|
||||
return DynamicList.write(self, section, new_val)
|
||||
end
|
||||
|
||||
-- [[ ACLs Settings ]]--
|
||||
s = m:section(NamedSection, cfgid, translate("ACLs"), translate("ACLs"))
|
||||
s.addremove = false
|
||||
@@ -173,7 +161,6 @@ sources.validate = function(self, value, t)
|
||||
|
||||
return value
|
||||
end
|
||||
sources.write = dynamicList_write
|
||||
|
||||
o = s:option(ListValue, "mode", translate("Mode"))
|
||||
o:value("0", translate("No Proxy"))
|
||||
|
||||
@@ -372,15 +372,6 @@ if api.is_finded("smartdns") then
|
||||
o.cfgvalue = function(self, section)
|
||||
return m:get(section, self.option) or {"tcp://1.1.1.1"}
|
||||
end
|
||||
function o.write(self, section, value)
|
||||
local new_t = {}
|
||||
if type(value) == "table" then
|
||||
new_t = api.table_remove_duplicates(value)
|
||||
else
|
||||
new_t = { value }
|
||||
end
|
||||
return DynamicList.write(self, section, new_t)
|
||||
end
|
||||
end
|
||||
|
||||
o = s:taboption("DNS", ListValue, "xray_dns_mode", translate("Remote DNS") .. " " .. translate("Request protocol"))
|
||||
|
||||
@@ -164,19 +164,6 @@ source.validate = function(self, value, t)
|
||||
return value
|
||||
end
|
||||
|
||||
local dynamicList_write = function(self, section, value)
|
||||
local new_t = {}
|
||||
if type(value) == "table" then
|
||||
new_t = api.table_remove_duplicates(value)
|
||||
else
|
||||
new_t = { value }
|
||||
end
|
||||
local new_val = table.concat(new_t, " ")
|
||||
return DynamicList.write(self, section, new_val)
|
||||
end
|
||||
|
||||
source.write = dynamicList_write
|
||||
|
||||
--[[
|
||||
-- Too low usage rate, hidden
|
||||
sourcePort = s:option(Value, "sourcePort", translate("Source port"))
|
||||
|
||||
@@ -116,12 +116,12 @@ if load_balancing_options then -- [[ Load balancing Start ]]
|
||||
end
|
||||
end
|
||||
-- 读取旧 DynamicList
|
||||
function o.cfgvalue(self, section)
|
||||
return m.uci:get_list(appname, section, "balancing_node") or {}
|
||||
function o.custom_cfgvalue(self, section)
|
||||
return table.concat(m:get(section, "balancing_node") or {}, " ")
|
||||
end
|
||||
-- 写入保持 DynamicList
|
||||
function o.custom_write(self, section, value)
|
||||
local old = m.uci:get_list(appname, section, "balancing_node") or {}
|
||||
local old = m:get(section, "balancing_node") or {}
|
||||
local new, set = {}, {}
|
||||
for v in value:gmatch("%S+") do
|
||||
new[#new + 1] = v
|
||||
@@ -129,13 +129,13 @@ if load_balancing_options then -- [[ Load balancing Start ]]
|
||||
end
|
||||
for _, v in ipairs(old) do
|
||||
if not set[v] then
|
||||
m.uci:set_list(appname, section, "balancing_node", new)
|
||||
m:set(section, "balancing_node", new)
|
||||
return
|
||||
end
|
||||
set[v] = nil
|
||||
end
|
||||
for _ in pairs(set) do
|
||||
m.uci:set_list(appname, section, "balancing_node", new)
|
||||
m:set(section, "balancing_node", new)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@@ -115,12 +115,12 @@ if load_urltest_options then -- [[ URLTest Start ]]
|
||||
end
|
||||
end
|
||||
-- 读取旧 DynamicList
|
||||
function o.cfgvalue(self, section)
|
||||
return m.uci:get_list(appname, section, "urltest_node") or {}
|
||||
function o.custom_cfgvalue(self, section)
|
||||
return table.concat(m:get(section, "urltest_node") or {}, " ")
|
||||
end
|
||||
-- 写入保持 DynamicList
|
||||
function o.custom_write(self, section, value)
|
||||
local old = m.uci:get_list(appname, section, "urltest_node") or {}
|
||||
local old = m:get(section, "urltest_node") or {}
|
||||
local new, set = {}, {}
|
||||
for v in value:gmatch("%S+") do
|
||||
new[#new + 1] = v
|
||||
@@ -128,13 +128,13 @@ if load_urltest_options then -- [[ URLTest Start ]]
|
||||
end
|
||||
for _, v in ipairs(old) do
|
||||
if not set[v] then
|
||||
m.uci:set_list(appname, section, "urltest_node", new)
|
||||
m:set(section, "urltest_node", new)
|
||||
return
|
||||
end
|
||||
set[v] = nil
|
||||
end
|
||||
for _ in pairs(set) do
|
||||
m.uci:set_list(appname, section, "urltest_node", new)
|
||||
m:set(section, "urltest_node", new)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@@ -216,15 +216,6 @@ o:depends({ [_n("reality")] = true })
|
||||
|
||||
o = s:option(DynamicList, _n("reality_serverNames"), translate("serverNames"))
|
||||
o:depends({ [_n("reality")] = true })
|
||||
function o.custom_write(self, section, value)
|
||||
local new_t = {}
|
||||
if type(value) == "table" then
|
||||
new_t = api.table_remove_duplicates(value)
|
||||
else
|
||||
new_t = { value }
|
||||
end
|
||||
m:set(section, self.option:sub(1 + #option_prefix), new_t)
|
||||
end
|
||||
|
||||
o = s:option(ListValue, _n("alpn"), translate("alpn"))
|
||||
o.default = "default"
|
||||
|
||||
@@ -4,6 +4,7 @@ nixio = require "nixio"
|
||||
fs = require "nixio.fs"
|
||||
sys = require "luci.sys"
|
||||
uci = require "luci.model.uci".cursor()
|
||||
cbi = require "luci.cbi"
|
||||
util = require "luci.util"
|
||||
datatypes = require "luci.cbi.datatypes"
|
||||
jsonc = require "luci.jsonc"
|
||||
@@ -1335,7 +1336,6 @@ function to_check_self()
|
||||
end
|
||||
|
||||
function set_default_cbi()
|
||||
local cbi = require "luci.cbi"
|
||||
if true then
|
||||
--TextValue
|
||||
local TextValue = cbi.TextValue
|
||||
@@ -1345,10 +1345,28 @@ function set_default_cbi()
|
||||
self.template = appname .. "/cbi/tvalue"
|
||||
end
|
||||
end
|
||||
if true then
|
||||
--DynamicList
|
||||
local DynamicList = cbi.DynamicList
|
||||
function DynamicList.write(self, section, value)
|
||||
local new_t = {}
|
||||
if type(value) == "table" then
|
||||
new_t = table_remove_duplicates(value)
|
||||
else
|
||||
new_t = { value }
|
||||
end
|
||||
local new_val
|
||||
if self.cast == "string" then
|
||||
new_val = table.concat(new_t, " ")
|
||||
else
|
||||
new_val = new_t
|
||||
end
|
||||
return cbi.AbstractValue.write(self, section, new_val)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function return_map(map)
|
||||
local cbi = require "luci.cbi"
|
||||
local api = require "luci.passwall.api"
|
||||
if true then
|
||||
-- header
|
||||
@@ -1406,11 +1424,25 @@ function luci_types(id, m, s, type_name, option_prefix)
|
||||
if self.custom_write then
|
||||
self:custom_write(section, value)
|
||||
else
|
||||
local new_val = value
|
||||
if util.instanceof(self, cbi.DynamicList) then
|
||||
local new_t = {}
|
||||
if type(value) == "table" then
|
||||
new_t = table_remove_duplicates(value)
|
||||
else
|
||||
new_t = { value }
|
||||
end
|
||||
if self.cast == "string" then
|
||||
new_val = table.concat(new_t, " ")
|
||||
else
|
||||
new_val = new_t
|
||||
end
|
||||
end
|
||||
if self.rewrite_option then
|
||||
m:set(section, self.rewrite_option, value)
|
||||
m:set(section, self.rewrite_option, new_val)
|
||||
else
|
||||
if self.option:find(option_prefix) == 1 then
|
||||
m:set(section, self.option:sub(1 + #option_prefix), value)
|
||||
m:set(section, self.option:sub(1 + #option_prefix), new_val)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -220,7 +220,7 @@ local function encode_vless(node)
|
||||
local link = "vless://" .. node.uuid .. "@" .. o.server .. ":" .. o.port
|
||||
local p = {}
|
||||
|
||||
if node.flow then table.insert(p, "flow=" .. urlencode(node.flow)) end
|
||||
if type(node.flow) == "string" and node.flow:sub(1, 5) == "xtls-" then table.insert(p, "flow=" .. urlencode(node.flow)) end
|
||||
if node.encryption then table.insert(p, "encryption=" .. urlencode(node.encryption)) end
|
||||
|
||||
-- TLS
|
||||
|
||||
Reference in new issue
Block a user