bootstrap: Respect 'onlynet=onion' and, when a trusted peer is set, connect only to that trusted peer.
This commit is contained in:
parent
7b168b7041
commit
3b58e1f251
|
@ -51,6 +51,12 @@ class BMConnectionPool(object):
|
||||||
BMConfigParser().safeGetInt(
|
BMConfigParser().safeGetInt(
|
||||||
"bitmessagesettings", "maxuploadrate")
|
"bitmessagesettings", "maxuploadrate")
|
||||||
)
|
)
|
||||||
|
onionOnly_deprecated = BMConfigParser().safeGetBoolean(
|
||||||
|
"bitmessagesettings", "onionservicesonly")
|
||||||
|
onionOnly = BMConfigParser().safeGet(
|
||||||
|
"bitmessagesettings", "onlynet") == "onion"
|
||||||
|
|
||||||
|
self.onionOnly = onionOnly or onionOnly_deprecated
|
||||||
self.outboundConnections = {}
|
self.outboundConnections = {}
|
||||||
self.inboundConnections = {}
|
self.inboundConnections = {}
|
||||||
self.listeningSockets = {}
|
self.listeningSockets = {}
|
||||||
|
@ -205,17 +211,17 @@ class BMConnectionPool(object):
|
||||||
|
|
||||||
def startBootstrappers(self):
|
def startBootstrappers(self):
|
||||||
"""Run the process of resolving bootstrap hostnames"""
|
"""Run the process of resolving bootstrap hostnames"""
|
||||||
|
onion_seed = 'quzwelsuziwqgpt2.onion' # FIXME onion bootstrap server is down
|
||||||
proxy_type = BMConfigParser().safeGet(
|
proxy_type = BMConfigParser().safeGet(
|
||||||
'bitmessagesettings', 'socksproxytype')
|
'bitmessagesettings', 'socksproxytype')
|
||||||
# A plugins may be added here
|
# A plugins may be added here
|
||||||
hostname = None
|
hostname = None
|
||||||
|
port = 8444
|
||||||
|
|
||||||
if not proxy_type or proxy_type == 'none':
|
if not proxy_type or proxy_type == 'none':
|
||||||
connection_base = TCPConnection
|
connection_base = TCPConnection
|
||||||
elif proxy_type == 'SOCKS5':
|
elif proxy_type == 'SOCKS5':
|
||||||
connection_base = Socks5BMConnection
|
connection_base = Socks5BMConnection
|
||||||
hostname = helper_random.randomchoice([
|
|
||||||
'quzwelsuziwqgpt2.onion', None
|
|
||||||
])
|
|
||||||
elif proxy_type == 'SOCKS4a':
|
elif proxy_type == 'SOCKS4a':
|
||||||
connection_base = Socks4aBMConnection # FIXME: I cannot test
|
connection_base = Socks4aBMConnection # FIXME: I cannot test
|
||||||
else:
|
else:
|
||||||
|
@ -223,12 +229,21 @@ class BMConnectionPool(object):
|
||||||
# is handled in bitmessagemain before starting the connectionpool
|
# is handled in bitmessagemain before starting the connectionpool
|
||||||
return
|
return
|
||||||
|
|
||||||
bootstrapper = bootstrap(connection_base)
|
if self.trustedPeer is not None:
|
||||||
if not hostname:
|
hostname = self.trustedPeer.host
|
||||||
|
port = self.trustedPeer.port
|
||||||
|
elif proxy_type == "SOCKS5" or self.onionOnly:
|
||||||
|
if self.onionOnly:
|
||||||
|
hostname = onion_seed
|
||||||
|
else:
|
||||||
|
hostname = helper_random.randomchoice([
|
||||||
|
onion_seed, None])
|
||||||
|
|
||||||
|
if hostname is None:
|
||||||
port = helper_random.randomchoice([8080, 8444])
|
port = helper_random.randomchoice([8080, 8444])
|
||||||
hostname = 'bootstrap%s.bitmessage.org' % port
|
hostname = 'bootstrap%s.bitmessage.org' % port
|
||||||
else:
|
|
||||||
port = 8444
|
bootstrapper = bootstrap(connection_base)
|
||||||
self.addConnection(bootstrapper(hostname, port))
|
self.addConnection(bootstrapper(hostname, port))
|
||||||
|
|
||||||
def loop(self): # pylint: disable=too-many-branches,too-many-statements
|
def loop(self): # pylint: disable=too-many-branches,too-many-statements
|
||||||
|
|
Loading…
Reference in New Issue
Block a user