|
|
@ -12,6 +12,7 @@ Test plan:
|
|
|
|
- `-proxy` (proxy everything)
|
|
|
|
- `-proxy` (proxy everything)
|
|
|
|
- `-onion` (proxy just onions)
|
|
|
|
- `-onion` (proxy just onions)
|
|
|
|
- `-proxyrandomize` Circuit randomization
|
|
|
|
- `-proxyrandomize` Circuit randomization
|
|
|
|
|
|
|
|
- `-cjdnsreachable`
|
|
|
|
- Proxy configurations to test on proxy side,
|
|
|
|
- Proxy configurations to test on proxy side,
|
|
|
|
- support no authentication (other proxy)
|
|
|
|
- support no authentication (other proxy)
|
|
|
|
- support no authentication + user/pass authentication (Tor)
|
|
|
|
- support no authentication + user/pass authentication (Tor)
|
|
|
@ -26,6 +27,7 @@ addnode connect to IPv4
|
|
|
|
addnode connect to IPv6
|
|
|
|
addnode connect to IPv6
|
|
|
|
addnode connect to onion
|
|
|
|
addnode connect to onion
|
|
|
|
addnode connect to generic DNS name
|
|
|
|
addnode connect to generic DNS name
|
|
|
|
|
|
|
|
addnode connect to a CJDNS address
|
|
|
|
|
|
|
|
|
|
|
|
- Test getnetworkinfo for each node
|
|
|
|
- Test getnetworkinfo for each node
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -58,7 +60,7 @@ NETWORKS = frozenset({NET_IPV4, NET_IPV6, NET_ONION, NET_I2P, NET_CJDNS})
|
|
|
|
|
|
|
|
|
|
|
|
class ProxyTest(BitcoinTestFramework):
|
|
|
|
class ProxyTest(BitcoinTestFramework):
|
|
|
|
def set_test_params(self):
|
|
|
|
def set_test_params(self):
|
|
|
|
self.num_nodes = 4
|
|
|
|
self.num_nodes = 5
|
|
|
|
self.setup_clean_chain = True
|
|
|
|
self.setup_clean_chain = True
|
|
|
|
|
|
|
|
|
|
|
|
def setup_nodes(self):
|
|
|
|
def setup_nodes(self):
|
|
|
@ -102,7 +104,9 @@ class ProxyTest(BitcoinTestFramework):
|
|
|
|
['-listen', f'-proxy={self.conf1.addr[0]}:{self.conf1.addr[1]}',f'-onion={self.conf2.addr[0]}:{self.conf2.addr[1]}',
|
|
|
|
['-listen', f'-proxy={self.conf1.addr[0]}:{self.conf1.addr[1]}',f'-onion={self.conf2.addr[0]}:{self.conf2.addr[1]}',
|
|
|
|
f'-i2psam={self.i2p_sam[0]}:{self.i2p_sam[1]}', '-i2pacceptincoming=0', '-proxyrandomize=0'],
|
|
|
|
f'-i2psam={self.i2p_sam[0]}:{self.i2p_sam[1]}', '-i2pacceptincoming=0', '-proxyrandomize=0'],
|
|
|
|
['-listen', f'-proxy={self.conf2.addr[0]}:{self.conf2.addr[1]}','-proxyrandomize=1'],
|
|
|
|
['-listen', f'-proxy={self.conf2.addr[0]}:{self.conf2.addr[1]}','-proxyrandomize=1'],
|
|
|
|
[]
|
|
|
|
[],
|
|
|
|
|
|
|
|
['-listen', f'-proxy={self.conf1.addr[0]}:{self.conf1.addr[1]}','-proxyrandomize=1',
|
|
|
|
|
|
|
|
'-cjdnsreachable']
|
|
|
|
]
|
|
|
|
]
|
|
|
|
if self.have_ipv6:
|
|
|
|
if self.have_ipv6:
|
|
|
|
args[3] = ['-listen', f'-proxy=[{self.conf3.addr[0]}]:{self.conf3.addr[1]}','-proxyrandomize=0', '-noonion']
|
|
|
|
args[3] = ['-listen', f'-proxy=[{self.conf3.addr[0]}]:{self.conf3.addr[1]}','-proxyrandomize=0', '-noonion']
|
|
|
@ -114,7 +118,7 @@ class ProxyTest(BitcoinTestFramework):
|
|
|
|
if peer["addr"] == addr:
|
|
|
|
if peer["addr"] == addr:
|
|
|
|
assert_equal(peer["network"], network)
|
|
|
|
assert_equal(peer["network"], network)
|
|
|
|
|
|
|
|
|
|
|
|
def node_test(self, node, *, proxies, auth, test_onion):
|
|
|
|
def node_test(self, node, *, proxies, auth, test_onion, test_cjdns):
|
|
|
|
rv = []
|
|
|
|
rv = []
|
|
|
|
addr = "15.61.23.23:1234"
|
|
|
|
addr = "15.61.23.23:1234"
|
|
|
|
self.log.debug(f"Test: outgoing IPv4 connection through node for address {addr}")
|
|
|
|
self.log.debug(f"Test: outgoing IPv4 connection through node for address {addr}")
|
|
|
@ -162,6 +166,21 @@ class ProxyTest(BitcoinTestFramework):
|
|
|
|
rv.append(cmd)
|
|
|
|
rv.append(cmd)
|
|
|
|
self.network_test(node, addr, network=NET_ONION)
|
|
|
|
self.network_test(node, addr, network=NET_ONION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if test_cjdns:
|
|
|
|
|
|
|
|
addr = "[fc00:1:2:3:4:5:6:7]:8888"
|
|
|
|
|
|
|
|
self.log.debug(f"Test: outgoing CJDNS connection through node for address {addr}")
|
|
|
|
|
|
|
|
node.addnode(addr, "onetry")
|
|
|
|
|
|
|
|
cmd = proxies[1].queue.get()
|
|
|
|
|
|
|
|
assert isinstance(cmd, Socks5Command)
|
|
|
|
|
|
|
|
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
|
|
|
|
|
|
|
|
assert_equal(cmd.addr, b"fc00:1:2:3:4:5:6:7")
|
|
|
|
|
|
|
|
assert_equal(cmd.port, 8888)
|
|
|
|
|
|
|
|
if not auth:
|
|
|
|
|
|
|
|
assert_equal(cmd.username, None)
|
|
|
|
|
|
|
|
assert_equal(cmd.password, None)
|
|
|
|
|
|
|
|
rv.append(cmd)
|
|
|
|
|
|
|
|
self.network_test(node, addr, network=NET_CJDNS)
|
|
|
|
|
|
|
|
|
|
|
|
addr = "node.noumenon:8333"
|
|
|
|
addr = "node.noumenon:8333"
|
|
|
|
self.log.debug(f"Test: outgoing DNS name connection through node for address {addr}")
|
|
|
|
self.log.debug(f"Test: outgoing DNS name connection through node for address {addr}")
|
|
|
|
node.addnode(addr, "onetry")
|
|
|
|
node.addnode(addr, "onetry")
|
|
|
@ -182,17 +201,17 @@ class ProxyTest(BitcoinTestFramework):
|
|
|
|
# basic -proxy
|
|
|
|
# basic -proxy
|
|
|
|
self.node_test(self.nodes[0],
|
|
|
|
self.node_test(self.nodes[0],
|
|
|
|
proxies=[self.serv1, self.serv1, self.serv1, self.serv1],
|
|
|
|
proxies=[self.serv1, self.serv1, self.serv1, self.serv1],
|
|
|
|
auth=False, test_onion=True)
|
|
|
|
auth=False, test_onion=True, test_cjdns=False)
|
|
|
|
|
|
|
|
|
|
|
|
# -proxy plus -onion
|
|
|
|
# -proxy plus -onion
|
|
|
|
self.node_test(self.nodes[1],
|
|
|
|
self.node_test(self.nodes[1],
|
|
|
|
proxies=[self.serv1, self.serv1, self.serv2, self.serv1],
|
|
|
|
proxies=[self.serv1, self.serv1, self.serv2, self.serv1],
|
|
|
|
auth=False, test_onion=True)
|
|
|
|
auth=False, test_onion=True, test_cjdns=False)
|
|
|
|
|
|
|
|
|
|
|
|
# -proxy plus -onion, -proxyrandomize
|
|
|
|
# -proxy plus -onion, -proxyrandomize
|
|
|
|
rv = self.node_test(self.nodes[2],
|
|
|
|
rv = self.node_test(self.nodes[2],
|
|
|
|
proxies=[self.serv2, self.serv2, self.serv2, self.serv2],
|
|
|
|
proxies=[self.serv2, self.serv2, self.serv2, self.serv2],
|
|
|
|
auth=True, test_onion=True)
|
|
|
|
auth=True, test_onion=True, test_cjdns=False)
|
|
|
|
# Check that credentials as used for -proxyrandomize connections are unique
|
|
|
|
# Check that credentials as used for -proxyrandomize connections are unique
|
|
|
|
credentials = set((x.username,x.password) for x in rv)
|
|
|
|
credentials = set((x.username,x.password) for x in rv)
|
|
|
|
assert_equal(len(credentials), len(rv))
|
|
|
|
assert_equal(len(credentials), len(rv))
|
|
|
@ -201,7 +220,12 @@ class ProxyTest(BitcoinTestFramework):
|
|
|
|
# proxy on IPv6 localhost
|
|
|
|
# proxy on IPv6 localhost
|
|
|
|
self.node_test(self.nodes[3],
|
|
|
|
self.node_test(self.nodes[3],
|
|
|
|
proxies=[self.serv3, self.serv3, self.serv3, self.serv3],
|
|
|
|
proxies=[self.serv3, self.serv3, self.serv3, self.serv3],
|
|
|
|
auth=False, test_onion=False)
|
|
|
|
auth=False, test_onion=False, test_cjdns=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -proxy=unauth -proxyrandomize=1 -cjdnsreachable
|
|
|
|
|
|
|
|
self.node_test(self.nodes[4],
|
|
|
|
|
|
|
|
proxies=[self.serv1, self.serv1, self.serv1, self.serv1],
|
|
|
|
|
|
|
|
auth=False, test_onion=True, test_cjdns=True)
|
|
|
|
|
|
|
|
|
|
|
|
def networks_dict(d):
|
|
|
|
def networks_dict(d):
|
|
|
|
r = {}
|
|
|
|
r = {}
|
|
|
@ -266,6 +290,21 @@ class ProxyTest(BitcoinTestFramework):
|
|
|
|
assert_equal(n3['i2p']['reachable'], False)
|
|
|
|
assert_equal(n3['i2p']['reachable'], False)
|
|
|
|
assert_equal(n3['cjdns']['reachable'], False)
|
|
|
|
assert_equal(n3['cjdns']['reachable'], False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n4 = networks_dict(self.nodes[4].getnetworkinfo())
|
|
|
|
|
|
|
|
assert_equal(NETWORKS, n4.keys())
|
|
|
|
|
|
|
|
for net in NETWORKS:
|
|
|
|
|
|
|
|
if net == NET_I2P:
|
|
|
|
|
|
|
|
expected_proxy = ''
|
|
|
|
|
|
|
|
expected_randomize = False
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
expected_proxy = '%s:%i' % (self.conf1.addr)
|
|
|
|
|
|
|
|
expected_randomize = True
|
|
|
|
|
|
|
|
assert_equal(n4[net]['proxy'], expected_proxy)
|
|
|
|
|
|
|
|
assert_equal(n4[net]['proxy_randomize_credentials'], expected_randomize)
|
|
|
|
|
|
|
|
assert_equal(n4['onion']['reachable'], True)
|
|
|
|
|
|
|
|
assert_equal(n4['i2p']['reachable'], False)
|
|
|
|
|
|
|
|
assert_equal(n4['cjdns']['reachable'], True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
ProxyTest().main()
|
|
|
|
ProxyTest().main()
|
|
|
|