@@ -51,6 +51,12 @@ def __init__(self):
51
51
BMConfigParser ().safeGetInt (
52
52
"bitmessagesettings" , "maxuploadrate" )
53
53
)
54
+ onionOnly_deprecated = BMConfigParser ().safeGetBoolean (
55
+ "bitmessagesettings" , "onionservicesonly" )
56
+ onionOnly = BMConfigParser ().safeGet (
57
+ "bitmessagesettings" , "onlynet" ) == "onion"
58
+
59
+ self .onionOnly = onionOnly or onionOnly_deprecated
54
60
self .outboundConnections = {}
55
61
self .inboundConnections = {}
56
62
self .listeningSockets = {}
@@ -205,30 +211,40 @@ def startUDPSocket(self, bind=None):
205
211
206
212
def startBootstrappers (self ):
207
213
"""Run the process of resolving bootstrap hostnames"""
214
+ onion_seed = 'quzwelsuziwqgpt2.onion' #FIXME onion bootstrap server is down
208
215
proxy_type = BMConfigParser ().safeGet (
209
216
'bitmessagesettings' , 'socksproxytype' )
210
217
# A plugins may be added here
211
218
hostname = None
219
+ port = 8444
220
+
212
221
if not proxy_type or proxy_type == 'none' :
213
222
connection_base = TCPConnection
214
223
elif proxy_type == 'SOCKS5' :
215
224
connection_base = Socks5BMConnection
216
- hostname = helper_random .randomchoice ([
217
- 'quzwelsuziwqgpt2.onion' , None
218
- ])
219
225
elif proxy_type == 'SOCKS4a' :
220
226
connection_base = Socks4aBMConnection # FIXME: I cannot test
221
227
else :
222
228
# This should never happen because socksproxytype setting
223
229
# is handled in bitmessagemain before starting the connectionpool
224
230
return
225
231
226
- bootstrapper = bootstrap (connection_base )
227
- if not hostname :
232
+ if self .trustedPeer is not None :
233
+ hostname = self .trustedPeer .host
234
+ port = self .trustedPeer .port
235
+ elif proxy_type == "SOCKS5" or self .onionOnly :
236
+ if self .onionOnly :
237
+ hostname = onion_seed
238
+ else :
239
+ hostname = helper_random .randomchoice ([
240
+ onion_seed , None
241
+ ])
242
+
243
+ if hostname is None :
228
244
port = helper_random .randomchoice ([8080 , 8444 ])
229
245
hostname = 'bootstrap%s.bitmessage.org' % port
230
- else :
231
- port = 8444
246
+
247
+ bootstrapper = bootstrap ( connection_base )
232
248
self .addConnection (bootstrapper (hostname , port ))
233
249
234
250
def loop (self ): # pylint: disable=too-many-branches,too-many-statements
0 commit comments