Commit 263dd554 authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

in plib.py : the address attributed to the server iface was XXXXX/len(network)...

in plib.py : the address attributed to the server iface was XXXXX/len(network) wich resulted in XXXXXX/48 while it should be XXXXXX/len(subnet of a single machine)
in vifibnet.py : the -l option was broken
in tunnel.py : routes count is now stored on each connection object and not in the tunnelManager object
parent dfbb4ec5
...@@ -33,19 +33,10 @@ To be done : ...@@ -33,19 +33,10 @@ To be done :
Handle LAN internally in order not to have catastrophic results .... Handle LAN internally in order not to have catastrophic results ....
( avahi could be used ) ( avahi could be used )
To be discussed: When we count the number of routes througt an interface, we should filter on
G, J : To get traffic stats ( bytes in/out ), you can use the prefix size and the subnet
/sys/class/net/interface/statistics/rx_bytes, etc...
or /proc/net/dev/snmp6/interface ( all in one file ). This can be enough
if used as follows: get traffic diff from last time we checked in order
to choose which connection is significantly unused compared to others,
and close it. Of course, too recent connections (i.e. those for which we
have no previous stat) would be always kept.
This should be combined with routing table (i.e. how many nodes are
served by each tunnel), which is possibly redundant.
ip6tables should be avoided if possible.
U : Great !!!
To be discussed:
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
...@@ -70,17 +61,6 @@ To be discussed: ...@@ -70,17 +61,6 @@ To be discussed:
on nexedi's server downtime ? it could be useful for the internship on nexedi's server downtime ? it could be useful for the internship
rapport rapport
U : The peer DB size should depend on the number of connection and the
refresh time
G : ?! I don't agree, the db size should be proportional ( with a factor
like 0.01 or less ) to the total number of peers in the entire network,
with maybe a max size.
U : what we need to do is to keep the randomness. For this, we need a big
enought DB to ensure we can still choose a peer as if it was choosen
directly from the server. The requiered db size can be calculated from
the number of connections and the refresh time.
G : ok, you can erase this talk
U : Why are --ip and internal-port mutually exclusive ? U : Why are --ip and internal-port mutually exclusive ?
Currently upnp only forward via UDP. Should he also forward via TCP ? Currently upnp only forward via UDP. Should he also forward via TCP ?
Why dont we only use UDP ? Why dont we only use UDP ?
...@@ -95,3 +75,11 @@ To be discussed: ...@@ -95,3 +75,11 @@ To be discussed:
G : I think the number of route going through an interface should be a G : I think the number of route going through an interface should be a
Connection attribute, not a dict in tunnelManager Connection attribute, not a dict in tunnelManager
U : Yes, it was planned, just wait for me to finish implementing it
U : '--up', 'ovpn-server %s/%u' % (server_ip, len(network)) in plib.py
if you use len(network), this means that all our network is on the
same LAN and that the interface of the server is connected to it
wich means that any packet should be routed to this interface
an interface should only advertise the /64 (or less) which has been
attributed to it
...@@ -22,7 +22,8 @@ def server(server_ip, network, max_clients, dh_path, pipe_fd, port, proto, hello ...@@ -22,7 +22,8 @@ def server(server_ip, network, max_clients, dh_path, pipe_fd, port, proto, hello
return openvpn(hello_interval, return openvpn(hello_interval,
'--tls-server', '--tls-server',
'--mode', 'server', '--mode', 'server',
'--up', 'ovpn-server %s/%u' % (server_ip, len(network)), #'--up', 'ovpn-server %s/%u' % (server_ip, len(network)),
'--up', 'ovpn-server %s/%u' % (server_ip, 64), # Isn't this better ?
'--client-connect', 'ovpn-server ' + str(pipe_fd), '--client-connect', 'ovpn-server ' + str(pipe_fd),
'--client-disconnect', 'ovpn-server ' + str(pipe_fd), '--client-disconnect', 'ovpn-server ' + str(pipe_fd),
'--dh', dh_path, '--dh', dh_path,
......
...@@ -14,6 +14,7 @@ class Connection: ...@@ -14,6 +14,7 @@ class Connection:
os.O_WRONLY|os.O_CREAT|os.O_TRUNC)) os.O_WRONLY|os.O_CREAT|os.O_TRUNC))
self.iface = iface self.iface = iface
self.routes = 0
self._prefix = prefix self._prefix = prefix
self._creation_date = time.time() self._creation_date = time.time()
self._bandwidth = None self._bandwidth = None
...@@ -64,7 +65,7 @@ class TunnelManager: ...@@ -64,7 +65,7 @@ class TunnelManager:
self._write_pipe = write_pipe self._write_pipe = write_pipe
self._peer_db = peer_db self._peer_db = peer_db
self._connection_dict = {} self._connection_dict = {}
self._route_count = {} self._iface_to_prefix = {}
self._ovpn_args = openvpn_args self._ovpn_args = openvpn_args
self._hello = hello_interval self._hello = hello_interval
self._refresh_time = refresh self._refresh_time = refresh
...@@ -106,7 +107,7 @@ class TunnelManager: ...@@ -106,7 +107,7 @@ class TunnelManager:
pass pass
self.free_interface_set.add(connection.iface) self.free_interface_set.add(connection.iface)
self._peer_db.unusePeer(prefix) self._peer_db.unusePeer(prefix)
del self._route_count[connection.iface] del self._iface_to_prefix[connection.iface]
def _makeNewTunnels(self): def _makeNewTunnels(self):
utils.log('Trying to make %i new tunnels' % utils.log('Trying to make %i new tunnels' %
...@@ -119,7 +120,7 @@ class TunnelManager: ...@@ -119,7 +120,7 @@ class TunnelManager:
self._connection_dict[prefix] = Connection(address, self._connection_dict[prefix] = Connection(address,
self._write_pipe, self._hello, iface, self._write_pipe, self._hello, iface,
prefix, self._ovpn_args) prefix, self._ovpn_args)
self._route_count[iface] = 0 self._iface_to_prefix[iface] = prefix
self._peer_db.usePeer(prefix) self._peer_db.usePeer(prefix)
except KeyError: except KeyError:
utils.log("""Can't establish connection with %s utils.log("""Can't establish connection with %s
...@@ -129,17 +130,18 @@ class TunnelManager: ...@@ -129,17 +130,18 @@ class TunnelManager:
def _countRoutes(self): def _countRoutes(self):
utils.log('Starting to count the routes on each interface', 3) utils.log('Starting to count the routes on each interface', 3)
for iface in self._route_count.keys(): for iface in self._iface_to_prefix.keys():
self._route_count[iface] = 0 self._connection_dict[self._iface_to_prefix[iface]].routes = 0
f = open('/proc/net/ipv6_route', 'r') f = open('/proc/net/ipv6_route', 'r')
for line in f: for line in f:
ip, subnet_size, iface = struct.unpack("""32s x 2s x 32x x 2x x ip, subnet_size, iface = struct.unpack("""32s x 2s 106x
32x x 8x x 8x x 8x x 8x x %ss x""" % (len(line)-142), line) %ss x""" % (len(line)-142), line)
iface = iface.replace(' ', '') iface = iface.replace(' ', '')
if iface in self._route_count.keys(): if iface in self._iface_to_prefix.keys():
self._route_count[iface] += 1 self._connection_dict[self._iface_to_prefix[iface]].routes += 1
for iface in self._route_count.keys(): for p in self._connection_dict.keys():
utils.log('Routes on iface %s : %s' % ( utils.log('Routes on iface %s : %s' % (
iface,self._route_count[iface] ), 5) self._connection_dict[p].iface,
self._connection_dict[p].routes ), 5)
...@@ -34,7 +34,7 @@ def getConfig(): ...@@ -34,7 +34,7 @@ def getConfig():
help='Port on the machine to listen on for incomming connections') help='Port on the machine to listen on for incomming connections')
_('--peers-db-refresh', default=3600, type=int, _('--peers-db-refresh', default=3600, type=int,
help='the time (seconds) to wait before refreshing the peers db') help='the time (seconds) to wait before refreshing the peers db')
_('-l', '-log', default='/var/log', _('-l', '-log', default='/var/log', dest='log',
help='Path to vifibnet logs directory') help='Path to vifibnet logs directory')
_('-s', '--state', default='/var/lib/vifibnet', _('-s', '--state', default='/var/lib/vifibnet',
help='Path to VPN state directory') help='Path to VPN state directory')
......
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