Commit 12729533 authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

Removing the bootstrap option from the registry

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