feat: multi-Tor round-robin via tor_nodes config
New top-level tor_nodes list distributes traffic across multiple Tor SOCKS proxies. First hop is replaced at connection time by round-robin selection; health tests also rotate across all nodes. FirstHopPools are created for each node when pool_size > 0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,7 @@ class TestConfig:
|
||||
assert c.max_connections == 256
|
||||
assert c.pool_size == 0
|
||||
assert c.pool_max_idle == 30.0
|
||||
assert c.tor_nodes == []
|
||||
|
||||
def test_max_connections_from_yaml(self, tmp_path):
|
||||
cfg_file = tmp_path / "test.yaml"
|
||||
@@ -221,6 +222,31 @@ class TestConfig:
|
||||
]
|
||||
|
||||
|
||||
class TestTorNodes:
|
||||
"""Test tor_nodes config parsing."""
|
||||
|
||||
def test_tor_nodes_from_yaml(self, tmp_path):
|
||||
cfg_file = tmp_path / "test.yaml"
|
||||
cfg_file.write_text(
|
||||
"tor_nodes:\n"
|
||||
" - socks5://10.200.1.1:9050\n"
|
||||
" - socks5://10.200.1.254:9050\n"
|
||||
" - socks5://10.200.1.13:9050\n"
|
||||
)
|
||||
c = load_config(cfg_file)
|
||||
assert len(c.tor_nodes) == 3
|
||||
assert c.tor_nodes[0].host == "10.200.1.1"
|
||||
assert c.tor_nodes[0].port == 9050
|
||||
assert c.tor_nodes[1].host == "10.200.1.254"
|
||||
assert c.tor_nodes[2].host == "10.200.1.13"
|
||||
|
||||
def test_no_tor_nodes(self, tmp_path):
|
||||
cfg_file = tmp_path / "test.yaml"
|
||||
cfg_file.write_text("listen: 1080\n")
|
||||
c = load_config(cfg_file)
|
||||
assert c.tor_nodes == []
|
||||
|
||||
|
||||
class TestListenerConfig:
|
||||
"""Test multi-listener config parsing."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user