Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_proxy.py
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | def setup_nodes(self): | ||||
self.add_nodes(self.num_nodes, extra_args=args) | self.add_nodes(self.num_nodes, extra_args=args) | ||||
self.start_nodes() | self.start_nodes() | ||||
def node_test(self, node, proxies, auth, test_onion=True): | def node_test(self, node, proxies, auth, test_onion=True): | ||||
rv = [] | rv = [] | ||||
# Test: outgoing IPv4 connection through node | # Test: outgoing IPv4 connection through node | ||||
node.addnode("15.61.23.23:1234", "onetry") | node.addnode("15.61.23.23:1234", "onetry") | ||||
cmd = proxies[0].queue.get() | cmd = proxies[0].queue.get() | ||||
assert(isinstance(cmd, Socks5Command)) | assert isinstance(cmd, Socks5Command) | ||||
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, | # Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, | ||||
# even if connecting directly to IPv4/IPv6 | # even if connecting directly to IPv4/IPv6 | ||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME) | assert_equal(cmd.atyp, AddressType.DOMAINNAME) | ||||
assert_equal(cmd.addr, b"15.61.23.23") | assert_equal(cmd.addr, b"15.61.23.23") | ||||
assert_equal(cmd.port, 1234) | assert_equal(cmd.port, 1234) | ||||
if not auth: | if not auth: | ||||
assert_equal(cmd.username, None) | assert_equal(cmd.username, None) | ||||
assert_equal(cmd.password, None) | assert_equal(cmd.password, None) | ||||
rv.append(cmd) | rv.append(cmd) | ||||
if self.have_ipv6: | if self.have_ipv6: | ||||
# Test: outgoing IPv6 connection through node | # Test: outgoing IPv6 connection through node | ||||
node.addnode( | node.addnode( | ||||
"[1233:3432:2434:2343:3234:2345:6546:4534]:5443", "onetry") | "[1233:3432:2434:2343:3234:2345:6546:4534]:5443", "onetry") | ||||
cmd = proxies[1].queue.get() | cmd = proxies[1].queue.get() | ||||
assert(isinstance(cmd, Socks5Command)) | assert isinstance(cmd, Socks5Command) | ||||
# Note: bitcoind's SOCKS5 implementation only sends atyp | # Note: bitcoind's SOCKS5 implementation only sends atyp | ||||
# DOMAINNAME, even if connecting directly to IPv4/IPv6 | # DOMAINNAME, even if connecting directly to IPv4/IPv6 | ||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME) | assert_equal(cmd.atyp, AddressType.DOMAINNAME) | ||||
assert_equal(cmd.addr, b"1233:3432:2434:2343:3234:2345:6546:4534") | assert_equal(cmd.addr, b"1233:3432:2434:2343:3234:2345:6546:4534") | ||||
assert_equal(cmd.port, 5443) | assert_equal(cmd.port, 5443) | ||||
if not auth: | if not auth: | ||||
assert_equal(cmd.username, None) | assert_equal(cmd.username, None) | ||||
assert_equal(cmd.password, None) | assert_equal(cmd.password, None) | ||||
rv.append(cmd) | rv.append(cmd) | ||||
if test_onion: | if test_onion: | ||||
# Test: outgoing onion connection through node | # Test: outgoing onion connection through node | ||||
node.addnode("bitcoinostk4e4re.onion:8333", "onetry") | node.addnode("bitcoinostk4e4re.onion:8333", "onetry") | ||||
cmd = proxies[2].queue.get() | cmd = proxies[2].queue.get() | ||||
assert(isinstance(cmd, Socks5Command)) | assert isinstance(cmd, Socks5Command) | ||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME) | assert_equal(cmd.atyp, AddressType.DOMAINNAME) | ||||
assert_equal(cmd.addr, b"bitcoinostk4e4re.onion") | assert_equal(cmd.addr, b"bitcoinostk4e4re.onion") | ||||
assert_equal(cmd.port, 8333) | assert_equal(cmd.port, 8333) | ||||
if not auth: | if not auth: | ||||
assert_equal(cmd.username, None) | assert_equal(cmd.username, None) | ||||
assert_equal(cmd.password, None) | assert_equal(cmd.password, None) | ||||
rv.append(cmd) | rv.append(cmd) | ||||
# Test: outgoing DNS name connection through node | # Test: outgoing DNS name connection through node | ||||
node.addnode("node.noumenon:8333", "onetry") | node.addnode("node.noumenon:8333", "onetry") | ||||
cmd = proxies[3].queue.get() | cmd = proxies[3].queue.get() | ||||
assert(isinstance(cmd, Socks5Command)) | assert isinstance(cmd, Socks5Command) | ||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME) | assert_equal(cmd.atyp, AddressType.DOMAINNAME) | ||||
assert_equal(cmd.addr, b"node.noumenon") | assert_equal(cmd.addr, b"node.noumenon") | ||||
assert_equal(cmd.port, 8333) | assert_equal(cmd.port, 8333) | ||||
if not auth: | if not auth: | ||||
assert_equal(cmd.username, None) | assert_equal(cmd.username, None) | ||||
assert_equal(cmd.password, None) | assert_equal(cmd.password, None) | ||||
rv.append(cmd) | rv.append(cmd) | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |