Commit cb4cb822 authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

adding openvpn.py

parent 8e578298
...@@ -44,7 +44,9 @@ def getConfig(): ...@@ -44,7 +44,9 @@ def getConfig():
def main(): def main():
getConfig() getConfig()
if config.ip != 'none':
serverProcess = openvpn.server(config, config.ip) serverProcess = openvpn.server(config, config.ip)
else:
client1Process = openvpn.client(config, '10.1.4.2') client1Process = openvpn.client(config, '10.1.4.2')
......
import subprocess
def openvpn(config, *args):
args = ['openvpn',
'--dev', 'tap',
'--ca', config.ca,
'--cert', config.cert,
'--key', config.key,
'--persist-tun',
'--persist-key',
'--script-security', '2',
'--user', 'nobody',
'--group', 'nogroup',
'--verb', config.verbose
] + list(args)
return subprocess.Popen(args)
# TODO : set iface up when creating a server/client
# ! check working directory before launching up script ?
def server(config, ip):
return openvpn(config,
'--tls-server',
'--keepalive', '10', '60',
'--mode', 'server',
'--duplicate-cn',
'--up', 'up-server ' + ip,
'--dh', config.dh)
def client(config, serverIp):
return openvpn(config,
'--nobind',
'--tls-client',
'--remote', serverIp,
'--up', 'up-client')
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