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 1c913bb9..10b6c869 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -149,7 +149,8 @@ end o = s:taboption("Main", Value, "node_socks_port", translate("Node") .. " Socks " .. translate("Listen Port")) o.default = 1070 -o.datatype = "port" +o.datatype = "range(1,65535)" +o.rmempty = false o:depends({ node = "", ["!reverse"] = true }) --[[ if has_singbox or has_xray then @@ -727,7 +728,7 @@ end) o = s2:option(Value, "port", "Socks " .. translate("Listen Port")) o.default = n + 1080 -o.datatype = "port" +o.datatype = "range(1,65535)" o.rmempty = false --[[ diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua index 71b5bacc..8d8cdf92 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua @@ -46,8 +46,9 @@ o:depends("console_auth", true) ---- Console Port o = s:option(Value, "console_port", translate("Console Port"), translate("In the browser input routing IP plus port access, such as:192.168.1.1:1188")) -o.datatype = "port" o.default = 1188 +o.datatype = "range(1,65535)" +o.rmempty = false o:depends("balancing_enable", true) o = s:option(Flag, "bind_local", translate("Haproxy Port") .. " " .. translate("Bind Local"), translate("When selected, it can only be accessed localhost.")) @@ -151,8 +152,8 @@ end ---- Haproxy Port o = s:option(Value, "haproxy_port", translate("Haproxy Port")) -o.datatype = "port" o.default = 1181 +o.datatype = "range(1,65535)" o.rmempty = false ---- Node Weight diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua index b9707722..f4453447 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua @@ -63,7 +63,7 @@ end) o = s:option(Value, "port", "Socks " .. translate("Listen Port")) o.default = n + 1080 -o.datatype = "port" +o.datatype = "range(1,65535)" o.rmempty = false if has_singbox or has_xray then diff --git a/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm b/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm index dc30ec04..2340e0b1 100644 --- a/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm +++ b/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm @@ -1215,11 +1215,15 @@ table td, .table .td { const set_node_div = { section: '', - open(cbi_id) { + open(cbi_id, protocol) { this.section = cbi_id; document.getElementById("set_node_div").style.display="block"; const node_name = document.getElementById("cbid.<%=appname%>." + cbi_id + ".remarks").value; document.getElementById("set_node_name").textContent = node_name; + const shunt_div = document.getElementById("set_node_shunt_div"); + if (shunt_div) { + shunt_div.style.display = protocol === "_shunt" ? "none" : ""; + } }, close() { document.getElementById("set_node_div").style.display="none"; @@ -1286,7 +1290,7 @@ table td, .table .td {
%s ',
log_path,
@@ -229,46 +246,17 @@ o.cfgvalue = function(t, n)
end
o:depends("log", "1")
----- TCP Redir Ports
-local TCP_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_redir_ports")
-o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports"))
-o:value("", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")")
-o:value("1:65535", translate("All"))
-o:value("22,25,53,80,143,443,465,587,853,873,993,995,5222,8080,8443,9418", translate("Common Use"))
-o:value("80,443", "80,443")
-o.validate = port_validate
-o:depends({ _hide_node_option = "1", ['!reverse'] = true })
-
----- UDP Redir Ports
-local UDP_REDIR_PORTS = m:get("@global_forwarding[0]", "udp_redir_ports")
-o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports"))
-o:value("", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")")
-o:value("1:65535", translate("All"))
-o.validate = port_validate
-o:depends({ _hide_node_option = "1", ['!reverse'] = true })
-
-o = s:option(DummyValue, "tips", " ")
-o.rawhtml = true
-o.cfgvalue = function(t, n)
- return string.format('%s',
- translate("The port settings support single ports and ranges.%s ',
log_path,
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua
index 4d401b0e..dd4ba20a 100644
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua
+++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua
@@ -4,7 +4,6 @@ api.set_default_cbi()
local has_ss_rust = api.is_finded("sslocal")
local has_singbox = api.finded_com("sing-box")
local has_xray = api.finded_com("xray")
-local has_hysteria2 = api.finded_com("hysteria")
local ss_type = {}
local trojan_type = {}
local vmess_type = {}
@@ -33,10 +32,6 @@ if has_xray then
table.insert(hysteria2_type, s)
end
end
-if has_hysteria2 then
- local s = "hysteria2"
- table.insert(hysteria2_type, s)
-end
m = Map()
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua
index a748281d..2bc93b48 100644
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua
+++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua
@@ -17,7 +17,6 @@ m:appendTemplate("/cbi/nodes_listvalue_com")
local has_ss_rust = api.is_finded("sslocal")
local has_singbox = api.finded_com("sing-box")
local has_xray = api.finded_com("xray")
-local has_hysteria2 = api.finded_com("hysteria")
local ss_type = {}
local trojan_type = {}
local vmess_type = {}
@@ -46,10 +45,6 @@ if has_xray then
table.insert(hysteria2_type, s)
end
end
-if has_hysteria2 then
- local s = "hysteria2"
- table.insert(hysteria2_type, s)
-end
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do
if e.node_type == "normal" then
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua
index f076e3c7..f622f076 100644
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua
+++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua
@@ -72,8 +72,7 @@ s = m:section(NamedSection, "@global_forwarding[0]", "global_forwarding", transl
---- TCP No Redir Ports
o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports"))
-o.default = "disable"
-o:value("disable", translate("No patterns are used"))
+o:value("", translate("No patterns are used"))
o:value("1:65535", translate("All"))
o.validate = port_validate
@@ -82,23 +81,22 @@ o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"),
"" ..
translate("Fill in the ports you don't want to be forwarded by the agent, with the highest priority.") ..
"")
-o.default = "disable"
-o:value("disable", translate("No patterns are used"))
+o:value("", translate("No patterns are used"))
o:value("1:65535", translate("All"))
o.validate = port_validate
---- TCP Redir Ports
o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports"))
-o.default = "22,25,53,80,143,443,465,587,853,873,993,995,5222,8080,8443,9418"
o:value("1:65535", translate("All"))
o:value("22,25,53,80,143,443,465,587,853,873,993,995,5222,8080,8443,9418", translate("Common Use"))
o:value("80,443", translate("Only Web"))
+o.default = o.keylist[1]
o.validate = port_validate
---- UDP Redir Ports
o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports"))
-o.default = "1:65535"
o:value("1:65535", translate("All"))
+o.default = o.keylist[1]
o.validate = port_validate
o = s:option(DummyValue, "tips", " ")
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/5_hysteria2.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/5_hysteria2.lua
deleted file mode 100644
index 753c748a..00000000
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/5_hysteria2.lua
+++ /dev/null
@@ -1,106 +0,0 @@
-if not api.finded_com("hysteria") then
- return
-end
-
--- [[ Hysteria2 ]]
-local m, s1 = ...
-local type_name = "Hysteria2"
-
-s1.fields["type"]:value(type_name, "Hysteria2")
-
-if s1.val["type"] ~= type_name then
- return
-end
-
-local s = NamedSection(m, arg[1], "server")
-s.type_name = type_name
-s.option_prefix = "hysteria2_"
-
-o = s:option(Value, "address", translate("Address (Support Domain Name)"))
-o:depends({ realms = false })
-
-o = s:option(Value, "port", translate("Port"))
-o.datatype = "port"
-o:depends({ realms = false })
-
-o = s:option(Value, "hop", translate("Port hopping range"))
-o.description = translate("Format as 1000:2000 or 1000-2000 Multiple groups are separated by commas (,).")
-o:depends({ realms = false })
-
-o = s:option(Value, "hop_interval", translate("Hop Interval(second)"), translate("Supports a fixed value or a random range (e.g., 30, 5-30), minimum 5."))
-o.datatype = "or(uinteger,portrange)"
-o.placeholder = "30"
-o.default = "30"
-o:depends({ realms = false })
-
-o = s:option(Flag, "realms", translate("Realms"))
-o.default = "0"
-
-o = s:option(Value, "realm_url", translate("Realm URL"), translate("Example:") .. "realm://public@realm.hy2.io/your-realm-name")
-o:depends({ realms = "1" })
-o.validate = function(self, value)
- value = api.trim(value)
- local realm = api.parse_realm_uri(value)
- if realm then return value end
- return nil, translate("Invalid Realm URL.")
-end
-
-o = s:option(DynamicList, "realm_stun", translate("Realm STUN"))
-o.default = { "stun.sip.us:3478", "stun.nextcloud.com:3478", "global.stun.twilio.com:3478" }
-o:depends({ realms = "1" })
-
-o = s:option(Value, "auth_password", translate("Auth Password"))
-o.password = true
-
-o = s:option(ListValue, "obfs_type", translate("Obfs Type"))
-o:value("", translate("Disable"))
-o:value("salamander")
-o:value("gecko")
-
-o = s:option(Value, "obfs_password", translate("Obfs Password"))
-o:depends({ obfs_type = "salamander" })
-o:depends({ obfs_type = "gecko" })
-
-o = s:option(Value, "obfs_MinPacketSize", translate("Gecko Packet Size (min)"))
-o.datatype = "uinteger"
-o.placeholder = "512"
-o.default = "512"
-o:depends({ obfs_type = "gecko" })
-
-o = s:option(Value, "obfs_MaxPacketSize", translate("Gecko Packet Size (max)"))
-o.datatype = "uinteger"
-o.placeholder = "1200"
-o.default = "1200"
-o:depends({ obfs_type = "gecko" })
-
-o = s:option(Flag, "fast_open", translate("Fast Open"))
-o.default = "0"
-
-o = s:option(Value, "tls_serverName", translate("Domain"))
-
-o = s:option(Flag, "tls_allowInsecure", translate("allowInsecure"), translate("Whether unsafe connections are allowed. When checked, Certificate validation will be skipped."))
-o.default = "0"
-
-o = s:option(Value, "tls_pinSHA256", translate("PinSHA256"),translate("Certificate fingerprint"))
-
-o = s:option(Value, "up_mbps", translate("Max upload Mbps"))
-
-o = s:option(Value, "down_mbps", translate("Max download Mbps"))
-
-o = s:option(Value, "recv_window", translate("QUIC stream receive window"))
-
-o = s:option(Value, "recv_window_conn", translate("QUIC connection receive window"))
-
-o = s:option(Value, "idle_timeout", translate("Idle Timeout"), translate("Units:seconds") .. " (4~120)")
-o.datatype = "range(4,120)"
-
-o = s:option(Value, "keep_alive_period", translate("QUIC KeepAlive interval"), translate("Units:seconds") .. " (2~60)")
-o.datatype = "range(2,60)"
-
-o = s:option(Flag, "disable_mtu_discovery", translate("Disable MTU detection"))
-o.default = "0"
-
-o = s:option(Flag, "lazy_start", translate("Lazy Start"))
-o.default = "0"
-
-api.luci_types(s1, s)
\ No newline at end of file
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/5_hysteria2.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/5_hysteria2.lua
deleted file mode 100644
index bd6c5c1d..00000000
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/5_hysteria2.lua
+++ /dev/null
@@ -1,143 +0,0 @@
-if not api.finded_com("hysteria") then
- return
-end
-
--- [[ Hysteria2 ]]
-local m, s1 = ...
-local type_name = "Hysteria2"
-
-s1.fields["type"]:value(type_name, "Hysteria2")
-
-if not s1.val["type"] then
- s1.val["type"] = type_name
-end
-
-if s1.val["type"] and s1.val["type"] ~= type_name then
- return
-end
-
-local s = NamedSection(m, arg[1], "server")
-s.type_name = type_name
-s.option_prefix = "hysteria2_"
-
-o = s:option(Flag, "custom", translate("Use Custom Config"))
-
-o = s:option(TextValue, "custom_config", translate("Custom Config"))
-o.rows = 10
-o.wrap = "off"
-o:depends({ custom = true })
-o.datatype = "json"
-local o_validate = o.validate
-o.validate = function(self, value)
- local v = o_validate(self, value)
- if v then return v end
- return nil, translate("Custom Config") .. " " .. translate("Must be JSON text!")
-end
-o.custom_cfgvalue = function(self, section, value)
- local config_str = m:get(section, "config_str")
- if config_str then
- return api.base64Decode(config_str)
- end
-end
-o.custom_write = function(self, section, value)
- m:set(section, "config_str", api.base64Encode(value) or "")
-end
-
-o = s:option(Value, "port", translate("Listen Port"))
-o.datatype = "port"
-o:depends({ custom = false })
-
-o = s:option(DynamicList, "users", translate("User"))
-for i, v in ipairs(user_list) do
- o:value(v[".name"], v.username)
-end
-o:depends({ custom = false })
-
-o = s:option(Flag, "realms", translate("Realms"))
-o.default = "0"
-o:depends({ custom = false })
-
-o = s:option(Value, "realm_url", translate("Realm URL"), translate("Example:") .. "realm://public@realm.hy2.io/your-realm-name")
-o:depends({ realms = true })
-o.validate = function(self, value)
- value = api.trim(value)
- local realm = api.parse_realm_uri(value)
- if realm then return value end
- return nil, translate("Invalid Realm URL.")
-end
-
-o = s:option(DynamicList, "realm_stun", translate("Realm STUN"))
-o.default = { "stun.sip.us:3478", "stun.nextcloud.com:3478", "global.stun.twilio.com:3478" }
-o:depends({ realms = true })
-
-o = s:option(ListValue, "obfs_type", translate("Obfs Type"))
-o:value("", translate("Disable"))
-o:value("salamander")
-o:value("gecko")
-o:depends({ custom = false })
-
-o = s:option(Value, "obfs_password", translate("Obfs Password"))
-o:depends({ obfs_type = "salamander" })
-o:depends({ obfs_type = "gecko" })
-
-o = s:option(Value, "obfs_MinPacketSize", translate("Gecko Packet Size (min)"))
-o.datatype = "uinteger"
-o.placeholder = "512"
-o.default = "512"
-o:depends({ obfs_type = "gecko" })
-
-o = s:option(Value, "obfs_MaxPacketSize", translate("Gecko Packet Size (max)"))
-o.datatype = "uinteger"
-o.placeholder = "1200"
-o.default = "1200"
-o:depends({ obfs_type = "gecko" })
-
-o = s:option(Flag, "udp", translate("UDP"))
-o.default = "1"
-o:depends({ custom = false })
-
-o = s:option(Value, "up_mbps", translate("Max upload Mbps"))
-o:depends({ custom = false })
-
-o = s:option(Value, "down_mbps", translate("Max download Mbps"))
-o:depends({ custom = false })
-
-o = s:option(Flag, "ignoreClientBandwidth", translate("ignoreClientBandwidth"))
-o.default = "0"
-o:depends({ custom = false })
-
-o = s:option(FileUpload, "tls_certificateFile", translate("Public key absolute path"), translate("as:") .. "/etc/ssl/fullchain.pem")
-o.default = m:get(s.section, "tls_certificateFile") or "/etc/config/ssl/" .. arg[1] .. ".pem"
-if o and o:formvalue(arg[1]) then o.default = o:formvalue(arg[1]) end
-o.validate = function(self, value, t)
- if value and value ~= "" then
- if not api.fs.access(value) then
- return nil, translate("Can't find this file!")
- else
- return value
- end
- end
- return nil
-end
-o:depends({ custom = false })
-
-o = s:option(FileUpload, "tls_keyFile", translate("Private key absolute path"), translate("as:") .. "/etc/ssl/private.key")
-o.default = m:get(s.section, "tls_keyFile") or "/etc/config/ssl/" .. arg[1] .. ".key"
-if o and o:formvalue(arg[1]) then o.default = o:formvalue(arg[1]) end
-o.validate = function(self, value, t)
- if value and value ~= "" then
- if not api.fs.access(value) then
- return nil, translate("Can't find this file!")
- else
- return value
- end
- end
- return nil
-end
-o:depends({ custom = false })
-
-o = s:option(Flag, "log", translate("Log"))
-o.default = "1"
-o.rmempty = false
-
-api.luci_types(s1, s)
\ No newline at end of file
diff --git a/luci-app-passwall2/luasrc/passwall2/api.lua b/luci-app-passwall2/luasrc/passwall2/api.lua
index 755bd2e6..491d402f 100644
--- a/luci-app-passwall2/luasrc/passwall2/api.lua
+++ b/luci-app-passwall2/luasrc/passwall2/api.lua
@@ -26,6 +26,7 @@ TMP_PATH = "/tmp/etc/" .. c_config
CACHE_PATH = TMP_PATH .. "_tmp"
S_TMP_PATH = "/tmp/etc/" .. s_config
TMP_IFACE_PATH = TMP_PATH .. "/iface"
+TMP_ACL_PATH = TMP_PATH .. "/acl"
local lang = uci:get("luci", "main", "lang") or "auto"
if lang == "auto" then
@@ -201,9 +202,10 @@ function get_cache_var(key)
return val
end
-function get_new_port()
+function get_new_port(p)
+ if not p then p = "auto" end
local cmd_format = ". /usr/share/passwall2/utils.sh ; echo -n $(get_new_port %s tcp,udp)"
- return tonumber(sys.exec(string.format(cmd_format, "auto")))
+ return tonumber(sys.exec(string.format(cmd_format, p)))
end
function exec_call(cmd)
@@ -613,7 +615,7 @@ function get_valid_nodes()
end
end
local port = e.port or e.hysteria_hop or e.hysteria2_hop
- local is_realm = (e.type == "Hysteria2" or e.protocol == 'hysteria2') and e.hysteria2_realms or nil
+ local is_realm = e.protocol == 'hysteria2' and e.hysteria2_realms or nil
if (port and e.address) or is_realm then
local address = e.address
if is_ip(address) or datatypes.hostname(address) or is_realm then
@@ -739,7 +741,7 @@ function get_node_remarks(n)
end
type_name = type_name .. " " .. protocol
end
- if (n.type == "Hysteria2" or n.protocol == 'hysteria2') and n.hysteria2_realms then
+ if n.protocol == "hysteria2" and n.hysteria2_realms then
type_name = type_name .. " Realm"
end
remarks = trim("%s:[%s]" % {type_name, n.remarks})
diff --git a/luci-app-passwall2/luasrc/passwall2/com.lua b/luci-app-passwall2/luasrc/passwall2/com.lua
index aefc5459..1327e3f5 100644
--- a/luci-app-passwall2/luasrc/passwall2/com.lua
+++ b/luci-app-passwall2/luasrc/passwall2/com.lua
@@ -10,21 +10,6 @@ local function gh_pre_release_url(self)
return "https://github.com/Openwrt-Passwall/openwrt-passwall-packages/releases/download/api-cache/" .. string.lower(self.name) .. "-pre-release-api.json"
end
-_M.hysteria = {
- name = "Hysteria",
- repo = "HyNetwork/hysteria",
- get_url = gh_release_url,
- cmd_version = "version | awk '/^Version:/ {print $2}'",
- remote_version_str_replace = "app/",
- zipped = false,
- default_path = "/usr/bin/hysteria",
- match_fmt_str = "linux%%-%s$",
- file_tree = {
- armv6 = "arm",
- armv7 = "arm"
- }
-}
-
_M["sing-box"] = {
name = "Sing-Box",
repo = "SagerNet/sing-box",
diff --git a/luci-app-passwall2/luasrc/passwall2/server_app.lua b/luci-app-passwall2/luasrc/passwall2/server_app.lua
index 783ee4f9..06420241 100644
--- a/luci-app-passwall2/luasrc/passwall2/server_app.lua
+++ b/luci-app-passwall2/luasrc/passwall2/server_app.lua
@@ -169,13 +169,6 @@ local function start()
config = require(require_dir .. "util_sing-box").gen_config_server(server)
end
bin = ln_run(api.get_app_path("sing-box"), "sing-box", "run -c " .. config_file, log_path)
- elseif type == "Hysteria2" then
- if server.custom == "1" and server.config_str then
- config = jsonc.parse(api.base64Decode(server.config_str))
- else
- config = require(require_dir .. "util_hysteria2").gen_config_server(server)
- end
- bin = ln_run(api.get_app_path("hysteria"), "hysteria", "-c " .. config_file .. " server", log_path)
end
if next(config) then
diff --git a/luci-app-passwall2/luasrc/passwall2/util_hysteria2.lua b/luci-app-passwall2/luasrc/passwall2/util_hysteria2.lua
deleted file mode 100644
index 2d557bcd..00000000
--- a/luci-app-passwall2/luasrc/passwall2/util_hysteria2.lua
+++ /dev/null
@@ -1,197 +0,0 @@
-module("luci.passwall2.util_hysteria2", package.seeall)
-local api = require "luci.passwall2.api"
-local jsonc = api.jsonc
-
-function gen_config_server(node)
- local users = nil
- if node.users and #node.users > 0 then
- users = {}
- for i, v in ipairs(node.users) do
- local user = api.uci_get_s(v) or {}
- if user[".type"] == "user" then
- users[user.username] = user.password
- end
- end
- if not next(users) then
- users = nil
- end
- end
- local config = {
- listen = (function()
- if node.realms and node.realm_url then
- local url = node.realm_url:gsub("/+$", "")
- if node.port then
- url = url .. (url:find("?") and "&lport=" or "?lport=") .. node.port
- end
- return url
- end
- return ":" .. (node.port or "0")
- end)(),
- tls = {
- cert = node.tls_certificateFile,
- key = node.tls_keyFile,
- },
- obfs = (node.obfs_type and node.obfs_password) and {
- type = node.obfs_type,
- [node.obfs_type] = {
- password = node.obfs_password
- }
- } or nil,
- auth = users and {
- type = "userpass",
- userpass = users
- } or nil,
- bandwidth = (node.up_mbps or node.down_mbps) and {
- up = node.up_mbps and node.up_mbps .. " mbps" or nil,
- down = node.down_mbps and node.down_mbps .. " mbps" or nil
- } or nil,
- ignoreClientBandwidth = (node.ignoreClientBandwidth == "1") and true or false,
- disableUDP = (node.udp == "0") and true or false,
- realm = (node.realms and node.realm_stun) and {
- stunServers = node.realm_stun
- } or nil
- }
-
- if config.obfs and config.obfs.gecko then
- local min = tonumber(node.obfs_MinPacketSize) or 512
- local max = tonumber(node.obfs_MaxPacketSize) or 1200
- if min <= 0 or min > max or max > 2048 then
- min = 512
- max = 1200
- end
- config.obfs.gecko.minPacketSize = min
- config.obfs.gecko.maxPacketSize = max
- end
-
- return config
-end
-
-function gen_config(var)
- local node_id = var["node"]
- if not node_id then
- print("node Cannot be empty!")
- return
- end
- local node = api.uci_get_c(node_id)
- local local_socks_address = var["local_socks_address"] or "0.0.0.0"
- local local_socks_port = var["local_socks_port"]
- local local_socks_username = var["local_socks_username"]
- local local_socks_password = var["local_socks_password"]
- local local_http_address = var["local_http_address"] or "0.0.0.0"
- local local_http_port = var["local_http_port"]
- local local_http_username = var["local_http_username"]
- local local_http_password = var["local_http_password"]
- local server_host = var["server_host"] or (node.address or ""):lower()
- local server_port = var["server_port"] or node.port
-
- if api.is_ipv6(server_host) then
- server_host = api.get_ipv6_full(server_host)
- end
-
- local port_hop = ((server_port or "") .. "," .. (node.hysteria2_hop or "")):gsub("^[%s,]+", ""):gsub("[%s,]+$", ""):gsub(":", "-")
- local server = server_host .. ":" .. (port_hop ~= "" and port_hop or "443")
-
- local config = {
- server = (function()
- if node.hysteria2_realms and node.hysteria2_realm_url then
- return node.hysteria2_realm_url:gsub("/+$", "")
- end
- return server
- end)(),
- realm = (node.hysteria2_realms and node.hysteria2_realm_stun) and {
- stunServers = node.hysteria2_realm_stun
- } or nil,
- transport = {
- type = "udp",
- udp = node.hysteria2_hop and (function()
- local udp = {}
- local t = node.hysteria2_hop_interval
- if not t then return nil end
- if t:find("-", 1, true) then
- local min, max = t:match("^(%d+)%-(%d+)$")
- min = tonumber(min)
- max = tonumber(max)
- if min and max then
- min = (min >= 5) and min or 5
- max = (max >= min) and max or min
- udp.minHopInterval = min .. "s"
- udp.maxHopInterval = max .. "s"
- return udp
- end
- end
- t = tonumber((t or "30"):match("^%d+"))
- t = (t and t >= 5) and t or 30
- udp.hopInterval = t .. "s"
- return udp
- end)() or nil
- },
- obfs = (node.hysteria2_obfs_type and node.hysteria2_obfs_password) and {
- type = node.hysteria2_obfs_type,
- [node.hysteria2_obfs_type] = {
- password = node.hysteria2_obfs_password
- }
- } or nil,
- auth = node.hysteria2_auth_password,
- tls = {
- sni = node.tls_serverName,
- insecure = (node.tls_allowInsecure == "1") and true or false,
- pinSHA256 = (node.tls_pinSHA256) and node.tls_pinSHA256 or nil,
- },
- quic = {
- initStreamReceiveWindow = (node.hysteria2_recv_window) and tonumber(node.hysteria2_recv_window) or nil,
- initConnReceiveWindow = (node.hysteria2_recv_window_conn) and tonumber(node.hysteria2_recv_window_conn) or nil,
- maxIdleTimeout = (function(t)
- t = tonumber(tostring(t or "30"):match("^%d+"))
- return (t and t >= 4 and t <= 120) and t .. "s" or "30s"
- end)(node.hysteria2_idle_timeout),
- keepAlivePeriod = (function(t)
- t = tonumber(tostring(t or "0"):match("^%d+"))
- return (t and t >= 2 and t <= 60) and t .. "s" or nil
- end)(node.hysteria2_keep_alive_period),
- disablePathMTUDiscovery = (node.hysteria2_disable_mtu_discovery) and true or false,
- },
- bandwidth = (node.hysteria2_up_mbps or node.hysteria2_down_mbps) and {
- up = node.hysteria2_up_mbps and node.hysteria2_up_mbps .. " mbps" or nil,
- down = node.hysteria2_down_mbps and node.hysteria2_down_mbps .. " mbps" or nil
- } or nil,
- fast_open = (node.fast_open == "1") and true or false,
- lazy = (node.hysteria2_lazy_start == "1") and true or false,
- socks5 = (local_socks_address and local_socks_port) and {
- listen = local_socks_address .. ":" .. local_socks_port,
- username = (local_socks_username and local_socks_password) and local_socks_username or nil,
- password = (local_socks_username and local_socks_password) and local_socks_password or nil,
- disableUDP = false,
- } or nil,
- http = (local_http_address and local_http_port) and {
- listen = local_http_address .. ":" .. local_http_port,
- username = (local_http_username and local_http_password) and local_http_username or nil,
- password = (local_http_username and local_http_password) and local_http_password or nil,
- } or nil
- }
-
- if config.obfs and config.obfs.gecko then
- local min = tonumber(node.hysteria2_obfs_MinPacketSize) or 512
- local max = tonumber(node.hysteria2_obfs_MaxPacketSize) or 1200
- if min <= 0 or min > max or max > 2048 then
- min = 512
- max = 1200
- end
- config.obfs.gecko.minPacketSize = min
- config.obfs.gecko.maxPacketSize = max
- end
-
- return jsonc.stringify(config, 1)
-end
-
-_G.gen_config = gen_config
-
-if arg[1] then
- local func =_G[arg[1]]
- if func then
- local var = nil
- if arg[2] then
- var = jsonc.parse(arg[2])
- end
- print(func(var))
- end
-end
diff --git a/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm b/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm
index a279f3b7..0312b6b3 100644
--- a/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm
+++ b/luci-app-passwall2/luasrc/view/passwall2/global/footer.htm
@@ -133,7 +133,7 @@ local sid = "@global[0]"
const m = cbid.match(/\.node$/);
if (m) {
- html += '?id=default&name=' + 'global' + '\', \'_blank\')"><%:Log%>';
+ html += '?id=default' + '\', \'_blank\')"><%:Log%>';
}
html = '