feat: add per-hop pool references in listener chains
Allow listeners to mix named pools in a single chain using pool:name syntax. Bare "pool" continues to use the listener's default pool. Replaces pool_hops field with pool_seq list; pool_hops is now a backward-compatible property. Each hop draws from its own pool and failure reporting targets the correct source pool. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -132,7 +132,7 @@ class TestHandleStatus:
|
||||
ListenerConfig(
|
||||
listen_host="0.0.0.0", listen_port=1081,
|
||||
chain=[ChainHop("socks5", "127.0.0.1", 9050)],
|
||||
pool_hops=1,
|
||||
pool_seq=["default"],
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -170,6 +170,56 @@ class TestHandleStatusPools:
|
||||
assert body["pools"]["mitm"] == {"alive": 3, "total": 8}
|
||||
|
||||
|
||||
class TestHandleStatusMultiPool:
|
||||
"""Test pool_seq appears in /status only for multi-pool listeners."""
|
||||
|
||||
def test_single_pool_no_pool_seq(self):
|
||||
"""Single-pool listener: no pool_seq in response."""
|
||||
config = Config(
|
||||
listeners=[
|
||||
ListenerConfig(
|
||||
listen_host="0.0.0.0", listen_port=1080,
|
||||
chain=[ChainHop("socks5", "127.0.0.1", 9050)],
|
||||
pool_seq=["clean", "clean"], pool_name="clean",
|
||||
),
|
||||
],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
_, body = _handle_status(ctx)
|
||||
assert "pool_seq" not in body["listeners"][0]
|
||||
|
||||
def test_multi_pool_has_pool_seq(self):
|
||||
"""Multi-pool listener: pool_seq appears in response."""
|
||||
config = Config(
|
||||
listeners=[
|
||||
ListenerConfig(
|
||||
listen_host="0.0.0.0", listen_port=1080,
|
||||
chain=[ChainHop("socks5", "127.0.0.1", 9050)],
|
||||
pool_seq=["clean", "mitm"], pool_name="clean",
|
||||
),
|
||||
],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
_, body = _handle_status(ctx)
|
||||
assert body["listeners"][0]["pool_seq"] == ["clean", "mitm"]
|
||||
assert body["listeners"][0]["pool_hops"] == 2
|
||||
|
||||
def test_multi_pool_in_config(self):
|
||||
"""Multi-pool listener: pool_seq appears in /config response."""
|
||||
config = Config(
|
||||
listeners=[
|
||||
ListenerConfig(
|
||||
listen_host="0.0.0.0", listen_port=1080,
|
||||
chain=[ChainHop("socks5", "127.0.0.1", 9050)],
|
||||
pool_seq=["clean", "mitm"], pool_name="clean",
|
||||
),
|
||||
],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
_, body = _handle_config(ctx)
|
||||
assert body["listeners"][0]["pool_seq"] == ["clean", "mitm"]
|
||||
|
||||
|
||||
class TestHandleMetrics:
|
||||
"""Test GET /metrics handler."""
|
||||
|
||||
@@ -318,7 +368,7 @@ class TestHandleConfig:
|
||||
proxy_pool=pp,
|
||||
listeners=[ListenerConfig(
|
||||
chain=[ChainHop("socks5", "127.0.0.1", 9050)],
|
||||
pool_hops=1,
|
||||
pool_seq=["default"],
|
||||
)],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
@@ -345,7 +395,7 @@ class TestHandleConfig:
|
||||
listeners=[ListenerConfig(
|
||||
listen_host="0.0.0.0", listen_port=1080,
|
||||
chain=[ChainHop("socks5", "127.0.0.1", 9050)],
|
||||
pool_hops=2, pool_name="clean",
|
||||
pool_seq=["clean", "clean"], pool_name="clean",
|
||||
)],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
|
||||
Reference in New Issue
Block a user