feat: add bypass rules, weighted pool selection, integration tests
Per-listener bypass rules skip the chain for local/private destinations (CIDR, exact IP/hostname, domain suffix). Weighted multi-candidate pool selection biases toward pools with more alive proxies. End-to-end integration tests validate the full client->s5p->hop->target path using mock SOCKS5 proxies. 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_seq=["default"],
|
||||
pool_seq=[["default"]],
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -180,7 +180,7 @@ class TestHandleStatusMultiPool:
|
||||
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",
|
||||
pool_seq=[["clean"], ["clean"]], pool_name="clean",
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -195,13 +195,13 @@ class TestHandleStatusMultiPool:
|
||||
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",
|
||||
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_seq"] == [["clean"], ["mitm"]]
|
||||
assert body["listeners"][0]["pool_hops"] == 2
|
||||
|
||||
def test_multi_pool_in_config(self):
|
||||
@@ -211,13 +211,13 @@ class TestHandleStatusMultiPool:
|
||||
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",
|
||||
pool_seq=[["clean"], ["mitm"]], pool_name="clean",
|
||||
),
|
||||
],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
_, body = _handle_config(ctx)
|
||||
assert body["listeners"][0]["pool_seq"] == ["clean", "mitm"]
|
||||
assert body["listeners"][0]["pool_seq"] == [["clean"], ["mitm"]]
|
||||
|
||||
|
||||
class TestHandleMetrics:
|
||||
@@ -395,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_seq=["clean", "clean"], pool_name="clean",
|
||||
pool_seq=[["clean"], ["clean"]], pool_name="clean",
|
||||
)],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
|
||||
Reference in New Issue
Block a user