Skip to content

Commit

Permalink
improve documentation and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
elfkuzco committed Sep 2, 2024
1 parent dce883b commit 45b4e65
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 24 deletions.
1 change: 1 addition & 0 deletions protonvpn-wireguard-config-downloader/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM python:3.11-slim-bookworm
LABEL org.opencontainers.image.source=https://github.com/kiwix/mirrors-qa

# We need gnupg2 for python-gnupg used in Proton libraries to work properly.
RUN apt-get update && apt-get install -y gnupg2

COPY src /src/src
Expand Down
4 changes: 2 additions & 2 deletions protonvpn-wireguard-config-downloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This script is intended to be used in Linux environments only.
- `USERNAME`: username for connnecting to ProtonVPN account
- `PASSWORD`
- `WORKDIR`: location to store configuration files. (default: /data)
- `WIREGUARD_PORT`: Port of the wireguard configuration files (default: 51820)
- `WIREGUARD_PORT`: Port of the wireguard configuration files (default: 51820).This allows to choose the wireguard port for the configuration files rather than leaving it to the ProtonVPN library which often defaults to the first available port in the session object.

## Usage
- Build the image
Expand All @@ -19,5 +19,5 @@ This script is intended to be used in Linux environments only.
```
- Download the configuration files
```sh
docker run --rm -e USERNAME=abcd@efg -e PASSWORD=pa55word -v ./:/data protonvpn-wireguard-config-downloader protonvpn-wireguard-configs
docker run --rm -e USERNAME=abcd@efg -e PASSWORD=pa55word -v ./proton:/data protonvpn-wireguard-config-downloader protonvpn-wireguard-configs
```
15 changes: 8 additions & 7 deletions protonvpn-wireguard-config-downloader/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ license = {text = "GPL-3.0-or-later"}
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]

Expand All @@ -34,19 +35,19 @@ scripts = [
"invoke==2.2.0",
]
lint = [
"black==24.1.1",
"ruff==0.2.0",
"black==24.4.2",
"ruff==0.5.1",
]
check = [
"pyright==1.1.349",
"pyright==1.1.370",
]
test = [
"pytest==8.0.0",
"coverage==7.4.1",
"pytest==8.2.2",
"coverage==7.5.4",
]
dev = [
"pre-commit==3.6.0",
"debugpy==1.8.0",
"pre-commit==3.7.1",
"debugpy==1.8.2",
"protonvpn_wireguard_config_downloader[scripts]",
"protonvpn_wireguard_config_downloader[lint]",
"protonvpn_wireguard_config_downloader[test]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.1-dev0"
__version__ = "1.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ async def logout(session: VPNSession) -> None:
await session.async_logout()


def wireguard_port_is_available(session: VPNSession, port: int) -> bool:
"""Check that the wireguard port is available in the client config."""
return port in session.client_config.wireguard_ports.udp


def vpn_servers(
session: VPNSession,
wireguard_port: int,
Expand All @@ -51,6 +46,8 @@ def vpn_servers(
if wireguard_port not in client_config.wireguard_ports.udp:
raise ValueError(f"Port {wireguard_port} is not available in client config.")

# Build up the list of servers, filtering out disabled servers and
# servers that are above the client's tier.
logical_servers = (
server
for server in session.server_list.logicals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ class Settings:
DEBUG = bool(getenv("DEBUG", default=False))
WORKDIR = Path(getenv("WORKDIR", default="/data")).resolve()
PROTONVPN_VERSION = getenv("PROTONVPN_APP_VERSION", default="4.4.4")
PROTONVPN_APP_VERSION = getenv(
"PROTONVPN_APP_VERSION", default=f"LinuxVPN_{PROTONVPN_VERSION}"
)
USER_AGENT = getenv(
"USER_AGENT",
default=(
f"ProtonVPN/{PROTONVPN_VERSION} "
f"(Linux; {distro.name()}/{distro.version()})"
),
PROTONVPN_APP_VERSION = f"LinuxVPN_{PROTONVPN_VERSION}"
USER_AGENT = (
f"ProtonVPN/{PROTONVPN_VERSION} (Linux; {distro.name()}/{distro.version()})"
)
WIREGUARD_PORT = int(getenv("WIREGUARD_PORT", default=51820))

0 comments on commit 45b4e65

Please sign in to comment.