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' CaPath = '/root/overnet/keys/ca.crt'
CertPath = '/root/overnet/keys/server.crt' CertPath = '/root/overnet/keys/server.crt'
KeyPath = '/root/overnet/keys/server.key' KeyPath = '/root/overnet/keys/server.key'
DhPath = '/root/overnet/keys/dh1024.pem' 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 Debug = True
\ No newline at end of file
...@@ -23,8 +23,8 @@ FailIfNotExists('CaPath') ...@@ -23,8 +23,8 @@ FailIfNotExists('CaPath')
FailIfNotExists('CertPath') FailIfNotExists('CertPath')
FailIfNotExists('KeyPath') FailIfNotExists('KeyPath')
FailIfNotExists('DhPath') FailIfNotExists('DhPath')
FailIfNotExists('Subnet') FailIfNotExists('IPv6')
FailIfNotExists('SubnetMask')
SetIfNotExists('Debug', False) SetIfNotExists('Debug', False)
SetIfNotExists('MandatoryConnections', []) SetIfNotExists('MandatoryConnections', [])
\ No newline at end of file SetIfNotExists('LocalPort', 1194)
#!/usr/bin/env python
import upnpigd import upnpigd
from subprocess import call import openvpn
from configuration import * from configuration import *
# Call == bad !! (ip, port) = upnpigd.GetExternalInfo(config.LocalPort)
# TODO : use subprocess module openvpn.LaunchServer()
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'])
for (address, port) in config.MandatoryConnections:
openvpn.LaunchClient(address, port)
...@@ -31,3 +31,4 @@ def GetExternalInfo(localPort): ...@@ -31,3 +31,4 @@ def GetExternalInfo(localPort):
return ForwardViaUPnP(localPort) return ForwardViaUPnP(localPort)
except Exception: except Exception:
return (GetLocalIp(), localPort) 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