mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-09-14 04:14:40 +08:00
update 2026-08-09 16:35:03
This commit is contained in:
@@ -495,22 +495,22 @@ end
|
||||
function add_node()
|
||||
local redirect = http.formvalue("redirect")
|
||||
|
||||
local uuid = api.gen_short_uuid()
|
||||
uci:section(appname, "nodes", uuid)
|
||||
local uid = api.gen_random_char()
|
||||
uci:section(appname, "nodes", uid)
|
||||
|
||||
local group = http.formvalue("group")
|
||||
if group and group ~= "default" then
|
||||
uci:set(appname, uuid, "group", group)
|
||||
uci:set(appname, uid, "group", group)
|
||||
end
|
||||
|
||||
uci:set(appname, uuid, "type", "Socks")
|
||||
uci:set(appname, uid, "type", "Socks")
|
||||
|
||||
if redirect == "1" then
|
||||
api.uci_save(uci, appname)
|
||||
http.redirect(api.url("node_config", uuid))
|
||||
http.redirect(api.url("node_config", uid))
|
||||
else
|
||||
api.uci_save(uci, appname, true, true)
|
||||
http_write_json({result = uuid})
|
||||
http_write_json({result = uid})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -538,17 +538,17 @@ end
|
||||
|
||||
function copy_node()
|
||||
local section = http.formvalue("section")
|
||||
local uuid = api.gen_short_uuid()
|
||||
uci:section(appname, "nodes", uuid)
|
||||
local uid = api.gen_random_char()
|
||||
uci:section(appname, "nodes", uid)
|
||||
for k, v in pairs(uci:get_all(appname, section)) do
|
||||
if not k:match("^%.") and k ~= "group" then
|
||||
if k == "remarks" then v = (v or "") .. "(1)" end
|
||||
uci:set(appname, uuid, k, v)
|
||||
uci:set(appname, uid, k, v)
|
||||
end
|
||||
end
|
||||
uci:set(appname, uuid, "add_mode", 1)
|
||||
uci:set(appname, uid, "add_mode", 1)
|
||||
api.uci_save(uci, appname)
|
||||
http.redirect(api.url("node_config", uuid))
|
||||
http.redirect(api.url("node_config", uid))
|
||||
end
|
||||
|
||||
function clear_all_nodes()
|
||||
@@ -1165,29 +1165,29 @@ function add_shunt_rule()
|
||||
local add_name = http.formvalue("add_name")
|
||||
local redirect = http.formvalue("redirect")
|
||||
|
||||
local uuid = add_name
|
||||
local uid = add_name
|
||||
if add_name then
|
||||
local has = uci:get(appname, uuid)
|
||||
local has = uci:get(appname, uid)
|
||||
if has then
|
||||
http_write_json_error({ message = "This ID already exists." })
|
||||
return
|
||||
end
|
||||
else
|
||||
uuid = api.gen_short_uuid()
|
||||
uid = api.gen_random_char()
|
||||
end
|
||||
uci:section(appname, "shunt_rules", uuid)
|
||||
uci:section(appname, "shunt_rules", uid)
|
||||
|
||||
local group = http.formvalue("group")
|
||||
if group and group ~= "default" then
|
||||
uci:set(appname, uuid, "group", group)
|
||||
uci:set(appname, uid, "group", group)
|
||||
end
|
||||
|
||||
if redirect == "1" then
|
||||
api.uci_save(uci, appname)
|
||||
http.redirect(api.url("shunt_rules", uuid))
|
||||
http.redirect(api.url("shunt_rules", uid))
|
||||
else
|
||||
api.uci_save(uci, appname)
|
||||
http_write_json_ok({uuid = uuid, redirect_url = api.url("shunt_rules", uuid)})
|
||||
http_write_json_ok({uid = uid, redirect_url = api.url("shunt_rules", uid)})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -23,10 +23,9 @@ s.anonymous = true
|
||||
s.addremove = true
|
||||
s.extedit = api.url("acl_config", "%s")
|
||||
function s.create(e, t)
|
||||
local uuid = api.gen_short_uuid(5)
|
||||
uuid = "acl_" .. uuid
|
||||
TypedSection.create(e, uuid)
|
||||
luci.http.redirect(e.extedit:format(uuid))
|
||||
local uid = "acl_" .. api.gen_random_char(5)
|
||||
TypedSection.create(e, uid)
|
||||
luci.http.redirect(e.extedit:format(uid))
|
||||
end
|
||||
function s.remove(e, t)
|
||||
sys.call("rm -rf /tmp/etc/passwall_tmp/dns_" .. t .. "*")
|
||||
@@ -50,6 +49,15 @@ sys.net.mac_hints(function(e, t)
|
||||
}
|
||||
end)
|
||||
|
||||
i = s:option(DummyValue, "interface", translate("Source Interface"))
|
||||
i.cfgvalue = function(t, n)
|
||||
local v = Value.cfgvalue(t, n) or ''
|
||||
if v == "" then
|
||||
return translate("All")
|
||||
end
|
||||
return v
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "sources", translate("Source"))
|
||||
o.rawhtml = true
|
||||
o.cfgvalue = function(t, n)
|
||||
@@ -68,10 +76,13 @@ o.cfgvalue = function(t, n)
|
||||
return e
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "interface", translate("Source Interface"))
|
||||
o.cfgvalue = function(t, n)
|
||||
local v = Value.cfgvalue(t, n) or '-'
|
||||
return v
|
||||
i = s:option(DummyValue, "mode", translate("Mode"))
|
||||
i.cfgvalue = function(t, n)
|
||||
local v = Value.cfgvalue(t, n) or '0'
|
||||
if v == "1" then
|
||||
return translate("Proxy")
|
||||
end
|
||||
return translate("No Proxy")
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
@@ -84,19 +84,6 @@ o = s:option(Value, "remarks", translate("Remarks"))
|
||||
o.default = cfgid
|
||||
o.rmempty = false
|
||||
|
||||
---- Log
|
||||
o = s:option(Flag, "log", translate("Log"))
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "loglevel", "Sing-Box/Xray " .. translate("Log Level"))
|
||||
o.default = "warning"
|
||||
o:value("debug")
|
||||
o:value("info")
|
||||
o:value("warning")
|
||||
o:value("error")
|
||||
o:depends("log", "1")
|
||||
|
||||
o = s:option(Value, "interface", translate("Source Interface"))
|
||||
o:value("", translate("All"))
|
||||
local iface = api.get_network_devices()
|
||||
@@ -196,12 +183,17 @@ sources.validate = function(self, value, t)
|
||||
end
|
||||
sources.write = dynamicList_write
|
||||
|
||||
o = s:option(ListValue, "mode", translate("Mode"))
|
||||
o:value("0", translate("No Proxy"))
|
||||
o:value("1", translate("Proxy"))
|
||||
|
||||
---- TCP No Redir Ports
|
||||
local TCP_NO_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_no_redir_ports")
|
||||
o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports"))
|
||||
o:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")")
|
||||
o:value("disable", translate("No patterns are used"))
|
||||
o:value("1:65535", translate("All"))
|
||||
o:depends("mode", "1")
|
||||
o.validate = port_validate
|
||||
|
||||
---- UDP No Redir Ports
|
||||
@@ -213,11 +205,13 @@ o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"),
|
||||
o:value("", translate("Use global config") .. "(" .. UDP_NO_REDIR_PORTS .. ")")
|
||||
o:value("disable", translate("No patterns are used"))
|
||||
o:value("1:65535", translate("All"))
|
||||
o:depends("mode", "1")
|
||||
o.validate = port_validate
|
||||
|
||||
o = s:option(DummyValue, "_hide_node_option", "")
|
||||
o.template = "passwall/cbi/hidevalue"
|
||||
o.value = "1"
|
||||
o:depends("mode", "0")
|
||||
o:depends({ tcp_no_redir_ports = "1:65535", udp_no_redir_ports = "1:65535" })
|
||||
if TCP_NO_REDIR_PORTS == "1:65535" and UDP_NO_REDIR_PORTS == "1:65535" then
|
||||
o:depends({ tcp_no_redir_ports = "", udp_no_redir_ports = "" })
|
||||
@@ -280,6 +274,20 @@ o.value = "1"
|
||||
o:depends({ udp_node = "", ['!reverse'] = true })
|
||||
o:depends({ shunt_udp_node = "tcp" })
|
||||
|
||||
---- Log
|
||||
o = s:option(Flag, "log", translate("Enable Node Log"))
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
o:depends({ _hide_node_option = false, use_global_config = false })
|
||||
|
||||
o = s:option(ListValue, "loglevel", "Sing-Box/Xray " .. translate("Log Level"))
|
||||
o.default = "warn"
|
||||
o:value("debug", "Debug")
|
||||
o:value("info", "Info")
|
||||
o:value("warn", "Warning")
|
||||
o:value("error", "Error")
|
||||
o:depends("log", "1")
|
||||
|
||||
---- TCP Proxy Drop Ports
|
||||
local TCP_PROXY_DROP_PORTS = m:get("@global_forwarding[0]", "tcp_proxy_drop_ports")
|
||||
o = s:option(Value, "tcp_proxy_drop_ports", translate("TCP Proxy Drop Ports"))
|
||||
|
||||
@@ -650,11 +650,11 @@ o.default = "0"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("log", ListValue, "loglevel", "Sing-Box/Xray " .. translate("Log Level"))
|
||||
o.default = "warning"
|
||||
o:value("debug")
|
||||
o:value("info")
|
||||
o:value("warning")
|
||||
o:value("error")
|
||||
o.default = "warn"
|
||||
o:value("debug", "Debug")
|
||||
o:value("info", "Info")
|
||||
o:value("warn", "Warning")
|
||||
o:value("error", "Error")
|
||||
|
||||
o = s:taboption("log", Flag, "advanced_log_feature", translate("Advanced log feature"), translate("For professionals only."))
|
||||
o.default = "0"
|
||||
@@ -696,10 +696,9 @@ s2.anonymous = true
|
||||
s2.addremove = true
|
||||
s2.extedit = api.url("socks_config", "%s")
|
||||
function s2.create(e, t)
|
||||
local uuid = api.gen_short_uuid(5)
|
||||
uuid = "socks_" .. uuid
|
||||
TypedSection.create(e, uuid)
|
||||
luci.http.redirect(e.extedit:format(uuid))
|
||||
local uid = "socks_" .. api.gen_random_char(5)
|
||||
TypedSection.create(e, uid)
|
||||
luci.http.redirect(e.extedit:format(uid))
|
||||
end
|
||||
function s2.remove(e, t)
|
||||
local socks = "Socks_" .. t
|
||||
|
||||
@@ -114,9 +114,8 @@ s.anonymous = true
|
||||
s.addremove = true
|
||||
|
||||
s.create = function(e, t)
|
||||
local uuid = api.gen_short_uuid(5)
|
||||
uuid = "haproxy_" .. uuid
|
||||
TypedSection.create(e, uuid)
|
||||
local uid = "haproxy_" .. api.gen_random_char(5)
|
||||
TypedSection.create(e, uid)
|
||||
end
|
||||
|
||||
s.remove = function(self, section)
|
||||
|
||||
@@ -138,12 +138,11 @@ s.template = "cbi/tblsection"
|
||||
s.extedit = api.url("node_subscribe_config", "%s")
|
||||
function s.create(e, t)
|
||||
m.no_commit = true
|
||||
local uuid = api.gen_short_uuid(5)
|
||||
uuid = "sub_" .. uuid
|
||||
TypedSection.create(e, uuid)
|
||||
m:set(uuid, "hysteria_up_mbps", "100")
|
||||
m:set(uuid, "hysteria_down_mbps", "100")
|
||||
luci.http.redirect(e.extedit:format(uuid))
|
||||
local uid = "sub_" .. api.gen_random_char(5)
|
||||
TypedSection.create(e, uid)
|
||||
m:set(uid, "hysteria_up_mbps", "100")
|
||||
m:set(uid, "hysteria_down_mbps", "100")
|
||||
luci.http.redirect(e.extedit:format(uid))
|
||||
end
|
||||
|
||||
o = s:option(Value, "remark", translate("Remarks"))
|
||||
|
||||
@@ -222,9 +222,8 @@ if has_xray then
|
||||
s_xray_noise.addremove = true
|
||||
|
||||
s_xray_noise.create = function(e, t)
|
||||
local uuid = api.gen_short_uuid(5)
|
||||
uuid = "xray_noise_" .. uuid
|
||||
TypedSection.create(e, uuid)
|
||||
local uid = "xray_noise_" .. api.gen_random_char(5)
|
||||
TypedSection.create(e, uid)
|
||||
end
|
||||
|
||||
s_xray_noise.remove = function(self, section)
|
||||
|
||||
@@ -513,6 +513,9 @@ o.default = "chrome"
|
||||
o:depends({ [_n("tls")] = true, [_n("utls")] = true })
|
||||
o:depends({ [_n("tls")] = true, [_n("reality")] = true })
|
||||
|
||||
o = s:option(Value, _n("cipherSuites"), translate("Cipher Suites"), '<a href="https://go.dev/src/crypto/tls/cipher_suites.go#L44" target="_blank">***</a>' .. " " .. translate("Configures the list of supported cipher suites, separated by :"))
|
||||
o:depends({ [_n("tls")] = true, [_n("reality")] = false })
|
||||
|
||||
o = s:option(Flag, _n("use_mldsa65Verify"), translate("ML-DSA-65"))
|
||||
o.default = "0"
|
||||
o:depends({ [_n("tls")] = true, [_n("reality")] = true })
|
||||
|
||||
@@ -536,6 +536,9 @@ o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:option(Value, _n("cipherSuites"), translate("Cipher Suites"), '<a href="https://go.dev/src/crypto/tls/cipher_suites.go#L44" target="_blank">***</a>' .. " " .. translate("Configures the list of supported cipher suites, separated by :"))
|
||||
o:depends({ [_n("tls")] = true })
|
||||
|
||||
o = s:option(Flag, _n("ech"), translate("ECH"))
|
||||
o.default = "0"
|
||||
o:depends({ [_n("tls")] = true, [_n("flow")] = "", [_n("reality")] = false })
|
||||
|
||||
@@ -26,10 +26,9 @@ t.sortable = true
|
||||
t.template = "cbi/tblsection"
|
||||
t.extedit = api.url("server_user", "%s")
|
||||
function t.create(e, t)
|
||||
local uuid = api.gen_uuid()
|
||||
t = uuid
|
||||
TypedSection.create(e, t)
|
||||
luci.http.redirect(e.extedit:format(t))
|
||||
local uid = api.gen_random_char()
|
||||
TypedSection.create(e, uid)
|
||||
luci.http.redirect(e.extedit:format(uid))
|
||||
end
|
||||
function t.remove(e, t)
|
||||
e.map.proceed = true
|
||||
|
||||
@@ -111,7 +111,7 @@ o:depends({ [_n("protocol")] = "socks" })
|
||||
|
||||
o = s:option(DynamicList, _n("uuid"), translate("ID") .. "/" .. translate("Password"))
|
||||
for i = 1, 3 do
|
||||
o:value(api.gen_uuid(1))
|
||||
o:value(api.gen_uuid())
|
||||
end
|
||||
o:depends({ [_n("protocol")] = "vmess" })
|
||||
o:depends({ [_n("protocol")] = "vless" })
|
||||
|
||||
@@ -235,7 +235,7 @@ o:depends({ [_n("protocol")] = "shadowsocks" })
|
||||
|
||||
o = s:option(DynamicList, _n("uuid"), translate("ID") .. "/" .. translate("Password"))
|
||||
for i = 1, 3 do
|
||||
o:value(api.gen_uuid(1))
|
||||
o:value(api.gen_uuid())
|
||||
end
|
||||
o:depends({ [_n("protocol")] = "vmess" })
|
||||
o:depends({ [_n("protocol")] = "vless" })
|
||||
|
||||
@@ -642,15 +642,12 @@ function get_full_node_remarks(n)
|
||||
return remarks
|
||||
end
|
||||
|
||||
function gen_uuid(format)
|
||||
function gen_uuid()
|
||||
local uuid = sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)")
|
||||
if format == nil then
|
||||
uuid = string.gsub(uuid, "-", "")
|
||||
end
|
||||
return uuid
|
||||
end
|
||||
|
||||
function gen_short_uuid(length)
|
||||
function gen_random_char(length)
|
||||
if not length then length = 8 end
|
||||
return sys.exec("echo -n $(head /dev/urandom | tr -dc A-Za-z0-9 | head -c %s)" % length)
|
||||
end
|
||||
|
||||
@@ -5,7 +5,6 @@ local sys = api.sys
|
||||
local jsonc = api.jsonc
|
||||
local appname = "passwall"
|
||||
local fs = api.fs
|
||||
local split = api.split
|
||||
local ech_domain = {}
|
||||
|
||||
local local_version = api.get_app_version("sing-box"):match("[^v]+")
|
||||
@@ -88,6 +87,11 @@ local function convert_geofile()
|
||||
convert(GEO_VAR.IP_PATH, "geoip", GEO_VAR.IP_TAGS)
|
||||
end
|
||||
|
||||
local function get_log_level(s)
|
||||
if s == "warning" then s = "warn" end
|
||||
return s
|
||||
end
|
||||
|
||||
function gen_outbound(flag, node, tag, proxy_table)
|
||||
local result = nil
|
||||
if node then
|
||||
@@ -190,7 +194,7 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
if not GLOBAL.DNS_SERVER[dns_key] then
|
||||
GLOBAL.DNS_SERVER[dns_key] = {
|
||||
server = {
|
||||
tag = "dns-node-" .. api.gen_short_uuid(),
|
||||
tag = "dns-node-" .. api.gen_random_char(),
|
||||
type = dns_proto,
|
||||
server = server_address,
|
||||
server_port = server_port,
|
||||
@@ -232,7 +236,8 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
--max_version = "1.3",
|
||||
fragment = fragment,
|
||||
record_fragment = record_fragment,
|
||||
certificate = (node.tls_certificate == "1" and node.tls_certificate_pem ~= "") and split(node.tls_certificate_pem, "\n") or nil,
|
||||
certificate = (node.tls_certificate == "1" and node.tls_certificate_pem ~= "") and api.split(node.tls_certificate_pem, "\n") or nil,
|
||||
cipher_suites = (node.cipherSuites and node.cipherSuites ~= "") and api.split(node.cipherSuites, ":") or nil,
|
||||
ech = (node.ech == "1") and (function()
|
||||
local function get_ech_domain(s) --兼容xray "域名+DNS" 格式ech
|
||||
local domain, dns = s:match("^([^+]+)%+(.+)$")
|
||||
@@ -1042,7 +1047,7 @@ function gen_config_server(node)
|
||||
local config = {
|
||||
log = {
|
||||
disabled = (not node or node.log == "0") and true or false,
|
||||
level = node.loglevel or "info",
|
||||
level = get_log_level(node.loglevel) or "info",
|
||||
timestamp = true,
|
||||
--output = logfile,
|
||||
},
|
||||
@@ -2169,7 +2174,7 @@ function gen_config(var)
|
||||
local config = {
|
||||
log = {
|
||||
disabled = log == "0" and true or false,
|
||||
level = loglevel,
|
||||
level = get_log_level(loglevel),
|
||||
timestamp = true,
|
||||
output = logfile,
|
||||
},
|
||||
|
||||
@@ -31,6 +31,11 @@ local function get_domain_excluded()
|
||||
return hosts
|
||||
end
|
||||
|
||||
local function get_log_level(s)
|
||||
if s == "warn" then s = "warning" end
|
||||
return s
|
||||
end
|
||||
|
||||
function gen_outbound(flag, node, tag, proxy_table)
|
||||
local result = nil
|
||||
if node then
|
||||
@@ -165,7 +170,8 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
certificates = (node.tls_certificate == "1" and node.tls_certificate_pem ~= "") and {
|
||||
certificate = api.split(node.tls_certificate_pem, "\n"),
|
||||
usage = "verify"
|
||||
} or nil
|
||||
} or nil,
|
||||
cipherSuites = node.cipherSuites or nil
|
||||
} or nil,
|
||||
realitySettings = (node.stream_security == "reality") and {
|
||||
serverName = node.tls_serverName,
|
||||
@@ -453,7 +459,7 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
local dns_key = dns_proto .. "|" .. config_address .. "|" .. tostring(config_port)
|
||||
if not GLOBAL.DNS_SERVER[dns_key] then
|
||||
GLOBAL.DNS_SERVER[dns_key] = {
|
||||
tag = "dns-node-" .. api.gen_short_uuid(),
|
||||
tag = "dns-node-" .. api.gen_random_char(),
|
||||
-- queryStrategy = node.domain_strategy or "UseIP",
|
||||
address = config_address,
|
||||
port = config_port,
|
||||
@@ -635,7 +641,7 @@ function gen_config_server(node)
|
||||
local config = {
|
||||
log = {
|
||||
-- error = "/tmp/etc/passwall_server/log/" .. user[".name"] .. ".log",
|
||||
loglevel = ("1" == node.log) and node.loglevel or "none"
|
||||
loglevel = ("1" == node.log) and get_log_level(node.loglevel) or "none"
|
||||
},
|
||||
-- 传入连接
|
||||
inbounds = {
|
||||
@@ -1966,7 +1972,7 @@ function gen_config(var)
|
||||
end)(),
|
||||
log = {
|
||||
-- error = string.format("/tmp/etc/%s/%s.log", appname, node[".name"]),
|
||||
loglevel = loglevel
|
||||
loglevel = get_log_level(loglevel)
|
||||
},
|
||||
-- DNS
|
||||
dns = dns,
|
||||
|
||||
Reference in New Issue
Block a user