mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 13:03:56 +08:00
🍕 Sync 2026-09-14 23:30:37
This commit is contained in:
1 parent
0603b094cf
commit
81fe4cd866
214 files changed
+10806
-2630
No files matched your search
@@ -12,7 +12,7 @@ local GLOBAL = {
|
||||
|
||||
local xray_version = api.get_app_version("xray")
|
||||
|
||||
local xray_min_version = "26.3.27"
|
||||
local xray_min_version = "26.7.11"
|
||||
|
||||
local function get_domain_excluded()
|
||||
local path = string.format("/usr/share/%s/rules/domains_excluded", api.c_config)
|
||||
@@ -58,31 +58,50 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
if node.type ~= "Xray" then
|
||||
if node.type == "Socks" then
|
||||
node.protocol = "socks"
|
||||
node.transport = "tcp"
|
||||
node.transport = "raw"
|
||||
else
|
||||
local relay_port = node.port
|
||||
local new_port = api.get_new_port()
|
||||
local config_file = string.format("%s_%s_%s.json", flag, tag, new_port)
|
||||
if tag and node_id and not tag:find(node_id) then
|
||||
config_file = string.format("%s_%s_%s_%s.json", flag, tag, node_id, new_port)
|
||||
end
|
||||
local new_port
|
||||
if run_socks_instance then
|
||||
sys.call(string.format('/usr/share/passwall/app.sh run_socks "%s"> /dev/null',
|
||||
string.format("flag=%s node=%s bind=%s socks_port=%s config_file=%s relay_port=%s",
|
||||
new_port, --flag
|
||||
node_id, --node
|
||||
"127.0.0.1", --bind
|
||||
new_port, --socks port
|
||||
config_file, --config file
|
||||
(proxy_tag and relay_port) and tostring(relay_port) or "" --relay port
|
||||
local relay_port = (proxy_tag and node.port) and tostring(node.port) or ""
|
||||
if relay_port == "" then
|
||||
local cache = api.get_socks_port_by_cache(node_id)
|
||||
if cache then
|
||||
new_port = cache
|
||||
run_socks_instance = nil
|
||||
end
|
||||
end
|
||||
if run_socks_instance then
|
||||
new_port = api.get_new_port()
|
||||
local config_file = string.format("nodesocks_%s_%s.json", node_id, new_port)
|
||||
if tag and node_id and not tag:find(node_id) then
|
||||
config_file = string.format("nodesocks_%s_%s_%s.json", tag, node_id, new_port)
|
||||
end
|
||||
sys.call(string.format('/usr/share/passwall/app.sh run_socks "%s"> /dev/null',
|
||||
string.format("flag=%s node=%s bind=%s socks_port=%s config_file=%s relay_port=%s",
|
||||
new_port, --flag
|
||||
node_id, --node
|
||||
"127.0.0.1", --bind
|
||||
new_port, --socks port
|
||||
config_file, --config file
|
||||
relay_port --relay port
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
if relay_port == "" then
|
||||
api.set_socks_port_to_cache(node_id, new_port)
|
||||
end
|
||||
end
|
||||
else
|
||||
TMP_PORT = TMP_PORT and TMP_PORT + 1 or 3001 -- 导出配置时作为演示
|
||||
new_port = TMP_PORT
|
||||
end
|
||||
if new_port then
|
||||
node = {}
|
||||
node.protocol = "socks"
|
||||
node.transport = "raw"
|
||||
node.address = "127.0.0.1"
|
||||
node.port = new_port
|
||||
end
|
||||
node = {}
|
||||
node.protocol = "socks"
|
||||
node.transport = "tcp"
|
||||
node.address = "127.0.0.1"
|
||||
node.port = new_port
|
||||
end
|
||||
node.stream_security = "none"
|
||||
proxy_tag = "socks <- " .. node_id
|
||||
@@ -156,7 +175,7 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
} or nil,
|
||||
dialerProxy = dialer_proxy_tag,
|
||||
},
|
||||
[(api.compare_versions(xray_version, "<", "26.7.11")) and "network" or "method"] = node.transport, -- Todo: Remove version check and "network"
|
||||
method = node.transport,
|
||||
security = node.stream_security,
|
||||
tlsSettings = (node.stream_security == "tls") and {
|
||||
serverName = node.tls_serverName,
|
||||
@@ -483,7 +502,7 @@ function gen_config_server(node)
|
||||
local settings = nil
|
||||
local routing = nil
|
||||
local outbounds = {
|
||||
{ protocol = "freedom", tag = "direct", settings = { finalRules = {{ action = "allow" }}}}, { protocol = "blackhole", tag = "blocked" }
|
||||
{ protocol = "freedom", tag = "direct", finalRules = {{ action = "allow" }}}, { protocol = "blackhole", tag = "blocked" }
|
||||
}
|
||||
|
||||
local users = node.users or {}
|
||||
@@ -631,9 +650,7 @@ function gen_config_server(node)
|
||||
interface = node.outbound_node_iface
|
||||
}
|
||||
},
|
||||
settings = {
|
||||
finalRules = {{ action = "allow" }}
|
||||
}
|
||||
finalRules = {{ action = "allow" }}
|
||||
}
|
||||
sys.call(string.format("mkdir -p %s && touch %s/%s", api.TMP_IFACE_PATH, api.TMP_IFACE_PATH, node.outbound_node_iface))
|
||||
else
|
||||
@@ -675,7 +692,7 @@ function gen_config_server(node)
|
||||
protocol = node.protocol,
|
||||
settings = settings,
|
||||
streamSettings = {
|
||||
[(api.compare_versions(xray_version, "<", "26.7.11")) and "network" or "method"] = node.transport, -- Todo: Remove version check and "network"
|
||||
method = node.transport,
|
||||
security = "none",
|
||||
tlsSettings = ("1" == node.tls) and {
|
||||
disableSystemRoot = false,
|
||||
@@ -857,9 +874,6 @@ function gen_config_server(node)
|
||||
config.outbounds[index][k] = nil
|
||||
end
|
||||
end
|
||||
if value.protocol == "freedom" and api.compare_versions(xray_version, "<", "26.5.3") then -- Todo is to remove it
|
||||
value.settings = nil
|
||||
end
|
||||
end
|
||||
|
||||
return config
|
||||
@@ -1316,9 +1330,7 @@ function gen_config(var)
|
||||
interface = node.iface
|
||||
}
|
||||
},
|
||||
settings = (api.compare_versions(xray_version, ">", "26.4.25")) and { -- Todo: Remove version check
|
||||
finalRules = {{ action = "allow" }}
|
||||
} or nil
|
||||
finalRules = {{ action = "allow" }}
|
||||
}
|
||||
sys.call(string.format("mkdir -p %s && touch %s/%s", api.TMP_IFACE_PATH, api.TMP_IFACE_PATH, node.iface))
|
||||
end
|
||||
@@ -1802,11 +1814,10 @@ function gen_config(var)
|
||||
sockopt = { dialerProxy = (dns_outbound_tag ~= "blackhole") and dns_outbound_tag or "direct" }
|
||||
} or nil,
|
||||
settings = {
|
||||
address = (chn_list ~= "proxy") and "8.8.8.8" or "223.5.5.5",
|
||||
port = 53,
|
||||
network = "tcp",
|
||||
nonIPQuery = (api.compare_versions(xray_version, "<", "26.4.25")) and "reject" or nil, -- Todo is to remove it
|
||||
rules = (api.compare_versions(xray_version, ">", "26.4.17")) and {} or nil
|
||||
rewriteAddress = (chn_list ~= "proxy") and "8.8.8.8" or "223.5.5.5",
|
||||
rewritePort = 53,
|
||||
rewriteNetwork = "tcp",
|
||||
rules = {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2030,9 +2041,7 @@ function gen_config(var)
|
||||
local direct_outbound = {
|
||||
protocol = "freedom",
|
||||
tag = "direct",
|
||||
settings = (api.compare_versions(xray_version, ">", "26.4.25")) and { -- Todo: Remove version check
|
||||
finalRules = {{ action = "allow" }}
|
||||
} or nil,
|
||||
finalRules = {{ action = "allow" }},
|
||||
streamSettings = {
|
||||
sockopt = {
|
||||
mark = 255,
|
||||
@@ -2136,7 +2145,7 @@ function gen_proto_config(var)
|
||||
local outbound = {
|
||||
protocol = server_proto,
|
||||
streamSettings = {
|
||||
network = "tcp",
|
||||
method = "raw",
|
||||
security = "none"
|
||||
},
|
||||
settings = {
|
||||
@@ -2161,10 +2170,10 @@ function gen_proto_config(var)
|
||||
table.insert(outbounds, {
|
||||
protocol = "freedom",
|
||||
tag = "direct",
|
||||
settings = (api.compare_versions(xray_version, ">", "26.4.25")) and { -- Todo: Remove version check
|
||||
finalRules = {{ action = "allow" }}
|
||||
} or nil,
|
||||
sockopt = {mark = 255}
|
||||
finalRules = {{ action = "allow" }},
|
||||
streamSettings = {
|
||||
sockopt = {mark = 255}
|
||||
}
|
||||
})
|
||||
|
||||
local config = {
|
||||
@@ -2176,7 +2185,10 @@ function gen_proto_config(var)
|
||||
-- 传出连接
|
||||
outbounds = outbounds,
|
||||
-- 路由
|
||||
routing = routing
|
||||
routing = routing,
|
||||
version = {
|
||||
min = xray_min_version
|
||||
}
|
||||
}
|
||||
return jsonc.stringify(config, 1)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user