Browse Source

Add Chrome OS support

master
Alice 5 years ago
parent
commit
4a05b9fe1e
11 changed files with 119 additions and 8 deletions
  1. +53
    -3
      lambdainst/openvpn.py
  2. +17
    -5
      lambdainst/views.py
  3. +1
    -0
      pages/help.en.md
  4. +1
    -0
      pages/help.fr.md
  5. +23
    -0
      pages/install-chromeos.en.md
  6. +24
    -0
      pages/install-chromeos.fr.md
  7. BIN
      static/pageimg/install_chromeos_1.png
  8. BIN
      static/pageimg/install_chromeos_1_arrows.png
  9. BIN
      static/pageimg/install_chromeos_2.png
  10. BIN
      static/pageimg/install_chromeos_3.png
  11. BIN
      static/pageimg/install_chromeos_4.png

+ 53
- 3
lambdainst/openvpn.py View File

@@ -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 = """\
# +----------------------------+


+ 17
- 5
lambdainst/views.py View File

@@ -305,9 +305,12 @@ def config(request):
def config_dl(request):
allowed_cc = [cc for (cc, _) in get_locations()]

os = request.GET.get('client_os')

common_options = {
'username': request.user.username,
'protocol': request.GET.get('protocol'),
'os': request.GET.get('client_os'),
'os': os,
'http_proxy': request.GET.get('http_proxy'),
'ipv6': 'enable_ipv6' in request.GET,
}
@@ -327,7 +330,10 @@ def config_dl(request):
z = zipfile.ZipFile(f, mode='w')

for gw_name in allowed_cc + ['random']:
filename = 'ccrypto-%s-%s.ovpn' % (gw_name, protocol)
if os == 'chromeos':
filename = 'ccrypto-%s-%s.onc' % (gw_name, protocol)
else:
filename = 'ccrypto-%s-%s.ovpn' % (gw_name, protocol)
config = openvpn.make_config(gw_name=gw_name, **common_options)
z.writestr(filename, config.encode('utf-8'))

@@ -342,15 +348,21 @@ def config_dl(request):
gw_name = location[3:]
else:
gw_name = 'random'
filename = 'ccrypto-%s-%s.ovpn' % (gw_name, protocol)
if os == 'chromeos':
filename = 'ccrypto-%s-%s.onc' % (gw_name, protocol)
else:
filename = 'ccrypto-%s-%s.ovpn' % (gw_name, protocol)

config = openvpn.make_config(gw_name=gw_name, **common_options)

if 'plain' in request.GET:
return HttpResponse(content=config, content_type='text/plain')
else:
r = HttpResponse(content=config, content_type='application/x-openvpn-profile')
r['Content-Disposition'] = 'attachment; filename="%s.ovpn"' % filename
if os == 'chromeos':
r = HttpResponse(content=config, content_type='application/x-onc')
else:
r = HttpResponse(content=config, content_type='application/x-openvpn-profile')
r['Content-Disposition'] = 'attachment; filename="%s"' % filename
return r




+ 1
- 0
pages/help.en.md View File

@@ -8,6 +8,7 @@ Title: Guides
<li><a href="/page/install-windows"><i class="fa fa-windows fa-5x"></i> Windows</a></li>
<li><a href="/page/install-gnulinux"><i class="fa fa-linux fa-5x"></i> GNU/Linux</a></li>
<li><a href="/page/install-osx"><i class="fa fa-apple fa-5x"></i> OS X</a></li>
<li><a href="/page/install-chromeos"><i class="fa fa-chrome fa-5x"></i> Chromebook</a></li>
</ul>

## Support


+ 1
- 0
pages/help.fr.md View File

@@ -7,6 +7,7 @@ Title: Guides
<li><a href="/page/install-windows"><i class="fa fa-windows fa-5x"></i> Windows</a></li>
<li><a href="/page/install-gnulinux"><i class="fa fa-linux fa-5x"></i> GNU/Linux</a></li>
<li><a href="/page/install-osx"><i class="fa fa-apple fa-5x"></i> OS X</a></li>
<li><a href="/page/install-chromeos"><i class="fa fa-chrome fa-5x"></i> Chromebook</a></li>
</ul>

## Support


+ 23
- 0
pages/install-chromeos.en.md View File

@@ -0,0 +1,23 @@
Title: Install on Chrome OS

1. Download the .onc file needed in [your account](/account/config). Select
Chrome OS as the target OS.

2. Go to <chrome://net-internals/#chromeos>, "ChromeOS" section, and import the downloaded file.
It won't display any confirmation; don't worry, it should have imported it anyway.

<img src="/static/pageimg/install_chromeos_1_arrows.png" alt="screenshot" />

3. Open the Chrome OS Settings, click on Private Network (under Ethernet and Wi-Fi),
and select CCrypto VPN.

<img src="/static/pageimg/install_chromeos_2.png" alt="screenshot" />

4. Then click the Connect button, enter your password, and Connect again.

<img src="/static/pageimg/install_chromeos_3.png" alt="screenshot" />

5. Wait a few seconds and it should be connected.

<img src="/static/pageimg/install_chromeos_4.png" alt="screenshot" />


+ 24
- 0
pages/install-chromeos.fr.md View File

@@ -0,0 +1,24 @@
Title: Install on Chrome OS

1. Téléchargez le fichier .onc requis dans [votre compte](/account/config), en choisissant
Chrome OS comme OS.

2. Allez sur <chrome://net-internals/#chromeos>, partie ChromeOS, et importez le fichier téléchargé.
Aucun message ne sera affiché, mais il devrait avoir été importé quand même.

<img src="/static/pageimg/install_chromeos_1_arrows.png" alt="screenshot" />

3. Ouvrez les options de Chrome OS, cliquez sur Private Network (en dessous de Ethernet et Wi-Fi),
et sélectionnez CCrypto VPN.

<img src="/static/pageimg/install_chromeos_2.png" alt="screenshot" />

4. Cliquez ensuite sur le bouton Connect, entrez votre mot de passe, et appuyez sur Connect
à nouveau.

<img src="/static/pageimg/install_chromeos_3.png" alt="screenshot" />

5. Attendez quelques secondes et le VPN devrait être connecté.

<img src="/static/pageimg/install_chromeos_4.png" alt="screenshot" />


BIN
static/pageimg/install_chromeos_1.png View File

Before After
Width: 571  |  Height: 537  |  Size: 33 KiB

BIN
static/pageimg/install_chromeos_1_arrows.png View File

Before After
Width: 571  |  Height: 537  |  Size: 36 KiB

BIN
static/pageimg/install_chromeos_2.png View File

Before After
Width: 665  |  Height: 531  |  Size: 35 KiB

BIN
static/pageimg/install_chromeos_3.png View File

Before After
Width: 432  |  Height: 432  |  Size: 20 KiB

BIN
static/pageimg/install_chromeos_4.png View File

Before After
Width: 321  |  Height: 299  |  Size: 15 KiB

Loading…
Cancel
Save