Commit c899b4ec authored by Guillaume Bury's avatar Guillaume Bury

Cleaner handling of reading lines for routes

parent de4d352d
...@@ -4,24 +4,18 @@ To be done : ...@@ -4,24 +4,18 @@ To be done :
Use an algorithm to choose which connections to keep and/or establish Use an algorithm to choose which connections to keep and/or establish
instead of pure randomness instead of pure randomness
number of routes / tunnel number of routes / tunnel
favorise most used roads favorise most used roads
Handle LAN internally in order not to have catastrophic results .... Handle LAN internally in order not to have catastrophic results ....
the first thing to do is to include the LAN iface on the intarfaces pb : someone who has a lan acces to our network can provide false
given to babel => pb : someone who has a lan acces to our network can informations. Needs of signature
provide false informations. Needs of signature => yeah it is a security problem to fix
If it is not sufficient, we could use avahi (dm-dns for linux)
Write docstrings for all class/methods/functions Write docstrings for all class/methods/functions
To be discussed: To be discussed:
G : There is a blacklist system now ( blacklisted prefixes are deleted from
the peers database ). Since all nodes whose packets are routed through
the local network are blacklisted, I think we should reset the blacklist
from time to time....
U : Babel seems to be very long to establish the routes : maybe we should U : Babel seems to be very long to establish the routes : maybe we should
tell him thant we are not on a wired network but on a mobile network ? tell him thant we are not on a wired network but on a mobile network ?
G : babel establish routes quickly enough i'd say. There are two new G : babel establish routes quickly enough i'd say. There are two new
......
...@@ -135,3 +135,4 @@ class PeerManager: ...@@ -135,3 +135,4 @@ class PeerManager:
else: else:
utils.log('Unknow message recieved from the openvpn pipe : ' utils.log('Unknow message recieved from the openvpn pipe : '
+ msg, 1) + msg, 1)
...@@ -3,8 +3,7 @@ import plib, utils, db ...@@ -3,8 +3,7 @@ import plib, utils, db
log = None log = None
smooth = 0.3 # this is used to smooth the traffic sampling. Lower value smooth = 0.3 # this is used to smooth the traffic sampling. Lower value
# mean more smooth # mean more smooth
# Be carfull the refresh interval should let the routes be established # Be carfull the refresh interval should let the routes be established
...@@ -153,15 +152,13 @@ class TunnelManager: ...@@ -153,15 +152,13 @@ class TunnelManager:
self._peer_db.clear_blacklist(0) self._peer_db.clear_blacklist(0)
for iface in self._iface_to_prefix.keys(): for iface in self._iface_to_prefix.keys():
self._connection_dict[self._iface_to_prefix[iface]].routes = 0 self._connection_dict[self._iface_to_prefix[iface]].routes = 0
f = open('/proc/net/ipv6_route', 'r') for line in open('/proc/net/ipv6_route'):
for line in f: line = line.split()
ip, subnet_size, iface = struct.unpack('32s x 2s 106x %ss x' ip = bin(int(line[0], 16))[2:].rjust(128, '0')
% (len(line) - 142), line)
ip = bin(int(ip, 16))[2:].rjust(128, '0')
if ip.startswith(self._network): if ip.startswith(self._network):
iface = iface.strip() iface = line[-1]
subnet_size = int(subnet_size, 16) subnet_size = int(line[1], 16)
utils.log('Route on iface %s detected to %s/%s' utils.log('Route on iface %s detected to %s/%s'
% (iface, ip, subnet_size), 8) % (iface, ip, subnet_size), 8)
if iface in self._iface_to_prefix.keys(): if iface in self._iface_to_prefix.keys():
......
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