feat: improve warp, outbounds reputation

This commit is contained in:
fufsob committed 2026-09-14 09:06:59 +00:00
1 parent 85c3e6cfaf
commit ab2167ff9c
18 files changed
+533 -224

No files matched your search

+34
View File
@@ -467,6 +467,40 @@
touch "$out"
'';
# autoProxy probe order: one exit per network first, bad exits last; and the
# strikes that make an exit bad.
autoproxy-rounds =
pkgs.runCommand "proxy-suite-autoproxy-rounds-check" { nativeBuildInputs = [ pkgs.jq ]; } ''
echo '[{"tag":"direct"},{"tag":"a"},{"tag":"b"},{"tag":"a2"},{"tag":"b2"},{"tag":"c"}]' > index.json
echo '{"exits":{"a":{"asn":"AS1","bad":true},"b":{"asn":"AS2"},"a2":{"asn":"AS1"},
"b2":{"asn":"AS2"},"c":{"asn":"AS3","bad":false}}}' > state.json
r="$(jq -c --slurpfile s state.json -f ${../../modules/proxy-suite/autoproxy-rounds.jq} index.json)"
printf '%s\n' "$r"
# A refused a takes neither AS1's first place (a2 does) nor any place before b2.
jq -e '. == {r1: "b,a2,c", r2: "b2,a", ordered: ["b", "a2", "b2", "c", "a"]}' <<<"$r" > /dev/null
k() {
jq -c --argjson tags "$1" --arg d "$2" --arg why "$3" --argjson now "$4" --argjson ttl 100 \
-f ${../../modules/proxy-suite/autoproxy-strike.jq} <<<"$5"
}
s='{"exits":{"a":{"asn":"AS1"},"b":{}}}'
# One destination is not enough, however often it strikes.
s="$(k '["a"]' sekai.test refused 1000 "$s")"
s="$(k '["a","b"]' sekai.test refused 1010 "$s")"
jq -e '.exits.a.bad == false and .exits.a.asn == "AS1" and .exits.b.bad == false' <<<"$s" > /dev/null
# A second one is.
s="$(k '["a"]' pximg.net slow 1020 "$s")"
jq -e '.exits.a | .bad and .badBy == ["sekai.test refused", "pximg.net slow"]' <<<"$s" > /dev/null
jq -e '.exits.b.bad == false' <<<"$s" > /dev/null
# A TTL later the older strike has expired.
s="$(k '[]' "" "" 1115 "$s")"
jq -e '.exits.a | (.bad | not) and .badBy == ["pximg.net slow"]' <<<"$s" > /dev/null
# A block page is the site's own verdict on the address: one is enough.
s="$(k '["b"]' colorfulpalette.org wall:aws-waf 1120 "$s")"
jq -e '.exits.b | .bad and .badBy == ["colorfulpalette.org wall:aws-waf"]' <<<"$s" > /dev/null
touch "$out"
'';
# Per-user inbound traffic collection; `proxy-ctl inbounds stats` is in proxy-ctl-unit.
inbound-stats =
pkgs.runCommand "proxy-suite-inbound-stats-check"
+48 -15
View File
@@ -7,7 +7,7 @@
let
generated = import ./read-generated.nix;
inherit (pkgs.lib) hasInfix;
inherit (pkgs.lib) hasInfix escapeShellArg;
profile = "/run/secrets/wgcf-profile.conf";
markOf = fixture: toString fixture.config.services.proxy-suite.proxy.tproxy.proxyMark;
@@ -35,12 +35,18 @@ let
fixture:
generated.readDerivation
fixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart;
tunnelOf =
fixture:
generated.readDerivation
fixture.config.systemd.services."proxy-suite-warp-tunnel".serviceConfig.ExecStart;
convertCall =
fixture: flag:
"warp_outbound.py --backend ${flag} --tag warp --routing-mark ${markOf fixture} < ${pkgs.lib.escapeShellArg profile}";
fixture: "warp_outbound.py --tag warp --routing-mark ${markOf fixture} < \"$profile\"";
singBoxHop = ''"server":"127.0.0.1","server_port":18538,"tag":"warp","type":"socks"'';
xrayHop = ''"protocol":"socks","settings":{"address":"127.0.0.1","port":18538},"tag":"warp"'';
singBox = mkFixture "sing-box" { asOutbound = true; };
singBoxStart = startOf singBox;
singBoxTunnel = tunnelOf singBox;
xray = mkFixture "xray" { asOutbound = true; };
xrayStart = startOf xray;
hybrid = mkFixture "hybrid" { asOutbound = true; };
@@ -49,7 +55,7 @@ let
asOutbound = true;
configFile = null;
};
autoStart = startOf auto;
autoTunnel = tunnelOf auto;
amneziaWg = evalProxySuite [
{
@@ -115,29 +121,53 @@ let
in
{
assertions = [
# Every backend dials the tunnel unit's loopback listener.
(
assert hasInfix (convertCall singBox "sing-box") singBoxStart;
assert hasInfix singBoxHop singBoxStart;
true
)
(
assert hasInfix "_proxy_suite_record_tag_source warp warp" singBoxStart;
true
)
# The profile is read at start; the private key never reaches the store.
(
assert !(hasInfix "PrivateKey" singBoxStart);
assert hasInfix xrayHop xrayStart;
true
)
(
assert hasInfix (convertCall xray "xray") xrayStart;
assert hasInfix singBoxHop hybridStart && hasInfix "_proxy_suite_add_sing_box_ob \"$OB_JSON\"" hybridStart;
true
)
# Only the tunnel reads the profile, at start; the private key never reaches the store.
(
assert !(hasInfix "warp_outbound.py" singBoxStart) && !(hasInfix profile singBoxStart);
true
)
(
assert hasInfix (convertCall hybrid "sing-box") hybridStart;
assert hasInfix "profile=${escapeShellArg profile}" singBoxTunnel;
true
)
(
assert hasInfix "_proxy_suite_add_sing_box_ob \"$OB_JSON\"" hybridStart;
assert hasInfix (convertCall singBox) singBoxTunnel;
true
)
(
assert !(hasInfix "PrivateKey" singBoxTunnel);
true
)
(
assert hasInfix "listen_port: 18538" singBoxTunnel;
true
)
# The resolver comes from proxy.dns.local; sing-box's "local" server fails behind resolved.
(
assert
hasInfix ''{"server":"1.1.1.1","server_port":53,"tag":"local","type":"udp"}'' singBoxTunnel
&& !(hasInfix ''type: "local"'' singBoxTunnel);
true
)
(
assert xray.config.systemd.services ? "proxy-suite-warp-tunnel";
true
)
(
@@ -148,12 +178,11 @@ in
assert auto.config.systemd.services ? "proxy-suite-warp";
true
)
# Before wgcf registers, the tunnel waits instead of failing its way through restarts.
(
assert hasInfix "if [ -s /var/lib/proxy-suite/warp/wgcf-profile.conf ]" autoStart;
true
)
(
assert hasInfix "OB_JSON='{\"type\":\"block\",\"tag\":\"warp\"}'" autoStart;
assert
hasInfix "profile=/var/lib/proxy-suite/warp/wgcf-profile.conf" autoTunnel
&& hasInfix "until [ -s \"$profile\" ]" autoTunnel;
true
)
(
@@ -164,6 +193,10 @@ in
assert amneziaWg.config.systemd.services ? "proxy-suite-awg-warp";
true
)
(
assert !(amneziaWg.config.systemd.services ? "proxy-suite-warp-tunnel");
true
)
]
++ invalidAssertions;
}