Commit 351e4fe8 authored by Guillaume Bury's avatar Guillaume Bury

Fixed recuperation of external_ip via openvpn

parent c180e126
...@@ -40,7 +40,7 @@ import os, time, sys ...@@ -40,7 +40,7 @@ import os, time, sys
# Send to client his external ip address # Send to client his external ip address
if os.environ['script_type'] == 'client-connect': if os.environ['script_type'] == 'client-connect':
with open(sys.argv[2], 'w') as f: with open(sys.argv[2], 'w') as f:
f.write('push "setenv external_ip %s"\n' % os.environ['trusted_ip']) f.write('push "setenv-safe external_ip %s"\n' % os.environ['trusted_ip'])
# Write into pipe connect/disconnect events # Write into pipe connect/disconnect events
os.write(int(sys.argv[1]), '%(script_type)s %(common_name)s\n' % os.environ) os.write(int(sys.argv[1]), '%(script_type)s %(common_name)s\n' % os.environ)
#!/usr/bin/python -S
import os, time, sys
# Write into pipe external ip address received
# Pb: executed before ( or at the same time ) as client-connect on server
# \===> external_ip not set when script is launched
# os.write(int(sys.argv[1]), '%(script_type)s %(external_ip)s\n' % os.environ)
...@@ -41,6 +41,6 @@ def client(serverIp, pipe_fd, *args, **kw): ...@@ -41,6 +41,6 @@ def client(serverIp, pipe_fd, *args, **kw):
'--client', '--client',
'--remote', serverIp, '--remote', serverIp,
'--up', 'up-client', '--up', 'up-client',
'--ipchange', 'ipchange ' + str(pipe_fd), '--route-up', 'route-up ' + str(pipe_fd),
*args, **kw) *args, **kw)
...@@ -101,7 +101,7 @@ def getConfig(): ...@@ -101,7 +101,7 @@ def getConfig():
# TODO: use maxpeer # TODO: use maxpeer
_('--max-clients', default=10, type=int, _('--max-clients', default=10, type=int,
help='the number of peers that can connect to the server') help='the number of peers that can connect to the server')
_('--refresh-time', default=60, type=int, _('--refresh-time', default=300, type=int,
help='the time (seconds) to wait before changing the connections') help='the time (seconds) to wait before changing the connections')
_('--refresh-count', default=1, type=int, _('--refresh-count', default=1, type=int,
help='The number of connections to drop when refreshing the connections') help='The number of connections to drop when refreshing the connections')
...@@ -205,7 +205,7 @@ def handle_message(msg): ...@@ -205,7 +205,7 @@ def handle_message(msg):
# TODO: check if we are not already connected to it # TODO: check if we are not already connected to it
elif script_type == 'client-disconnect': elif script_type == 'client-disconnect':
log.log('%s has disconnected' % (arg,), 3) log.log('%s has disconnected' % (arg,), 3)
elif script_type == 'ipchange': elif script_type == 'route-up':
# TODO: save the external ip received # TODO: save the external ip received
log.log('External Ip : ' + arg, 3) log.log('External Ip : ' + arg, 3)
else: else:
......
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