Skip to content

Commit 12ff4be

Browse files
committed
test: ensure -rpcallowip is compatible with RFC4193
1 parent c02bd3c commit 12ff4be

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/functional/rpc_bind.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from test_framework.netutil import all_interfaces, addr_to_hex, get_bind_addrs, test_ipv6_local
88
from test_framework.test_framework import BitcoinTestFramework, SkipTest
9+
from test_framework.test_node import ErrorMatch
910
from test_framework.util import assert_equal, assert_raises_rpc_error, get_rpc_proxy, rpc_port, rpc_url
1011

1112
class RPCBindTest(BitcoinTestFramework):
@@ -75,6 +76,25 @@ def run_allowip_test(self, allow_ips, rpchost, rpcport):
7576
node.getnetworkinfo()
7677
self.stop_nodes()
7778

79+
def run_invalid_allowip_test(self):
80+
'''
81+
Check parameter interaction with -rpcallowip and -cjdnsreachable.
82+
RFC4193 addresses are fc00::/7 like CJDNS but have an optional
83+
"local" L bit making them fd00:: which should always be OK.
84+
'''
85+
self.log.info("Allow RFC4193 when compatible with CJDNS options")
86+
# Don't rpcallow RFC4193 with L-bit=0 if CJDNS is enabled
87+
self.nodes[0].assert_start_raises_init_error(
88+
["-rpcallowip=fc00:db8:c0:ff:ee::/80","-cjdnsreachable"],
89+
"Invalid -rpcallowip subnet specification",
90+
match=ErrorMatch.PARTIAL_REGEX)
91+
# OK to rpcallow RFC4193 with L-bit=1 if CJDNS is enabled
92+
self.start_node(0, ["-rpcallowip=fd00:db8:c0:ff:ee::/80","-cjdnsreachable"])
93+
self.stop_nodes()
94+
# OK to rpcallow RFC4193 with L-bit=0 if CJDNS is not enabled
95+
self.start_node(0, ["-rpcallowip=fc00:db8:c0:ff:ee::/80"])
96+
self.stop_nodes()
97+
7898
def run_test(self):
7999
if sum([self.options.run_ipv4, self.options.run_ipv6, self.options.run_nonloopback]) > 1:
80100
raise AssertionError("Only one of --ipv4, --ipv6 and --nonloopback can be set")
@@ -101,6 +121,7 @@ def run_test(self):
101121
self.run_invalid_bind_test(['127.0.0.1'], ['127.0.0.1:notaport', '127.0.0.1:-18443', '127.0.0.1:0', '127.0.0.1:65536'])
102122
if self.options.run_ipv6:
103123
self.run_invalid_bind_test(['[::1]'], ['[::1]:notaport', '[::1]:-18443', '[::1]:0', '[::1]:65536'])
124+
self.run_invalid_allowip_test()
104125
if not self.options.run_ipv4 and not self.options.run_ipv6:
105126
self._run_nonloopback_tests()
106127

0 commit comments

Comments
 (0)