Commit 12729533 authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

Removing the bootstrap option from the registry

parent 2fc3ee74
Bug :
Peers stay connected to the bootstrap node so none can enter
possible bug in the upnp refresh
possible bug in the upnp refresh
possible freeze in the regisrty
To be done :
test with python 2.6
......
......@@ -20,9 +20,9 @@ DESCRIPTION
===========
re6st-registry is a server for the re6st network. Its role is to deliver
vertificates to new nodes, and to maintain the complete table of peers, so it
certificates to new nodes, and to maintain the complete table of peers, so it
can send part of it to nodes asking for new peers.
As of now, only one re6st-registry per re6st network should run. The node
Only one re6st-registry per re6st network should run. The node
running the re6st-registry must also have a client ( re6stnet ) running.
USAGE
......@@ -31,7 +31,7 @@ USAGE
The re6st-registry will automatically listen on both ipv4 and ipv6 for incomming
request.
port
--port port
The port on which the server will listen
--db path
......@@ -59,21 +59,6 @@ port
address will be advertised only to nodes having a valid
certificate.
Options
-------
--bootstrap prefix
Prefix of a node to be given to other as a bootstrap node to
initiate connection with the network.A prefix is an id given to
each node, which is used to generate the re6st ip address of the
node. A prefix is a string representing binary number.
By default the registry delivers 16 bits prefix. You can get your
prefix from the python interpreter (see re6stnet man page HOW TO)
By default the registry delivers 16 bits prefix.
Asusming a network prefix ``2001:db8:42::/48``, the re6st ip address
``2001:db8:42:1::1/64`` corresponds to a prefix ``1/16`` i.e
``00000000000000010``.
SEE ALSO
========
......
......@@ -252,25 +252,20 @@ these files in a different directory than the certificates for the registry,
although the names shouldn't conflict.
Now here's the tricky part. For your network to work, you need to restart the
registry (maybe it will be fixed one day...), this time with more information
than the last time. You need to get your hands on the individual prefix of your
node, and the re6st ipv6 address associated. These should have been printed
at the end of re6st-conf. If you have missed them, for one reason or another,
you can get them in the python interpreter::
>>> from re6st import utils
>>> network = utils.networkFromCa('ca.pem')
>>> re6st_ip, prefix = utils.ipFromCert(network, 'cert.crt')
>>> print re6st_ip
2001:0db8:0042:0003:0000:0000:0000:0001
>>> print prefix
0000000000000011
registry with more information than the last time. You need to get your hands
on the re6st ipv6 address associated with your node. These should have been
printed at the end of re6st-conf. If you have missed them, for one reason or
another, you can get it in the python interpreter::
from re6st import utils
network = utils.networkFromCa('ca.pem')
re6st_ip, _ = utils.ipFromCert(network, 'cert.crt')
print re6st_ip
Now you can restart your re6st-registry with two more options:
``re6st-registry port_number --db db_path --ca path_to_ca.crt
--key path_to_ca.key --mailhost yourmailhost --private 2001:db8:42:3::1
--bootstrap 0000000000000011``
Finally, you can start your own re6st node following the instructions in the
precedent section.
......
......@@ -60,9 +60,6 @@ class main(object):
help='Path to certificate key')
_('--mailhost', required=True,
help='SMTP server mail host')
_('--bootstrap', action="append",
help='''VPN prefix of the peers to send as bootstrap peer,
instead of random ones''')
_('--private',
help='VPN IP of the node on which runs the registry')
self.config = parser.parse_args()
......@@ -201,25 +198,16 @@ class main(object):
def getPrivateAddress(self, handler):
return 'http://[%s]:%u' % (self.config.private, self.config.port)
def _randomPeer(self):
return self.db.execute("""SELECT prefix, address
FROM peers ORDER BY random() LIMIT 1""").next()
def getBootstrapPeer(self, handler, client_prefix):
cert, = self.db.execute("SELECT cert FROM vpn WHERE prefix = ?",
(client_prefix,)).next()
logging.trace('Getting bootpeer info...')
if self.config.bootstrap:
bootpeer = random.choice(self.config.bootstrap)
try:
prefix, address = self.db.execute("""SELECT prefix, address
FROM peers WHERE prefix = ?""", (bootpeer,)).next()
except StopIteration:
logging.info('Bootstrap peer %s unknown, sending random peer'
% hex(int(bootpeer, 2))[2:])
prefix, address = self._randomPeer()
else:
prefix, address = self._randomPeer()
try:
prefix, address = self.db.execute("""SELECT prefix, address FROM peers
WHERE prefix != ? ORDER BY random() LIMIT 1""", (client_prefix,)).next()
except StopIteration:
logging.info('No peer to send for bootstrap')
raise
logging.trace('Gotten bootpeer info from db')
r, w = os.pipe()
try:
......
......@@ -139,6 +139,8 @@ class PeerManager:
except sqlite3.IntegrityError, e:
if e.args[0] != 'column prefix is not unique':
raise
except StopIteration:
logging.info('No peer available for bootstrap')
return False
def usePeer(self, prefix):
......
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