6
6
7
7
from test_framework .netutil import all_interfaces , addr_to_hex , get_bind_addrs , test_ipv6_local
8
8
from test_framework .test_framework import BitcoinTestFramework , SkipTest
9
+ from test_framework .test_node import ErrorMatch
9
10
from test_framework .util import assert_equal , assert_raises_rpc_error , get_rpc_proxy , rpc_port , rpc_url
10
11
11
12
class RPCBindTest (BitcoinTestFramework ):
@@ -75,6 +76,25 @@ def run_allowip_test(self, allow_ips, rpchost, rpcport):
75
76
node .getnetworkinfo ()
76
77
self .stop_nodes ()
77
78
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
+
78
98
def run_test (self ):
79
99
if sum ([self .options .run_ipv4 , self .options .run_ipv6 , self .options .run_nonloopback ]) > 1 :
80
100
raise AssertionError ("Only one of --ipv4, --ipv6 and --nonloopback can be set" )
@@ -101,6 +121,7 @@ def run_test(self):
101
121
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' ])
102
122
if self .options .run_ipv6 :
103
123
self .run_invalid_bind_test (['[::1]' ], ['[::1]:notaport' , '[::1]:-18443' , '[::1]:0' , '[::1]:65536' ])
124
+ self .run_invalid_allowip_test ()
104
125
if not self .options .run_ipv4 and not self .options .run_ipv6 :
105
126
self ._run_nonloopback_tests ()
106
127
0 commit comments