feat: improve warp, outbounds reputation
This commit is contained in:
18 files changed
+533
-224
No files matched your search
@@ -76,7 +76,6 @@ let
|
||||
proxySuiteScriptsDir = ../../../scripts;
|
||||
parserScriptsPythonPath = proxySuiteScriptsDir;
|
||||
buildOutboundPy = "${proxySuiteScriptsDir}/build-outbound.py";
|
||||
warpOutboundPy = "${proxySuiteScriptsDir}/warp_outbound.py";
|
||||
buildInboundPy = "${proxySuiteScriptsDir}/build-inbound.py";
|
||||
fetchSubscriptionPy = "${proxySuiteScriptsDir}/fetch-subscription.py";
|
||||
|
||||
@@ -112,7 +111,6 @@ let
|
||||
xray
|
||||
parserScriptsPythonPath
|
||||
buildOutboundPy
|
||||
warpOutboundPy
|
||||
buildInboundPy
|
||||
fetchSubscriptionPy
|
||||
;
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
if pureXrayEnabled then
|
||||
''
|
||||
def xray_bind_outbound($interface):
|
||||
if $interface == "" or .protocol == "blackhole" or .protocol == "dns" then
|
||||
# A loopback hop (the WARP tunnel, the OpenSSH listener) cannot leave through the uplink.
|
||||
if $interface == "" or .protocol == "blackhole" or .protocol == "dns"
|
||||
or ((.settings.address? // "") | test("^(127\\.|::1$|localhost$)")) then
|
||||
.
|
||||
else
|
||||
.streamSettings = (.streamSettings // {})
|
||||
@@ -87,10 +89,7 @@ else
|
||||
[.route.rules[]
|
||||
| select(((.action? // "") == "hijack-dns")
|
||||
and (((.inbound? // []) | index("xray-dns-in")) != null))];
|
||||
# sing-box runs WireGuard as an endpoint, not an outbound.
|
||||
.outbounds = ($obs | map(select(.type != "wireguard"))) + .outbounds
|
||||
| ($obs | map(select(.type == "wireguard"))) as $endpoints
|
||||
| if $endpoints == [] then . else .endpoints = (.endpoints // []) + $endpoints end
|
||||
.outbounds = $obs + .outbounds
|
||||
| if $auth_enabled then
|
||||
(.inbounds[] | select(.type == "mixed" and .tag == "mixed-in") | .users) = [{username:$user,password:$password}]
|
||||
else . end
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
python3,
|
||||
parserScriptsPythonPath,
|
||||
buildOutboundPy,
|
||||
warpOutboundPy,
|
||||
mkSubscriptionBlock,
|
||||
mkSubscriptionLoadHelperBlock,
|
||||
runtimeSubscriptionsBlock,
|
||||
@@ -319,40 +318,31 @@ let
|
||||
_proxy_suite_record_tag_source ${sshProxyTag} ssh
|
||||
'';
|
||||
|
||||
# The profile is a secret, so it is converted at start rather than baked into the store.
|
||||
# Hybrid runs WARP in sing-box, like the SSH outbound.
|
||||
# WARP runs in proxy-suite-warp-tunnel, which restarts it when the handshake stops being
|
||||
# answered. Every backend reaches it as a loopback SOCKS hop.
|
||||
mkWarpOutboundBlock =
|
||||
routingMark:
|
||||
let
|
||||
markArg = lib.optionalString (routingMark != null) " --routing-mark ${toString routingMark}";
|
||||
profile = lib.escapeShellArg warpCfg.profilePath;
|
||||
convert = ''
|
||||
OB_JSON=$(${python3} ${warpOutboundPy} --backend ${
|
||||
if pureXrayEnabled then "xray" else "sing-box"
|
||||
} --tag warp${markArg} < ${profile}) || exit 1
|
||||
'';
|
||||
blockJson =
|
||||
outbound =
|
||||
if pureXrayEnabled then
|
||||
''{"protocol":"blackhole","tag":"warp","settings":{}}''
|
||||
{
|
||||
protocol = "socks";
|
||||
tag = "warp";
|
||||
settings = {
|
||||
address = "127.0.0.1";
|
||||
port = warpCfg.tunnelPort;
|
||||
};
|
||||
}
|
||||
else
|
||||
''{"type":"block","tag":"warp"}'';
|
||||
{
|
||||
type = "socks";
|
||||
tag = "warp";
|
||||
server = "127.0.0.1";
|
||||
server_port = warpCfg.tunnelPort;
|
||||
};
|
||||
in
|
||||
''
|
||||
# outbound: warp (${if pureXrayEnabled then "XRay wireguard" else "sing-box WireGuard endpoint"})
|
||||
${
|
||||
if warpCfg.autoRegister then
|
||||
''
|
||||
if [ -s ${profile} ]; then
|
||||
${convert}
|
||||
else
|
||||
# proxy-suite-warp restarts this service once wgcf has registered.
|
||||
echo "proxy-suite: warning: no WARP profile yet; warp blocks until proxy-suite-warp registers" >&2
|
||||
OB_JSON='${blockJson}'
|
||||
fi
|
||||
''
|
||||
else
|
||||
convert
|
||||
}
|
||||
# outbound: warp (SOCKS hop to proxy-suite-warp-tunnel)
|
||||
OB_JSON=${lib.escapeShellArg (builtins.toJSON outbound)}
|
||||
${
|
||||
if hybridEnabled then
|
||||
''_proxy_suite_add_sing_box_ob "$OB_JSON"''
|
||||
@@ -420,9 +410,7 @@ let
|
||||
) proxyCfg.subscriptions;
|
||||
|
||||
sshProxyBlock = lib.optionalString sshProxyCfg.asOutbound (mkSshProxyOutboundBlock routingMark);
|
||||
warpBlock = lib.optionalString (warpCfg.enable && warpCfg.asOutbound) (
|
||||
mkWarpOutboundBlock routingMark
|
||||
);
|
||||
warpBlock = lib.optionalString (warpCfg.enable && warpCfg.asOutbound) mkWarpOutboundBlock;
|
||||
|
||||
wrapperBlock =
|
||||
if pureXrayEnabled && selectionMode == "urltest" then
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
xray,
|
||||
parserScriptsPythonPath,
|
||||
buildOutboundPy,
|
||||
warpOutboundPy,
|
||||
fetchSubscriptionPy,
|
||||
tproxyFile,
|
||||
tunFile,
|
||||
@@ -125,7 +124,6 @@ let
|
||||
python3
|
||||
parserScriptsPythonPath
|
||||
buildOutboundPy
|
||||
warpOutboundPy
|
||||
mkSubscriptionBlock
|
||||
mkSubscriptionLoadHelperBlock
|
||||
runtimeSubscriptionsBlock
|
||||
|
||||
@@ -242,22 +242,20 @@ let
|
||||
# proxy-ctl proxy outbounds test. Servers for its ping, keyed by the user's tag:
|
||||
# the wrapper may have renamed one outbound "proxy" or prefixed them all, and a
|
||||
# hybrid XRay outbound is a sing-box socks hop whose real server is the sidecar's.
|
||||
# A loopback hop (the WARP tunnel, XRay's SSH listener) has no server worth timing.
|
||||
ENDPOINTS_TMP="$RUNTIME_DIR/outbound-endpoints.json.tmp"
|
||||
${jq} -c --argjson sidecar "''${XRAY_OUTBOUNDS_JSON:-[]}" --arg collapsed "''${PROXY_TAG:-}" '
|
||||
def endpoint:
|
||||
if .server then {server, port: .server_port}
|
||||
elif (.peers | type) == "array" then {server: .peers[0].address, port: .peers[0].port}
|
||||
elif .settings.address then {server: .settings.address, port: .settings.port}
|
||||
elif .settings.vnext then {server: .settings.vnext[0].address, port: .settings.vnext[0].port}
|
||||
elif .settings.servers then {server: .settings.servers[0].address, port: .settings.servers[0].port}
|
||||
elif .settings.peers then
|
||||
.settings.peers[0].endpoint | capture("^\\[?(?<server>.*?)\\]?:(?<port>[0-9]+)$") | .port |= tonumber
|
||||
else null end;
|
||||
def udp: (.type // .protocol) as $t | ["hysteria", "hysteria2", "tuic", "wireguard"] | index($t) != null;
|
||||
def udp: (.type // .protocol) as $t | ["hysteria", "hysteria2", "tuic"] | index($t) != null;
|
||||
($sidecar | map({key: .tag, value: .}) | from_entries) as $real
|
||||
| [.[] | select(.type != "selector" and .type != "urltest")
|
||||
| (.tag | ltrimstr("proxy-suite-ob-") | if . == "proxy" then $collapsed else . end) as $tag
|
||||
| ($real[.tag] // .) | select(endpoint != null)
|
||||
| ($real[.tag] // .) | select(endpoint != null and (endpoint.server | test("^(127\\.|::1$|localhost$)") | not))
|
||||
| {key: $tag, value: (endpoint + {network: (if udp then "udp" else "tcp" end)})}]
|
||||
| from_entries
|
||||
' <<< "$OUTBOUNDS_JSON" > "$ENDPOINTS_TMP"
|
||||
|
||||
Reference in new issue
Block a user