Commit 093e464e authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

A bug was solved in openvpn.py : the max-peer option was passed as an int instead of a string

Adding propagation.py, not functionnal yet
parent 7ecb3e27
......@@ -33,7 +33,7 @@ def server(ip, pipe_fd, *args, **kw):
'--client-connect', 'client-connect ' + str(pipe_fd),
'--client-disconnect', 'client-connect ' + str(pipe_fd),
'--dh', config.dh,
'--max-clients', config.max_clients,
'--max-clients', str(config.max_clients),
*args, **kw)
def client(serverIp, *args, **kw):
......
import socket
import uuid
# create an upd socket
# listen on it for incoming messages and forward them
# manage the forwarding routing table
# the peudo-code can be found here http://en.wikipedia.org/wiki/Chord_%28peer-to-peer%29
class RingMember:
def __init__(self, id, ip, port):
self.port = port
self.ip = ip
self.id = id
def toString(self):
return str(self.id) + ' ' + self.ip + ' ' + str(self.port)
class Ring:
def __init__(self, entryPoint):
# initialize the connection
self.sock = socket.socket( socket.AF_INET666666, socket.SOCK_DGRAM )
self.sock.bind(('', 0))
self.me = RingMember(uuid.uuid1().int ,'', self.sock.getsockname()[1]) # TODO : get the address
# to enter the ring
self.predecessor = None
if entryPoint == None:
self.successor = self.me
else:
self.send('FIND_SUCCESSOR ' + str(self.me.id) + ' ' + self.me.toString(), entrypoint)
# TODO :
def handleMessages(self):
# TODO : switch to log
print 'Handling messages ...'
pass
def send(self, message, target):
# TODO : switch to log
print 'Sending : ' + message + ' to ' + target.toString()
self.sock.sendTo(message, (target.ip, target.port))
def findSuccessor(self, id, sender):
if self.id < id and id <= self.successor:
self.send('SUCCESSOR_IS ' + self.successor.toString(), sender)
else:
self.send('FIND_SUCCESSOR ' + str(id) + ' ' + sender.toString(), successor) # TODO : use the fingers
# Just copying the pseudocode from wikipedia, I will make it work later
# Possible messages (just for the creation of the ring) :
#
# find_successor $id $sender : $sender whants the IP of the successor of $id
# successor_is $ip $successor
# get_predecessor
# notify $sender_ip $sender_id
# PING
# called periodically
# pb : how to fix successor
# def stabilize(self):
# x = SEND get_predecessor TO self.successor
# if n < x && x < self.successor:
# self.successor = x
# SEND notify self.ip, self.id TO self.successor
# def notify(self, n2)
# if self.predecessor == None || (predecessor < n2 && n2 < n):
# self.predecessor = n2
# to be called periodically
# def fixFingers(self)
# next = (next + 1) mod (nFingers) # Or Random, cf google
# finger[next] = find_successor(n+2^{next-1});
# to be called periodically
# def checkPredecessor(self)
# if NO PING from self.predecessor:
# self.predecessor = None
......@@ -4,6 +4,7 @@ import traceback
import upnpigd
import openvpn
import random
import propagation
VIFIB_NET = "2001:db8:42::/48"
connection_dict = {} # to remember current connections we made
......@@ -87,9 +88,11 @@ def getConfig():
help='Path to babeld state-file')
_('--verbose', '-v', default=0, type=int,
help='Defines the verbose level')
# Temporary args
# Temporary args - to be removed
_('--ip', required=True,
help='IPv6 of the server')
_('--entry-ip', default=None, help='entrypoint for the ring')
_('--entry-port', default=None, help='entrypoint for the ring')
# Openvpn options
_('openvpn_args', nargs=argparse.REMAINDER,
help="Common OpenVPN options (e.g. certificates)")
......@@ -168,7 +171,7 @@ def main():
# Launch babel on all interfaces
log_message('Starting babel', 3)
babel = startBabel(stdout=os.open('%s/babeld.log' % (config.log_directory,), os.O_WRONLY|os.O_CREAT|os.O_TRUNC),
babel = startBabel(stdout=os.open('%s/babeld.log' % (config.log_directory,), os.O_WRONLY | os.O_CREAT | os.O_TRUNC),
stderr=subprocess.STDOUT)
# Create and open read_only pipe to get connect/disconnect events from openvpn
......@@ -179,7 +182,7 @@ def main():
# Establish connections
log_message('Starting openvpn server', 3)
serverProcess = openvpn.server(config.ip, write_pipe, '--dev', 'vifibnet',
stdout=os.open('%s/vifibnet.server.log' % (config.log_directory,), os.O_WRONLY|os.O_CREAT|os.O_TRUNC))
stdout=os.open('%s/vifibnet.server.log' % (config.log_directory,), os.O_WRONLY | os.O_CREAT | os.O_TRUNC))
startNewConnection(config.client_count)
# Timed refresh initializing
......
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