|
|
@@ -1,3 +1,5 @@ |
|
|
|
import json |
|
|
|
import uuid |
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
from django.conf import settings |
|
|
|
|
|
|
@@ -10,6 +12,7 @@ CONFIG_OS = ( |
|
|
|
('ubuntu', _("Ubuntu")), |
|
|
|
('osx', _("OS X")), |
|
|
|
('ios', _("iOS")), |
|
|
|
('chromeos', _("Chrome OS")), |
|
|
|
('freebox', _("Freebox")), |
|
|
|
('other', _("Other / GNU/Linux")), |
|
|
|
) |
|
|
@@ -21,7 +24,45 @@ PROTOCOLS = ( |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def make_config(gw_name, os, protocol, http_proxy=None, ipv6=True): |
|
|
|
def _make_onc(username, name, hostname, port, protocol, http_proxy=None, ipv6=True): |
|
|
|
cert_id = '{%s}' % uuid.uuid4() |
|
|
|
vpn_id = '{%s}' % uuid.uuid4() |
|
|
|
|
|
|
|
openvpn_config = { |
|
|
|
'ServerCARef': cert_id, |
|
|
|
'ClientCertType': 'None', |
|
|
|
'CompLZO': 'true', |
|
|
|
'Port': port, |
|
|
|
'Proto': protocol, |
|
|
|
'ServerPollTimeout': 10, |
|
|
|
'NsCertType': 'server', |
|
|
|
'Username': username, |
|
|
|
} |
|
|
|
cert = { |
|
|
|
'GUID': cert_id, |
|
|
|
'Type': 'Authority', |
|
|
|
'X509': CA_CERT.strip().replace('\n', '\\n'), |
|
|
|
} |
|
|
|
vpn = { |
|
|
|
'GUID': vpn_id, |
|
|
|
'Name': name, |
|
|
|
'Type': 'VPN', |
|
|
|
'VPN': { |
|
|
|
'Type': 'OpenVPN', |
|
|
|
'Host': hostname, |
|
|
|
'OpenVPN': openvpn_config, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
return json.dumps({ |
|
|
|
'type': 'UnencryptedConfiguration', |
|
|
|
'Certificates': [cert], |
|
|
|
'NetworkConfigurations': [vpn], |
|
|
|
}, indent=2) |
|
|
|
|
|
|
|
|
|
|
|
def make_config(username, gw_name, os, protocol, http_proxy=None, ipv6=True): |
|
|
|
|
|
|
|
use_frag = protocol == 'udpl' and os != 'ios' |
|
|
|
ipv6 = ipv6 and (os != 'freebox') |
|
|
|
http_proxy = http_proxy if protocol == 'tcp' else None |
|
|
@@ -31,9 +72,18 @@ def make_config(gw_name, os, protocol, http_proxy=None, ipv6=True): |
|
|
|
openvpn_ports = {'udp': 1196, 'udpl': 1194, 'tcp': 443} |
|
|
|
|
|
|
|
hostname = 'gw.%s.204vpn.net' % gw_name |
|
|
|
port = openvpn_ports[protocol] |
|
|
|
proto = openvpn_proto[protocol] |
|
|
|
|
|
|
|
if os == 'chromeos': |
|
|
|
name = "CCrypto VPN" |
|
|
|
if gw_name != 'random': |
|
|
|
name += " " + gw_name.upper() |
|
|
|
return _make_onc(username, name, hostname, port, proto, http_proxy, ipv6) |
|
|
|
|
|
|
|
remote = str(hostname) |
|
|
|
remote += ' ' + str(openvpn_ports[protocol]) |
|
|
|
remote += ' ' + openvpn_proto[protocol] |
|
|
|
remote += ' ' + str(port) |
|
|
|
remote += ' ' + proto |
|
|
|
|
|
|
|
config = """\ |
|
|
|
# +----------------------------+ |
|
|
|