Read bootstrap nodes from file

If a file exists in the current directory called "bootstrap"
then its contents will be used as a replacement for the
hardcoded bootstrap nodes
This commit is contained in:
Bob Mottram 2015-08-29 14:34:55 +01:00
parent d8edaeb6ac
commit 8fd1a50ea7
1 changed files with 21 additions and 5 deletions

View File

@ -584,11 +584,27 @@ class Site:
announced = 0
threads = []
for protocol, ip, port in SiteManager.TRACKERS: # Start announce threads
thread = gevent.spawn(self.announceTracker, protocol, ip, port, fileserver_port, address_hash, my_peer_id)
threads.append(thread)
thread.ip = ip
thread.protocol = protocol
# read bootstrap nodes
nodes_filename="bootstrap"
if os.path.isfile(nodes_filename):
bootstrap_nodes = open(nodes_filename,"r")
for node in bootstrap_nodes:
node_fields = node.split(' ')
if len(node_fields) == 3:
protocol = node_fields[0].strip()
ip = node_fields[1].strip()
port = int(node_fields[2].strip())
thread = gevent.spawn(self.announceTracker, protocol, ip, port, fileserver_port, address_hash, my_peer_id)
threads.append(thread)
thread.ip = ip
thread.protocol = protocol
if not threads:
for protocol, ip, port in SiteManager.TRACKERS: # Start announce threads
thread = gevent.spawn(self.announceTracker, protocol, ip, port, fileserver_port, address_hash, my_peer_id)
threads.append(thread)
thread.ip = ip
thread.protocol = protocol
gevent.joinall(threads) # Wait for announce finish