ovpn-server 598 Bytes
Newer Older
Joanne Hugé's avatar
Joanne Hugé committed
1
#!/usr/bin/python -S
2
import os, sys
3

4
script_type = os.environ['script_type']
5 6 7 8 9 10
external_ip = os.getenv('trusted_ip') or os.environ['trusted_ip6']

# Write into pipe connect/disconnect events
fd = int(sys.argv[1])
os.write(fd, repr((script_type, (os.environ['common_name'], os.environ['dev'],
                   int(os.environ['tls_serial_0']), external_ip))))
11 12

if script_type == 'client-connect':
Joanne Hugé's avatar
Joanne Hugé committed
13
    if os.read(fd, 1) == b'\x00':
14
        sys.exit(1)
15 16
    # Send client its external ip address
    with open(sys.argv[2], 'w') as f:
17
        f.write('push "setenv-safe external_ip %s"\n' % external_ip)