diff --git a/arch/PKGBUILD b/arch/PKGBUILD index 9872d67..fcb9249 100644 --- a/arch/PKGBUILD +++ b/arch/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Proton Technologies AG pkgname=protonvpn-cli pkgver=3.5.0 -pkgrel=1 +pkgrel=2 pkgdesc="Official ProtonVPN CLI." arch=("any") url="https://github.com/ProtonVPN/" diff --git a/debian/changelog b/debian/changelog index d4eff4b..e0be175 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ -protonvpn-cli (3.5.0-1) unstable; urgency=low +protonvpn-cli (3.5.0-2) unstable; urgency=low * Handle servers with multiple features + * Fix server feature issue when displaying connection status -- Proton Technologies AG Tue, 30 Mar 2021 12:20:00 +0100 diff --git a/protonvpn_cli/cli_dialog.py b/protonvpn_cli/cli_dialog.py index c41391f..314610d 100644 --- a/protonvpn_cli/cli_dialog.py +++ b/protonvpn_cli/cli_dialog.py @@ -1,3 +1,4 @@ +import copy import sys from dialog import Dialog @@ -110,9 +111,21 @@ def display_servers(self, country, countries): servername ) load = str(int(server.load)).rjust(3, " ") - features = ", ".join( - [self.SUPPORTED_FEATURES[feature] for feature in server.features] - ) + _features = copy.copy(server.features) + try: + _features.pop(FeatureEnum.NORMAL) + except IndexError: + pass + + if len(_features) > 1: + features = ", ".join( + [self.SUPPORTED_FEATURES[feature] for feature in _features] + ) + elif len(_features) == 1: + features = self.SUPPORTED_FEATURES[_features[0]] + else: + features = "" + tier = self.SERVER_TIERS[ServerTierEnum(server.tier)] choices.append( diff --git a/protonvpn_cli/cli_wrapper.py b/protonvpn_cli/cli_wrapper.py index a2f4923..3b152d0 100644 --- a/protonvpn_cli/cli_wrapper.py +++ b/protonvpn_cli/cli_wrapper.py @@ -4,6 +4,7 @@ import os import time from textwrap import dedent +import copy from proton.constants import VERSION as proton_version from protonvpn_nm_lib import exceptions @@ -582,6 +583,12 @@ def status(self): print("\nNo active ProtonVPN connection.") return + # cache servers if needed + try: + self.protonvpn.get_session().servers + except: # noqa + pass + logger.info("Gathering connection information") conn_status_dict = self.__transform_status_to_readable_format( self.protonvpn.get_connection_status() @@ -591,12 +598,21 @@ def status(self): ) tier_enum = ServerTierEnum(server.tier) + _features = copy.copy(server.features) + try: + _features.pop(FeatureEnum.NORMAL) + except IndexError: + pass - features = ", ".join( - [self.SUPPORTED_FEATURES[feature] for feature in server.features] - ) + if len(_features) > 1: + features = ", ".join( + [self.SUPPORTED_FEATURES[feature] for feature in _features] + ) + elif len(_features) == 1: + features = self.SUPPORTED_FEATURES[_features[0]] + else: + features = "None" features = "Server Features: " + features - entry_country = self.protonvpn.country.get_country_name( server.entry_country ) @@ -625,17 +641,11 @@ def status(self): load=int(server.load), server_tier=self.SERVER_TIERS[tier_enum], features="" - if ( - len(server.features) == 0 - or ( - len(server.features) == 1 - and FeatureEnum.NORMAL in server.features - ) - ) + if len(_features) == 0 else features + "\n", secure_core=( "{} >> ".format(entry_country) - if FeatureEnum.SECURE_CORE in server.features + if FeatureEnum.SECURE_CORE in _features else "" ), killswitch_status=conn_status_dict[ diff --git a/rpmbuild/SPECS/protonvpn-cli.spec b/rpmbuild/SPECS/protonvpn-cli.spec index a1b38bb..8852854 100644 --- a/rpmbuild/SPECS/protonvpn-cli.spec +++ b/rpmbuild/SPECS/protonvpn-cli.spec @@ -1,6 +1,6 @@ %define unmangled_name protonvpn-cli %define version 3.5.0 -%define release 1 +%define release 2 Prefix: %{_prefix} @@ -46,8 +46,9 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %changelog -* Tue Mar 30 2021 Proton Technologies AG 3.5.0-1 +* Tue Mar 30 2021 Proton Technologies AG 3.5.0-2 - Handle servers with multiple features +- Fix server feature issue when displaying connection status * Tue Mar 30 2021 Proton Technologies AG 3.4.1-4 - Fix dialog crash