Skip to content

Commit

Permalink
Add feature: Non Standard Ports [VPNLINUX-315]
Browse files Browse the repository at this point in the history
  • Loading branch information
calexandru2018 committed Feb 24, 2022
1 parent 3c27451 commit a9a8eb8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
2 changes: 1 addition & 1 deletion arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Proton Technologies AG <[email protected]>
pkgname=protonvpn-cli
pkgver=3.11.1
pkgrel=2
pkgrel=3
pkgdesc="Official ProtonVPN CLI."
arch=("any")
url="https://github.com/ProtonVPN/"
Expand Down
4 changes: 2 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
protonvpn-cli (3.11.1-2) unstable; urgency=medium
protonvpn-cli (3.11.1-3) unstable; urgency=medium

* Bugfix: Display message when incorrectly formatted servername is provided
* Feature: Modereate NAT
* Feature: Moderate NAT, Non Standard Ports

-- Proton Technologies AG <[email protected]> Thu, 16 Dez 2021 09:00:00 +0000

Expand Down
11 changes: 11 additions & 0 deletions protonvpn_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ def custom_dns():
"disable",
]
)
group.add_argument(
"--non-standard-ports",
help="Non Standard Ports.",
nargs=1,
choices=[
"enable",
"disable",
]
)
group.add_argument(
"-d", "--default",
help="Reset do default configurations.",
Expand All @@ -371,6 +380,7 @@ def custom_dns():
and not args.vpn_accelerator
and not args.alt_routing
and not args.moderate_nat
and not args.non_standard_ports
)
):
print(CONFIG_HELP)
Expand All @@ -381,6 +391,7 @@ def custom_dns():
and not args.alt_routing
and not args.vpn_accelerator
and not args.moderate_nat
and not args.non_standard_ports
and not args.help

) and args.dns and args.dns.pop() == "custom":
Expand Down
38 changes: 38 additions & 0 deletions protonvpn_cli/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ def set_moderate_nat(self, status):
logger.exception(e)
print("\nInvalid option was provided")
return 1
except exceptions.APISessionIsNotValidError as e:
logger.exception(e)
print("\nPlease login to make any changes")
return 1
except Exception as e:
logger.exception(e)
print(e)
Expand All @@ -167,6 +171,30 @@ def set_moderate_nat(self, status):
print("\nModerate NAT has been {}d. ".format(status))
return 0

def set_non_standard_ports(self, status):
_status = {
"enable": UserSettingStatusEnum.ENABLED,
"disable": UserSettingStatusEnum.DISABLED
}

try:
self.user_settings.non_standard_ports = _status[status]
except KeyError as e:
logger.exception(e)
print("\nInvalid option was provided")
return 1
except exceptions.APISessionIsNotValidError as e:
logger.exception(e)
print("\nPlease login to make any changes")
return 1
except Exception as e:
logger.exception(e)
print(e)
return 1

print("\nNon Standard Ports have been {}d. ".format(status))
return 0

def logout(self):
"""Proxymethod to logout user."""
if not self.protonvpn.check_session_exists():
Expand Down Expand Up @@ -560,6 +588,7 @@ def configurations_menu(self, args):
vpn_accelerator=self.set_vpn_accelerator,
alt_routing=self.set_alternative_routing,
moderate_nat=self.set_moderate_nat,
non_standard_ports=self.set_non_standard_ports,
default=self.restore_default_configurations,
)

Expand Down Expand Up @@ -688,13 +717,17 @@ def list_configurations(self, _):
DNS:\t\t\t{dns}
Alternative Routing:\t{alt_routing}
VPN Accelerator:\t{vpn_accel}
Moderate NAT:\t\t{mod_nat}
Non Standard Ports:\t{non_stand_ports}
""").format(
protocol=user_settings_dict[DisplayUserSettingsEnum.PROTOCOL],
alt_routing=user_settings_dict[DisplayUserSettingsEnum.ALT_ROUTING],
killswitch=user_settings_dict[DisplayUserSettingsEnum.KILLSWITCH],
netshield=user_settings_dict[DisplayUserSettingsEnum.NETSHIELD],
vpn_accel=user_settings_dict[DisplayUserSettingsEnum.VPN_ACCELERATOR],
dns=user_settings_dict[DisplayUserSettingsEnum.DNS],
mod_nat=user_settings_dict[DisplayUserSettingsEnum.MODERATE_NAT],
non_stand_ports=user_settings_dict[DisplayUserSettingsEnum.NON_STANDARD_PORTS],
)
print(status_to_print)
return 0
Expand All @@ -715,6 +748,9 @@ def __transform_user_setting_to_readable_format(self, raw_format):
raw_ns = raw_format[DisplayUserSettingsEnum.NETSHIELD]
raw_alt_routing = raw_format[DisplayUserSettingsEnum.ALT_ROUTING]
raw_vpn_accel = raw_format[DisplayUserSettingsEnum.VPN_ACCELERATOR]
moderate_nat = "On" if bool(raw_format[DisplayUserSettingsEnum.MODERATE_NAT].value) else "Off"
non_standard_ports = "On" if bool(raw_format[DisplayUserSettingsEnum.NON_STANDARD_PORTS].value) else "Off"


# protocol
if raw_protocol in SUPPORTED_PROTOCOLS[ProtocolImplementationEnum.OPENVPN]: # noqa
Expand Down Expand Up @@ -757,6 +793,8 @@ def __transform_user_setting_to_readable_format(self, raw_format):
DisplayUserSettingsEnum.NETSHIELD: transformed_ns,
DisplayUserSettingsEnum.ALT_ROUTING: transformed_alt_routing,
DisplayUserSettingsEnum.VPN_ACCELERATOR: transformed_vpn_accel,
DisplayUserSettingsEnum.MODERATE_NAT: moderate_nat,
DisplayUserSettingsEnum.NON_STANDARD_PORTS: non_standard_ports,
}

def restore_default_configurations(self, _):
Expand Down
6 changes: 3 additions & 3 deletions rpmbuild/SPECS/protonvpn-cli.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%define unmangled_name protonvpn-cli
%define version 3.11.1
%define release 2
%define release 3

Prefix: %{_prefix}

Expand Down Expand Up @@ -46,9 +46,9 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root)

%changelog
* Thu Dez 16 2021 Proton Technologies AG <[email protected]> 3.11.1-2
* Thu Dez 16 2021 Proton Technologies AG <[email protected]> 3.11.1-3
- Bugfix: Display message when incorrectly formatted servername is provided
- Feature: Modereate NAT
- Feature: Moderate NAT, Non Standard Ports

* Thu Nov 12 2021 Proton Technologies AG <[email protected]> 3.11.0-7
- Improve: Handle accounting use cases
Expand Down

0 comments on commit a9a8eb8

Please sign in to comment.