| 64 | self.setup_clean_chain = True |
| 65 | |
| 66 | def setup_nodes(self): |
| 67 | self.have_ipv6 = test_ipv6_local() |
| 68 | # Create two proxies on different ports |
| 69 | # ... one unauthenticated |
| 70 | self.conf1 = Socks5Configuration() |
| 71 | self.conf1.addr = ('127.0.0.1', RANGE_BEGIN + (os.getpid() % 1000)) |
| 72 | self.conf1.unauth = True |
| 73 | self.conf1.auth = False |
| 74 | # ... one supporting authenticated and unauthenticated (Tor) |
| 75 | self.conf2 = Socks5Configuration() |
| 76 | self.conf2.addr = ('127.0.0.1', RANGE_BEGIN + 1000 + (os.getpid() % 1000)) |
| 77 | self.conf2.unauth = True |
| 78 | self.conf2.auth = True |
| 79 | if self.have_ipv6: |
| 80 | # ... one on IPv6 with similar configuration |
| 81 | self.conf3 = Socks5Configuration() |
| 82 | self.conf3.af = socket.AF_INET6 |
| 83 | self.conf3.addr = ('::1', RANGE_BEGIN + 2000 + (os.getpid() % 1000)) |
| 84 | self.conf3.unauth = True |
| 85 | self.conf3.auth = True |
| 86 | else: |
| 87 | self.log.warning("Testing without local IPv6 support") |
| 88 | |
| 89 | self.serv1 = Socks5Server(self.conf1) |
| 90 | self.serv1.start() |
| 91 | self.serv2 = Socks5Server(self.conf2) |
| 92 | self.serv2.start() |
| 93 | if self.have_ipv6: |
| 94 | self.serv3 = Socks5Server(self.conf3) |
| 95 | self.serv3.start() |
| 96 | |
| 97 | # We will not try to connect to this. |
| 98 | self.i2p_sam = ('127.0.0.1', 7656) |
| 99 | |
| 100 | # Note: proxies are not used to connect to local nodes. This is because the proxy to |
| 101 | # use is based on CService.GetNetwork(), which returns NET_UNROUTABLE for localhost. |
| 102 | args = [ |
| 103 | ['-listen', f'-proxy={self.conf1.addr[0]}:{self.conf1.addr[1]}','-proxyrandomize=1'], |
| 104 | ['-listen', f'-proxy={self.conf1.addr[0]}:{self.conf1.addr[1]}',f'-onion={self.conf2.addr[0]}:{self.conf2.addr[1]}', |
| 105 | f'-i2psam={self.i2p_sam[0]}:{self.i2p_sam[1]}', '-i2pacceptincoming=0', '-proxyrandomize=0'], |
| 106 | ['-listen', f'-proxy={self.conf2.addr[0]}:{self.conf2.addr[1]}','-proxyrandomize=1'], |
| 107 | [], |
| 108 | ['-listen', f'-proxy={self.conf1.addr[0]}:{self.conf1.addr[1]}','-proxyrandomize=1', |
| 109 | '-cjdnsreachable'] |
| 110 | ] |
| 111 | if self.have_ipv6: |
| 112 | args[3] = ['-listen', f'-proxy=[{self.conf3.addr[0]}]:{self.conf3.addr[1]}','-proxyrandomize=0', '-noonion'] |
| 113 | self.add_nodes(self.num_nodes, extra_args=args) |
| 114 | self.start_nodes() |
| 115 | |
| 116 | def network_test(self, node, addr, network): |
| 117 | for peer in node.getpeerinfo(): |