Commit dcc76a0d authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

Initial commit

parent bdc04ba6
import socket
hostname = socket.gethostname()
CaPath = '/root/overnet/keys/ca.crt'
CertPath = '/root/overnet/keys/server.crt'
KeyPath = '/root/overnet/keys/server.key'
DhPath = '/root/overnet/keys/dh1024.pem'
Subnet = '10.8.0.0'
SubnetMask = '255.255.255.0'
if hostname == 'm5':
IPv6 = '2000:0:0:1::1/64'
MandatoryConnections = [('10.1.4.3', 1194)]
elif hostname == 'm6':
IPv6 = '2000:0:0:2::1/64'
Debug = True
......@@ -23,8 +23,8 @@ FailIfNotExists('CaPath')
FailIfNotExists('CertPath')
FailIfNotExists('KeyPath')
FailIfNotExists('DhPath')
FailIfNotExists('Subnet')
FailIfNotExists('SubnetMask')
FailIfNotExists('IPv6')
SetIfNotExists('Debug', False)
SetIfNotExists('MandatoryConnections', [])
SetIfNotExists('LocalPort', 1194)
#!/usr/bin/env python
import upnpigd
from subprocess import call
import openvpn
from configuration import *
# Call == bad !!
# TODO : use subprocess module
def LaunchOpenVpnClient(serverAddress, serverPort):
call(['openvpn',
'--client',
'--dev', 'tun',
'--proto', 'udp',
'--remote', serverAddress, str(serverPort),
'--nobind',
'--persist-key',
'--persist-tun',
'--ca', config.CaPath,
'--cert', config.CertPath,
'--key', config.KeyPath,
'--ns-cert-type', 'server',
'--comp-lzo',
'--verb', '3',
'--daemon', 'openVpnClient(' + serverAddress + ')' ])
def LaunchOpenVpnServer(port):
call(['openvpn',
'--dev', 'tun',
'--proto', 'udp',
'--ca', config.CaPath,
'--cert', config.CertPath,
'--key', config.KeyPath,
'--dh', config.DhPath,
'--server', config.Subnet, config.SubnetMask,
'--port', str(port),
'--ifconfig-pool-persist', 'ipp.txt',
'--comp-lzo',
'--keepalive', '10', '120',
'--persist-tun',
'--persist-key',
'--verb', '3'])
(ip, port) = upnpigd.GetExternalInfo(config.LocalPort)
openvpn.LaunchServer()
for (address, port) in config.MandatoryConnections:
openvpn.LaunchClient(address, port)
......@@ -31,3 +31,4 @@ def GetExternalInfo(localPort):
return ForwardViaUPnP(localPort)
except Exception:
return (GetLocalIp(), localPort)
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