Skip to content

Commit 81dfeec

Browse files
committed
Support for the client to declare itself
* Introduces support for the client to declare itself as ProtonVPN Linux Community client. Signed-off-by: Samuele Kaplun <kaplun@protonmail.com>
1 parent dd0aab7 commit 81dfeec

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Table of Contents
44

5+
- [v2.2.5](#v225)
56
- [v2.2.4](#v224)
67
- [v2.2.3](#v223)
78
- [v2.2.2](#v222)
@@ -13,6 +14,10 @@
1314
- [v2.0.0](#v200)
1415
- [v0.1.0](#v010)
1516

17+
## v2.2.5
18+
19+
- Enhancement: Introduces support for the client to declare itself
20+
1621
## v2.2.4
1722

1823
- Bug fix: Failing to connect when choosing a server via dialog menu

protonvpn_cli/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
)
6464
# Constants
6565
from .constants import (
66-
CONFIG_DIR, CONFIG_FILE, PASSFILE, USER, VERSION, SPLIT_TUNNEL_FILE
66+
CONFIG_DIR, CONFIG_FILE, PASSFILE, USER, VERSION, SPLIT_TUNNEL_FILE, CLIENT_SUFFIX
6767
)
6868

6969

@@ -256,7 +256,7 @@ def init_config_file():
256256
set_config_value("USER", "killswitch", 0)
257257

258258
with open(PASSFILE, "w") as f:
259-
f.write("{0}\n{1}".format(ovpn_username, ovpn_password))
259+
f.write("{0}+{1}\n{2}".format(ovpn_username, CLIENT_SUFFIX, ovpn_password))
260260
logger.debug("Passfile created")
261261
os.chmod(PASSFILE, 0o600)
262262

protonvpn_cli/connection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
set_config_value, get_ip_info, get_country_name,
2020
get_fastest_server, check_update, get_default_nic,
2121
get_transferred_data, create_openvpn_config,
22-
is_ipv6_disabled
22+
is_ipv6_disabled, patch_passfile
2323
)
2424
# Constants
2525
from .constants import (
26-
CONFIG_DIR, OVPN_FILE, PASSFILE, CONFIG_FILE
26+
CONFIG_DIR, OVPN_FILE, PASSFILE, CONFIG_FILE, CLIENT_SUFFIX
2727
)
2828

2929

@@ -459,6 +459,8 @@ def openvpn_connect(servername, protocol):
459459

460460
print("Connecting to {0} via {1}...".format(servername, protocol.upper()))
461461

462+
patch_passfile(PASSFILE)
463+
462464
with open(os.path.join(CONFIG_DIR, "ovpn.log"), "w+") as f:
463465
subprocess.Popen(
464466
[

protonvpn_cli/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
SPLIT_TUNNEL_FILE = os.path.join(CONFIG_DIR, "split_tunnel.txt")
1818
OVPN_FILE = os.path.join(CONFIG_DIR, "connect.ovpn")
1919
PASSFILE = os.path.join(CONFIG_DIR, "pvpnpass")
20-
VERSION = "2.2.4"
20+
CLIENT_SUFFIX = "plc" # ProtonVPN Linux Community
21+
VERSION = "2.2.5"

protonvpn_cli/utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Constants
1818
from .constants import (
1919
USER, CONFIG_FILE, SERVER_INFO_FILE, SPLIT_TUNNEL_FILE,
20-
VERSION, OVPN_FILE
20+
VERSION, OVPN_FILE, CLIENT_SUFFIX
2121
)
2222

2323

@@ -521,3 +521,14 @@ def convert_size(size_bytes):
521521
rx_bytes = int(f.read())
522522

523523
return convert_size(tx_bytes), convert_size(rx_bytes)
524+
525+
526+
def patch_passfile(passfile):
527+
with open(passfile, "r") as f:
528+
ovpn_username = f.readline()
529+
ovpn_password = f.readline()
530+
if CLIENT_SUFFIX not in ovpn_username.strip().split('+')[1:]:
531+
# Let's append the CLIENT_SUFFIX
532+
with open(passfile, "w") as f:
533+
f.write("{0}+{1}\n{2}".format(ovpn_username.strip(), CLIENT_SUFFIX, ovpn_password))
534+
os.chmod(passfile, 0o600)

0 commit comments

Comments
 (0)