Commit 8d0aabf2 authored by Guillaume Bury's avatar Guillaume Bury

Random choice among bootstrap peers

parent 938da7ea
Name ideas :
URGENT => Name ideas :
resnet ( for Resiliable NET )
rsnet ( Resiliable Scalable NET )
To be done :
use the server as a bootstrap node -> switch peer discovery to be done
by vifibnet directly ?
Use an algorithm to choose which connections to keep and/or establish
instead of pure randomness
number of routes / tunnel
......
......@@ -53,9 +53,9 @@ class main(object):
help='Path to certificate key')
_('--mailhost', required=True,
help='SMTP server mail host')
_('--bootstrap', required=True, nargs=4,
help='''VPN prefix, ip address, port and protocol to send as
bootstrap peer''')
_('--bootstrap', nargs=4, action="append",
help='''VPN prefix, ip address, port and protocol to send as
bootstrap peers, instead of random ones''')
self.config = parser.parse_args()
# Database initializing
......@@ -181,8 +181,13 @@ class main(object):
# TODO: Insert a flag column for bootstrap ready servers in peers
# ( servers which shouldn't go down or change ip and port as opposed to servers owned by particulars )
# that way, we also ascertain that the server sent is not the new node....
prefix = self.config.bootstrap[0]
address = ','.join(self.config.bootstrap[1:])
if self.config.bootstrap:
bootpeer = random.choice(self.config.bootstrap)
prefix = bootpeer[0]
address = ','.join(bootpeer[1:])
else:
prefix, address = self.db.execute("""SELECT prefix, address
FROM peers ORDER BY random() LIMIT 1""")
print "Sending bootstrap peer (%s, %s)" % (prefix, str(address))
return prefix, address
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment