Skip to content

Commit

Permalink
Merge branch 'feature/VPNLINUX-317-moderate-nat' into 'develop'
Browse files Browse the repository at this point in the history
Add feature: Moderate NAT [VPNLINUX-317]

See merge request ProtonVPN/linux/linux-cli!53
  • Loading branch information
calexandru2018 committed Feb 24, 2022
2 parents 01acd65 + b1f0993 commit 3c27451
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 23 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=1
pkgrel=2
pkgdesc="Official ProtonVPN CLI."
arch=("any")
url="https://github.com/ProtonVPN/"
Expand Down
5 changes: 3 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
protonvpn-cli (3.11.1-1) unstable; urgency=medium
protonvpn-cli (3.11.1-2) unstable; urgency=medium

* Bug: Display message when incorrectly formatted servername is provided
* Bugfix: Display message when incorrectly formatted servername is provided
* Feature: Modereate NAT

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

Expand Down
30 changes: 17 additions & 13 deletions protonvpn_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ def custom_dns():
"disable",
]
)
group.add_argument(
"--moderate-nat",
help="Moderate NAT.",
nargs=1,
choices=[
"enable",
"disable",
]
)
group.add_argument(
"-d", "--default",
help="Reset do default configurations.",
Expand All @@ -361,24 +370,19 @@ def custom_dns():
and not args.list
and not args.vpn_accelerator
and not args.alt_routing
and not args.moderate_nat
)
):
print(CONFIG_HELP)
return 0
elif (
(
not args.protocol
and not args.default
and not args.alt_routing
and not args.vpn_accelerator
and not args.help
) or (
not args.protocol
and not args.vpn_accelerator
and not args.alt_routing
and not args.default
and args.help
)
not args.protocol
and not args.default
and not args.alt_routing
and not args.vpn_accelerator
and not args.moderate_nat
and not args.help

) and args.dns and args.dns.pop() == "custom":
return custom_dns()

Expand Down
28 changes: 24 additions & 4 deletions protonvpn_cli/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@ def set_alternative_routing(self, status):
print("\nAlternative Routing has been {}d. ".format(status))
return 0

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

try:
self.user_settings.moderate_nat = _status[status]
except KeyError as e:
logger.exception(e)
print("\nInvalid option was provided")
return 1
except Exception as e:
logger.exception(e)
print(e)
return 1

print("\nModerate NAT has been {}d. ".format(status))
return 0

def logout(self):
"""Proxymethod to logout user."""
if not self.protonvpn.check_session_exists():
Expand Down Expand Up @@ -481,10 +501,9 @@ def set_netshield(self, args):
print("\nPlease login to to be able to set NetShield.")
return 1

# To-do: Once infra is updated, implement this check
# if not self.protonvpn.get_session().clientconfig.features.netshield:
# print("\nThis feature is currently not supported.")
# return
if not self.protonvpn.get_session().clientconfig.features.netshield:
print("\nThis feature is currently not supported.")
return

session = self.protonvpn.get_session()
if not args.off and session.vpn_tier == ServerTierEnum.FREE.value:
Expand Down Expand Up @@ -540,6 +559,7 @@ def configurations_menu(self, args):
list=self.list_configurations,
vpn_accelerator=self.set_vpn_accelerator,
alt_routing=self.set_alternative_routing,
moderate_nat=self.set_moderate_nat,
default=self.restore_default_configurations,
)

Expand Down
3 changes: 3 additions & 0 deletions protonvpn_cli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
-p, --protocol Change default protocol.
-d, --default Reset to default configurations.
--alt-routing Change alternative routing preference.
--moderate-nat Change Moderate NAT preference.
If disabled then strict NAT is applied.
--vpn-accelerator VPN Accelerator enables a set of unique performance
enhancing technologies which can increase VPN speeds by up to 400%.
-h, --help Display help message.
Expand All @@ -108,6 +110,7 @@
protonvpn-cli config --protocol udp
protonvpn-cli config --vpn-accelerator enable
protonvpn-cli config --alt-routing enable
protonvpn-cli config --moderate-nat disable
protonvpn-cli config (-d | --default)
protonvpn-cli config --help
""" # noqa
Expand Down
7 changes: 4 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 1
%define release 2

Prefix: %{_prefix}

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

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

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

0 comments on commit 3c27451

Please sign in to comment.