mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-16 21:43:33 +08:00
🌈 Sync 2026-05-19 02:35:14
This commit is contained in:
1 parent
595807ea37
commit
ca5e918f4b
81 files changed
+12003
-3193
No files matched your search
@@ -472,9 +472,10 @@ function get_valid_nodes()
|
||||
end
|
||||
end
|
||||
local port = e.port or e.hysteria_hop or e.hysteria2_hop
|
||||
if (port and e.address) or e.hysteria2_realms then
|
||||
local is_realm = (e.type == "Hysteria2" or 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 e.hysteria2_realms then
|
||||
if is_ip(address) or datatypes.hostname(address) or is_realm then
|
||||
if (e.type == "sing-box" or e.type == "Xray") and e.protocol then
|
||||
local protocol = e.protocol
|
||||
if protocol == "vmess" then
|
||||
@@ -501,10 +502,11 @@ function get_valid_nodes()
|
||||
type_name = type_name .. " " .. protocol
|
||||
end
|
||||
if is_ipv6(address) then address = get_ipv6_full(address) end
|
||||
type_name = is_realm and type_name .. " Realm" or type_name
|
||||
e["remark"] = trim("%s:[%s]" % {type_name, e.remarks})
|
||||
if show_node_info == "1" then
|
||||
port = (port or ""):gsub(":", "-")
|
||||
if not e.hysteria2_realms then
|
||||
if not is_realm then
|
||||
e["remark"] = trim("%s:[%s] %s:%s" % {type_name, e.remarks, address, port})
|
||||
end
|
||||
end
|
||||
@@ -596,6 +598,9 @@ 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
|
||||
type_name = type_name .. " Realm"
|
||||
end
|
||||
remarks = trim("%s:[%s]" % {type_name, n.remarks})
|
||||
end
|
||||
end
|
||||
@@ -1595,3 +1600,29 @@ function vps_domain_exclude(domain)
|
||||
if map[domain] then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
function parse_realm_uri(uri)
|
||||
if type(uri) ~= "string" then return nil end
|
||||
-- realm://token@server/realm_id?query
|
||||
local token, server_url, realm_id, query = trim(uri):match("^realm://([^@]+)@([^/]+)/([^?]*)%??(.*)$")
|
||||
if not token or not server_url or not realm_id then return nil end
|
||||
realm_id = realm_id:gsub("/+$", "")
|
||||
local realm = {
|
||||
token = token,
|
||||
server_url = server_url,
|
||||
realm_id = realm_id
|
||||
}
|
||||
-- 解析 query 中的 stun=
|
||||
if query and query ~= "" then
|
||||
local stun_servers = {}
|
||||
for key, value in query:gmatch("([^&=?]+)=([^&]+)") do
|
||||
if key == "stun" and value ~= "" then
|
||||
stun_servers[#stun_servers + 1] = value
|
||||
end
|
||||
end
|
||||
if #stun_servers > 0 then
|
||||
realm.stun_servers = stun_servers
|
||||
end
|
||||
end
|
||||
return realm
|
||||
end
|
||||
@@ -132,7 +132,7 @@ local function start()
|
||||
end
|
||||
end
|
||||
bin = ln_run("/usr/bin/microsocks", "microsocks_" .. id, string.format("-i :: -p %s %s", port, auth), log_path)
|
||||
elseif type == "SS" or type == "SSR" then
|
||||
elseif type == "SSR" then
|
||||
if user.custom == "1" and user.config_str then
|
||||
config = jsonc.parse(api.base64Decode(user.config_str))
|
||||
else
|
||||
|
||||
@@ -67,11 +67,7 @@ function gen_config(var)
|
||||
server_host = api.get_ipv6_full(server_host)
|
||||
end
|
||||
|
||||
local server = server_host .. (server_port and ":" .. server_port or "")
|
||||
|
||||
if node.hysteria2_hop then
|
||||
server = server .. (server_port and "," or ":") .. string.gsub(node.hysteria2_hop, ":", "-")
|
||||
end
|
||||
local server = server_host .. ":" .. ((server_port or "") .. "," .. (node.hysteria2_hop or "")):gsub("^[%s,]+", ""):gsub("[%s,]+$", ""):gsub(":", "-")
|
||||
|
||||
local config = {
|
||||
server = (function()
|
||||
|
||||
@@ -80,11 +80,7 @@ function gen_config(var)
|
||||
tcp_tproxy = var["tcp_tproxy"] and true or nil
|
||||
}
|
||||
|
||||
if node.type == "SS" then
|
||||
config.plugin = plugin_file or nil
|
||||
config.plugin_opts = (plugin_file) and node.plugin_opts or nil
|
||||
config.mode = mode
|
||||
elseif node.type == "SSR" then
|
||||
if node.type == "SSR" then
|
||||
config.protocol = node.protocol
|
||||
config.protocol_param = node.protocol_param
|
||||
config.obfs = node.obfs
|
||||
|
||||
@@ -103,8 +103,8 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
local run_socks_instance = true
|
||||
if proxy_table ~= nil and type(proxy_table) == "table" then
|
||||
proxy_tag = proxy_table.tag or nil
|
||||
fragment = (proxy_table.fragment and node.protocol ~= "naive") and true or nil
|
||||
record_fragment = (proxy_table.record_fragment and node.protocol ~= "naive") and true or nil
|
||||
fragment = (proxy_table.fragment and node.protocol ~= "naive" and not node.hysteria2_realms) and true or nil
|
||||
record_fragment = (proxy_table.record_fragment and node.protocol ~= "naive" and not node.hysteria2_realms) and true or nil
|
||||
run_socks_instance = proxy_table.run_socks_instance
|
||||
end
|
||||
|
||||
@@ -472,6 +472,7 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
table.insert(server_ports, range)
|
||||
end
|
||||
end
|
||||
result.server_port = nil
|
||||
end
|
||||
protocol_table = {
|
||||
server_ports = next(server_ports) and server_ports or nil,
|
||||
@@ -528,6 +529,10 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
table.insert(server_ports, range)
|
||||
end
|
||||
end
|
||||
result.server_port = nil
|
||||
end
|
||||
if node.hysteria2_realms then
|
||||
server_ports = {}
|
||||
end
|
||||
local interval, interval_max
|
||||
if next(server_ports) then
|
||||
@@ -571,7 +576,18 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
return (t and t >= 2 and t <= 60) and t or nil
|
||||
end)(node.hysteria2_keep_alive_period),
|
||||
disable_path_mtu_discovery = version_ge_1_14_0 and (tonumber(node.hysteria2_disable_mtu_discovery) == 1) or nil,
|
||||
tls = tls
|
||||
tls = tls,
|
||||
realm = node.hysteria2_realms and (function()
|
||||
result.server = nil
|
||||
result.server_port = nil
|
||||
local realm = api.parse_realm_uri(node.hysteria2_realm_url)
|
||||
if realm then
|
||||
realm.server_url = realm.server_url and "https://" .. realm.server_url or nil
|
||||
realm.stun_servers = realm.stun_servers or node.hysteria2_realm_stun
|
||||
return realm
|
||||
end
|
||||
return nil
|
||||
end)() or nil
|
||||
}
|
||||
end
|
||||
|
||||
@@ -908,7 +924,17 @@ function gen_config_server(node)
|
||||
}
|
||||
},
|
||||
ignore_client_bandwidth = (node.hysteria2_ignore_client_bandwidth == "1") and true or false,
|
||||
tls = tls
|
||||
tls = tls,
|
||||
realm = node.hysteria2_realms and (function()
|
||||
local realm = api.parse_realm_uri(node.hysteria2_realm_url)
|
||||
if realm then
|
||||
realm.server_url = realm.server_url and "https://" .. realm.server_url or nil
|
||||
realm.stun_servers = realm.stun_servers or node.hysteria2_realm_stun
|
||||
realm.stun_domain_resolver = "direct"
|
||||
return realm
|
||||
end
|
||||
return nil
|
||||
end)() or nil
|
||||
}
|
||||
end
|
||||
|
||||
@@ -2088,7 +2114,7 @@ function gen_config(var)
|
||||
if not value.detour and value.server then
|
||||
value.detour = "direct"
|
||||
end
|
||||
if value.server and not api.datatypes.hostname(value.server) then
|
||||
if (value.server and not api.datatypes.hostname(value.server)) and not value.realm then
|
||||
value.domain_resolver = nil
|
||||
end
|
||||
for k, v in pairs(config.outbounds[index]) do
|
||||
|
||||
@@ -1072,7 +1072,13 @@ function gen_config(var)
|
||||
type = _node.balancingStrategy,
|
||||
settings = {
|
||||
expected = _node.expected and tonumber(_node.expected) and tonumber(_node.expected) or 2,
|
||||
maxRTT = "1s"
|
||||
maxRTT = "1s",
|
||||
tolerance = (function(t)
|
||||
t = tonumber(t) or 0
|
||||
if t < 1 then return nil end
|
||||
if t > 100 then t = 100 end
|
||||
return t / 100
|
||||
end)(_node.tolerance)
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user