12
12
- `-proxy` (proxy everything)
13
13
- `-onion` (proxy just onions)
14
14
- `-proxyrandomize` Circuit randomization
15
+ - `-cjdnsreachable`
15
16
- Proxy configurations to test on proxy side,
16
17
- support no authentication (other proxy)
17
18
- support no authentication + user/pass authentication (Tor)
26
27
addnode connect to IPv6
27
28
addnode connect to onion
28
29
addnode connect to generic DNS name
30
+ addnode connect to a CJDNS address
29
31
30
32
- Test getnetworkinfo for each node
31
33
"""
58
60
59
61
class ProxyTest (BitcoinTestFramework ):
60
62
def set_test_params (self ):
61
- self .num_nodes = 4
63
+ self .num_nodes = 5
62
64
self .setup_clean_chain = True
63
65
64
66
def setup_nodes (self ):
@@ -102,7 +104,9 @@ def setup_nodes(self):
102
104
['-listen' , f'-proxy={ self .conf1 .addr [0 ]} :{ self .conf1 .addr [1 ]} ' ,f'-onion={ self .conf2 .addr [0 ]} :{ self .conf2 .addr [1 ]} ' ,
103
105
f'-i2psam={ self .i2p_sam [0 ]} :{ self .i2p_sam [1 ]} ' , '-i2pacceptincoming=0' , '-proxyrandomize=0' ],
104
106
['-listen' , f'-proxy={ self .conf2 .addr [0 ]} :{ self .conf2 .addr [1 ]} ' ,'-proxyrandomize=1' ],
105
- []
107
+ [],
108
+ ['-listen' , f'-proxy={ self .conf1 .addr [0 ]} :{ self .conf1 .addr [1 ]} ' ,'-proxyrandomize=1' ,
109
+ '-cjdnsreachable' ]
106
110
]
107
111
if self .have_ipv6 :
108
112
args [3 ] = ['-listen' , f'-proxy=[{ self .conf3 .addr [0 ]} ]:{ self .conf3 .addr [1 ]} ' ,'-proxyrandomize=0' , '-noonion' ]
@@ -114,7 +118,7 @@ def network_test(self, node, addr, network):
114
118
if peer ["addr" ] == addr :
115
119
assert_equal (peer ["network" ], network )
116
120
117
- def node_test (self , node , * , proxies , auth , test_onion ):
121
+ def node_test (self , node , * , proxies , auth , test_onion , test_cjdns ):
118
122
rv = []
119
123
addr = "15.61.23.23:1234"
120
124
self .log .debug (f"Test: outgoing IPv4 connection through node for address { addr } " )
@@ -162,6 +166,21 @@ def node_test(self, node, *, proxies, auth, test_onion):
162
166
rv .append (cmd )
163
167
self .network_test (node , addr , network = NET_ONION )
164
168
169
+ if test_cjdns :
170
+ addr = "[fc00:1:2:3:4:5:6:7]:8888"
171
+ self .log .debug (f"Test: outgoing CJDNS connection through node for address { addr } " )
172
+ node .addnode (addr , "onetry" )
173
+ cmd = proxies [1 ].queue .get ()
174
+ assert isinstance (cmd , Socks5Command )
175
+ assert_equal (cmd .atyp , AddressType .DOMAINNAME )
176
+ assert_equal (cmd .addr , b"fc00:1:2:3:4:5:6:7" )
177
+ assert_equal (cmd .port , 8888 )
178
+ if not auth :
179
+ assert_equal (cmd .username , None )
180
+ assert_equal (cmd .password , None )
181
+ rv .append (cmd )
182
+ self .network_test (node , addr , network = NET_CJDNS )
183
+
165
184
addr = "node.noumenon:8333"
166
185
self .log .debug (f"Test: outgoing DNS name connection through node for address { addr } " )
167
186
node .addnode (addr , "onetry" )
@@ -182,17 +201,17 @@ def run_test(self):
182
201
# basic -proxy
183
202
self .node_test (self .nodes [0 ],
184
203
proxies = [self .serv1 , self .serv1 , self .serv1 , self .serv1 ],
185
- auth = False , test_onion = True )
204
+ auth = False , test_onion = True , test_cjdns = False )
186
205
187
206
# -proxy plus -onion
188
207
self .node_test (self .nodes [1 ],
189
208
proxies = [self .serv1 , self .serv1 , self .serv2 , self .serv1 ],
190
- auth = False , test_onion = True )
209
+ auth = False , test_onion = True , test_cjdns = False )
191
210
192
211
# -proxy plus -onion, -proxyrandomize
193
212
rv = self .node_test (self .nodes [2 ],
194
213
proxies = [self .serv2 , self .serv2 , self .serv2 , self .serv2 ],
195
- auth = True , test_onion = True )
214
+ auth = True , test_onion = True , test_cjdns = False )
196
215
# Check that credentials as used for -proxyrandomize connections are unique
197
216
credentials = set ((x .username ,x .password ) for x in rv )
198
217
assert_equal (len (credentials ), len (rv ))
@@ -201,7 +220,12 @@ def run_test(self):
201
220
# proxy on IPv6 localhost
202
221
self .node_test (self .nodes [3 ],
203
222
proxies = [self .serv3 , self .serv3 , self .serv3 , self .serv3 ],
204
- auth = False , test_onion = False )
223
+ auth = False , test_onion = False , test_cjdns = False )
224
+
225
+ # -proxy=unauth -proxyrandomize=1 -cjdnsreachable
226
+ self .node_test (self .nodes [4 ],
227
+ proxies = [self .serv1 , self .serv1 , self .serv1 , self .serv1 ],
228
+ auth = False , test_onion = True , test_cjdns = True )
205
229
206
230
def networks_dict (d ):
207
231
r = {}
@@ -266,6 +290,21 @@ def networks_dict(d):
266
290
assert_equal (n3 ['i2p' ]['reachable' ], False )
267
291
assert_equal (n3 ['cjdns' ]['reachable' ], False )
268
292
293
+ n4 = networks_dict (self .nodes [4 ].getnetworkinfo ())
294
+ assert_equal (NETWORKS , n4 .keys ())
295
+ for net in NETWORKS :
296
+ if net == NET_I2P :
297
+ expected_proxy = ''
298
+ expected_randomize = False
299
+ else :
300
+ expected_proxy = '%s:%i' % (self .conf1 .addr )
301
+ expected_randomize = True
302
+ assert_equal (n4 [net ]['proxy' ], expected_proxy )
303
+ assert_equal (n4 [net ]['proxy_randomize_credentials' ], expected_randomize )
304
+ assert_equal (n4 ['onion' ]['reachable' ], True )
305
+ assert_equal (n4 ['i2p' ]['reachable' ], False )
306
+ assert_equal (n4 ['cjdns' ]['reachable' ], True )
307
+
269
308
270
309
if __name__ == '__main__' :
271
310
ProxyTest ().main ()
0 commit comments