-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmullvad-test.py
47 lines (31 loc) · 1.38 KB
/
mullvad-test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
from mullvad import MullvadAPI
# --->
ACCOUNT_NUMBER = '###################'
mullvad = MullvadAPI(ACCOUNT_NUMBER)
# --- List countries
relays = mullvad._list_relays_json()
countries = relays['countries']
# for country in countries:
# print('\n= %s [ %s ] =' % (country['name'], country['code']))
# for city in country['cities']:
# print('%s [ %s ]' % (city['name'], city['code']))
# for relay in city['relays']:
# print('\t----> %s [ %s ]' % (relay['hostname'], relay['ipv4_addr_in']))
print('There are %d countries listed on MullVad' % len(relays))
# -- Get a specific exit location (by hostname)
# print(mullvad.get_relay('us58-wireguard'))
# --- A) Create private and public key
# private_key = mullvad.generate_pkey()
# print('Private Key: %s' % str(private_key))
# public_key = mullvad._derivatePubKey(private_key)
# print('Public Key: %s' % str(public_key))
# --- B) Or just upload an existing private key to Mullvad
# print(mullvad.add_pubkey(public_key))
private_key = 'uO/q4VmwVy62UJpFdcup/w+pjYPiNa603xshTsjr10s='
# ---- And let MullvadAPI generate a wireguard configuration, given a hostname
res = mullvad.generate_conf(hostname='us58-wireguard') # , private_key = private_key
print(res)
# Finally, revoke the key from MullVad
public_key = mullvad._derivatePubKey(private_key)
print(mullvad.revoke_pubkey(res['public_key']))