|
18 | 18 | assert_equal,
|
19 | 19 | assert_greater_than,
|
20 | 20 | check_node_connections,
|
| 21 | + p2p_port, |
21 | 22 | )
|
22 | 23 | from test_framework.crypto.chacha20 import REKEY_INTERVAL
|
| 24 | +from test_framework.socks5 import Socks5Configuration, Socks5Server |
23 | 25 |
|
24 | 26 |
|
25 | 27 | class P2PEncrypted(BitcoinTestFramework):
|
@@ -129,6 +131,27 @@ def run_test(self):
|
129 | 131 | assert_equal(node0.getpeerinfo()[-1]["transport_protocol_type"], "v1")
|
130 | 132 | check_node_connections(node=node0, num_in=1, num_out=0)
|
131 | 133 |
|
| 134 | + conf = Socks5Configuration() |
| 135 | + conf.auth = True |
| 136 | + conf.unauth = True |
| 137 | + conf.addr = ('127.0.0.1', p2p_port(self.num_nodes)) |
| 138 | + conf.keep_alive = True |
| 139 | + proxy = Socks5Server(conf) |
| 140 | + proxy.start() |
| 141 | + args = ['-listen', f'-proxy={conf.addr[0]}:{conf.addr[1]}', '-proxyrandomize=0', '-v2onlyclearnet=1', '-v2transport=1'] |
| 142 | + self.restart_node(0, extra_args=args) |
| 143 | + self.log.info("Test -v2onlyclearnet=1 behaviour") |
| 144 | + self.log.info("Check that outbound v2 connection to an ipv4 peer is successful") |
| 145 | + node0.addnode("15.61.23.23:1234", "onetry", True) |
| 146 | + assert_equal(node0.getpeerinfo()[-1]["addr"], "15.61.23.23:1234") |
| 147 | + self.log.info("Check that outbound v1 connection to an ipv4 peer is unsuccessful") |
| 148 | + node0.addnode("8.8.8.8:1234", "onetry", False) |
| 149 | + assert all(peer["addr"] != "8.8.8.8:1234" for peer in node0.getpeerinfo()) |
| 150 | + self.log.info("Check that outbound v1 connection to an onion peer is successful") |
| 151 | + addr = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion:8333" |
| 152 | + node0.addnode(addr, "onetry", False) |
| 153 | + assert_equal(node0.getpeerinfo()[-1]["addr"], addr) |
| 154 | + |
132 | 155 |
|
133 | 156 | if __name__ == '__main__':
|
134 | 157 | P2PEncrypted(__file__).main()
|
0 commit comments