Commit 1b272c71 authored by Julien Muchembled's avatar Julien Muchembled

More sanity check

parent c231062f
......@@ -84,15 +84,20 @@ class PeerDB(object):'Getting Boot peer...')
bootpeer = self._proxy.getBootstrapPeer(self._prefix).data
except (socket.error, xmlrpclib.Fault), e:
p = subprocess.Popen(
('openssl', 'rsautl', '-decrypt', '-inkey', self._key_path),
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out, err = p.communicate(bootpeer)
if p.returncode:
raise subprocess.CalledProcessError(p.returncode, err)
prefix, address = out.split()
except (socket.error, xmlrpclib.Fault, subprocess.CalledProcessError,
ValueError), e:
logging.warning('Failed to bootstrap (%s)', e)
p = subprocess.Popen(('openssl', 'rsautl', '-decrypt', '-inkey', self._key_path),
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
bootpeer = p.communicate(bootpeer)[0].split()
if bootpeer[0] != self._prefix:
return bootpeer
if prefix != self._prefix:
self.addPeer(prefix, address)
return prefix, address
logging.warning('Buggy registry sent us our own address')
def addPeer(self, prefix, address, set_preferred=False):
......@@ -405,10 +405,13 @@ class TunnelManager(object):
code = ord(msg[0])
if code == 1: # answer
# TODO: do not fail if message contains garbage
# We parse the message in a way to discard a truncated line.
for peer in msg[1:].split('\n')[:-1]:
prefix, address = peer.split()
prefix, address = peer.split()
int(prefix, 2)
except ValueError:
if prefix != self._prefix:
self._peer_db.addPeer(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