Commit 17d80ac6 authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

A few bug solved

parent 4fc87945
...@@ -6,6 +6,11 @@ To be done : ...@@ -6,6 +6,11 @@ To be done :
find out who to have an automatic recovery without declare find out who to have an automatic recovery without declare
Test the package Test the package
PB : at the beggining a node tries to find 10 other nodes so ask for 10 bootsrap nodes
This slow the beginning !!
When a node arrive it is in nobody DB => very slow beginning. It should advertise itself more
check the ips attributed check the ips attributed
remove decalre remove decalre
how do we make sure that none inject some false packets ? how do we make sure that none inject some false packets ?
......
...@@ -75,16 +75,15 @@ class PeerManager: ...@@ -75,16 +75,15 @@ class PeerManager:
try: try:
self._declare() self._declare()
self.next_refresh = time.time() + self._refresh_time self.next_refresh = time.time() + self._refresh_time
return True
except socket.error, e: except socket.error, e:
logging.info('Connection to server failed, re-bootstraping') logging.info('Connection to server failed, re-bootstraping')
try: try:
self._bootstrap() self._bootstrap()
self.next_refresh = time.time() + self._refresh_time
except socket.error, e: except socket.error, e:
logging.debug('socket.error : %s' % e) logging.debug('socket.error : %s' % e)
logging.info('Connection to server failed, retrying in 30s') logging.info('Connection to server failed, retrying in 30s')
self.next_refresh = time.time() + 30 self.next_refresh = time.time() + 30
return False
def _declare(self): def _declare(self):
if self.address != None: if self.address != None:
...@@ -120,8 +119,8 @@ class PeerManager: ...@@ -120,8 +119,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: #except Exception, e:
logging.info('Unable to bootstrap') # logging.info('Unable to bootstrap : %s' % e)
return False return False
def usePeer(self, prefix): def usePeer(self, prefix):
...@@ -185,7 +184,7 @@ class PeerManager: ...@@ -185,7 +184,7 @@ class PeerManager:
return False return False
self._db.execute("""DELETE FROM peers WHERE used <= 0 ORDER BY used, self._db.execute("""DELETE FROM peers WHERE used <= 0 ORDER BY used,
RANDOM() LIMIT MAX(0, (SELECT COUNT(*) FROM peers RANDOM() LIMIT MAX(0, (SELECT COUNT(*) FROM peers
WHERE used <= 0) - ?)""", str(self._db_size)) WHERE used <= 0) - ?)""", (str(self._db_size),))
self._db.execute("INSERT INTO peers (prefix, address) VALUES (?,?)", peer) self._db.execute("INSERT OR REPLACE INTO peers (prefix, address) VALUES (?,?)", peer)
logging.debug('Peer added') logging.debug('Peer added')
return True return True
import os, traceback, time, subprocess, logging import os, traceback, time, subprocess, logging
import socket import socket
import plib import plib
import utils
# Be carfull the refresh interval should let the routes be established # Be carfull the refresh interval should let the routes be established
...@@ -169,7 +170,7 @@ class TunnelManager: ...@@ -169,7 +170,7 @@ class TunnelManager:
peerIp[12:16], peerIp[16:20], peerIp[20:24], peerIp[24:28], peerIp[28:32]) peerIp[12:16], peerIp[16:20], peerIp[20:24], peerIp[24:28], peerIp[28:32])
logging.debug('Notifying peer %s' % ip) logging.debug('Notifying peer %s' % ip)
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
sock.sendto('%s %s\n' % (self._prefix, self._peer_db.address), (ip, 326)) sock.sendto('%s %s\n' % (self._prefix, utils.address_str(self._peer_db.address)), (ip, 326))
except socket.error, e: except socket.error, e:
logging.debug('Unable to notify %s' % ip) logging.debug('Unable to notify %s' % ip)
logging.debug('socket.error : %s' % e) logging.debug('socket.error : %s' % e)
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