Commit 896bc9de authored by Julien Muchembled's avatar Julien Muchembled

registry: new RPC to get versions of all running nodes

parent e9243962
......@@ -161,7 +161,7 @@ class RegistryServer(object):
def handle_request(self, request, method, kw):
m = getattr(self, method)
if method in ('topology',) and \
if method in ('versions', 'topology',) and \
request.client_address[0] not in ('', '::1'):
return request.send_error(httplib.FORBIDDEN)
key = m.getcallargs(**kw).get('cn')
......@@ -369,6 +369,44 @@ class RegistryServer(object):"Sending bootstrap peer: %s", msg)
return utils.encrypt(cert, msg)
def versions(self):
with self.peers_lock:
peers = set(prefix
for neigh_routes in self.ctl.neighbours.itervalues()
for prefix in neigh_routes[1]
if prefix)
peer_dict = {}
s = self.sock,
with self.lock:
while True:
r, w, _ =, s if peers else (), (), 3)
if r:
ver, address = self.sock.recvfrom(1<<16)
address = utils.binFromIp(address[0])
if (address.startswith( and
len(ver) > 1 and ver[0] in '\3\4' # BBB
.startswith, peer_dict),
key=len)] = ver[1:]
except ValueError:
if w:
x = peers.pop()
peer_dict[x] = None
x = utils.ipFromBin( + x)
self.sock.sendto('\3', (x, tunnel.PORT))
except socket.error:
elif not r:
return repr(peer_dict)
def topology(self):
with self.lock:
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