Update rtorrent
and privoxy
to proton community cli
This commit is contained in:
parent
f5001a28b7
commit
0413612bce
3 changed files with 91 additions and 91 deletions
|
@ -58,7 +58,11 @@ services:
|
||||||
LOG_HTML: "false"
|
LOG_HTML: "false"
|
||||||
CAPTCHA_SOLVER: none
|
CAPTCHA_SOLVER: none
|
||||||
privoxy:
|
privoxy:
|
||||||
image: walt3rl/proton-privoxy
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile_inline: |
|
||||||
|
FROM walt3rl/proton-privoxy
|
||||||
|
RUN apk --update add ip6tables
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
|
|
@ -1,25 +1,36 @@
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from os import environ
|
from os import chmod, environ
|
||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
|
from random import choice
|
||||||
from re import M
|
from re import M
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from protonvpn_cli.cli import FeatureEnum, protonvpn
|
from protonvpn_cli import connection
|
||||||
|
from protonvpn_cli.constants import PASSFILE
|
||||||
|
from protonvpn_cli.utils import check_init, get_fastest_server, get_servers, set_config_value, pull_server_data
|
||||||
|
|
||||||
|
|
||||||
def run_proton(args):
|
def run_proton(args):
|
||||||
exit(
|
exit(
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["pipenv", "run", "proton"],
|
["proton"],
|
||||||
cwd="/app",
|
cwd="/app",
|
||||||
env=dict(
|
env=dict(
|
||||||
environ,
|
environ,
|
||||||
PIPENV_VENV_IN_PROJECT=f"{1}",
|
|
||||||
PVPN_CMD_ARGS=" ".join(args))).returncode)
|
PVPN_CMD_ARGS=" ".join(args))).returncode)
|
||||||
|
|
||||||
|
environ["PVPN_USERNAME"] = environ["PVPN_USERNAME"] + (environ["PVPN_TAGS"] or "")
|
||||||
|
|
||||||
protonvpn.ensure_connectivity()
|
with open(PASSFILE, "w") as f:
|
||||||
|
f.write("{0}\n{1}".format(environ["PVPN_USERNAME"], environ["PVPN_PASSWORD"]))
|
||||||
|
chmod(PASSFILE, 0o600)
|
||||||
|
|
||||||
|
check_init()
|
||||||
|
set_config_value("USER", "username", environ["PVPN_USERNAME"])
|
||||||
|
set_config_value("USER", "tier", environ["PVPN_TIER"])
|
||||||
|
set_config_value("USER", "default_protocol", environ["PVPN_PROTOCOL"])
|
||||||
|
set_config_value("USER", "initialized", 1)
|
||||||
|
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
|
|
||||||
|
@ -29,7 +40,7 @@ if not args:
|
||||||
|
|
||||||
parser = ArgumentParser(exit_on_error=False)
|
parser = ArgumentParser(exit_on_error=False)
|
||||||
subParsers = parser.add_subparsers(dest="command")
|
subParsers = parser.add_subparsers(dest="command")
|
||||||
initParser = subParsers.add_parser("init", alias=["i"])
|
initParser = subParsers.add_parser("init", aliases=["i"])
|
||||||
connectParser = subParsers.add_parser("connect", aliases=["c"])
|
connectParser = subParsers.add_parser("connect", aliases=["c"])
|
||||||
|
|
||||||
for aliases in [
|
for aliases in [
|
||||||
|
@ -50,56 +61,40 @@ try:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if parsedArgs is not None and parsedArgs.command == "init":
|
if parsedArgs is not None and (
|
||||||
userName = input("Enter your Proton VPN username or email: ")
|
len(
|
||||||
subprocess.run(["protonvpn-cli", "login", userName])
|
list(
|
||||||
else:
|
filter(
|
||||||
session = protonvpn.get_session()
|
lambda item: item[1] not in [False, None],
|
||||||
try:
|
vars(parsedArgs).items()))) > 1):
|
||||||
session.ensure_valid()
|
|
||||||
except:
|
|
||||||
raise Exception(
|
|
||||||
"Your current session is invalid. Please initialize the session using the `init` subcommand.")
|
|
||||||
|
|
||||||
environ["PVPN_USERNAME"] = session.vpn_username + \
|
def match(server):
|
||||||
(environ.get("PVPN_TAGS") or "")
|
features = list()
|
||||||
environ["PVPN_PASSWORD"] = session.vpn_password
|
|
||||||
environ["PVPN_TIER"] = f"{session.vpn_tier}"
|
|
||||||
|
|
||||||
if parsedArgs is not None and (
|
if parsedArgs.streaming:
|
||||||
len(
|
pass
|
||||||
list(
|
if parsedArgs.sc:
|
||||||
filter(
|
pass
|
||||||
lambda item: item[1] not in [False, None],
|
if parsedArgs.p2p:
|
||||||
vars(parsedArgs).items()))) > 1):
|
pass
|
||||||
country = protonvpn.get_country()
|
if parsedArgs.tor:
|
||||||
|
pass
|
||||||
|
|
||||||
def match(server):
|
return (parsedArgs.cc is None or server.exit_country.lower() == parsedArgs.cc.lower()) and (
|
||||||
features = list()
|
all(feature in server.features for feature in features))
|
||||||
|
|
||||||
if parsedArgs.streaming:
|
pull_server_data(force=True)
|
||||||
features.append(FeatureEnum.STREAMING)
|
servers = list(filter(lambda server: match(server), get_servers()))
|
||||||
if parsedArgs.sc:
|
|
||||||
features.append(FeatureEnum.SECURE_CORE)
|
|
||||||
if parsedArgs.p2p:
|
|
||||||
features.append(FeatureEnum.P2P)
|
|
||||||
if parsedArgs.tor:
|
|
||||||
features.append(FeatureEnum.TOR)
|
|
||||||
|
|
||||||
return (parsedArgs.cc is None or server.exit_country.lower() == parsedArgs.cc.lower()) and (
|
if len(servers) > 0:
|
||||||
all(feature in server.features for feature in features))
|
if parsedArgs.fastest or not parsedArgs.random:
|
||||||
|
server = get_fastest_server(servers)
|
||||||
servers = session.servers.filter(match)
|
|
||||||
|
|
||||||
if len(servers) > 0:
|
|
||||||
if parsedArgs.fastest or not parsedArgs.random:
|
|
||||||
server = servers.get_fastest_server()
|
|
||||||
else:
|
|
||||||
server = servers.get_random_server()
|
|
||||||
|
|
||||||
run_proton(["connect", server.name])
|
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
server = choice(servers)
|
||||||
f"Unable to find a server matching the specified criteria {args[1:]}!")
|
|
||||||
|
run_proton(["connect", server["Name"]])
|
||||||
else:
|
else:
|
||||||
run_proton(args)
|
raise Exception(
|
||||||
|
f"Unable to find a server matching the specified criteria {args[1:]}!")
|
||||||
|
else:
|
||||||
|
run_proton(args)
|
||||||
|
|
|
@ -5,8 +5,13 @@ FROM debian
|
||||||
ARG PVPN_CLI_VER=2.2.12
|
ARG PVPN_CLI_VER=2.2.12
|
||||||
ARG USERNAME=proton
|
ARG USERNAME=proton
|
||||||
|
|
||||||
ENV PVPN_TAGS="+pmp" \
|
ENV PVPN_USERNAME= \
|
||||||
|
PVPN_USERNAME_FILE= \
|
||||||
|
PVPN_PASSWORD= \
|
||||||
|
PVPN_PASSWORD_FILE= \
|
||||||
|
PVPN_TIER=2 \
|
||||||
PVPN_PROTOCOL=udp \
|
PVPN_PROTOCOL=udp \
|
||||||
|
PVPN_TAGS="+pmp" \
|
||||||
PVPN_CMD_ARGS="connect --p2p --random" \
|
PVPN_CMD_ARGS="connect --p2p --random" \
|
||||||
PVPN_DEBUG= \
|
PVPN_DEBUG= \
|
||||||
HOST_NETWORK= \
|
HOST_NETWORK= \
|
||||||
|
@ -20,9 +25,28 @@ ENV PVPN_TAGS="+pmp" \
|
||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
COPY --from=rtorrent / /
|
COPY --from=rtorrent / /
|
||||||
|
|
||||||
|
RUN apt-get update -y \
|
||||||
|
&& apt-get upgrade -y \
|
||||||
|
&& apt-get install -y \
|
||||||
|
git \
|
||||||
|
iproute2 \
|
||||||
|
iptables \
|
||||||
|
natpmpc \
|
||||||
|
openvpn \
|
||||||
|
pipenv \
|
||||||
|
procps \
|
||||||
|
python3 \
|
||||||
|
python3-pip \
|
||||||
|
python3-setuptools \
|
||||||
|
sudo \
|
||||||
|
&& rm -rf /var/lib/apt/lists
|
||||||
|
|
||||||
|
RUN pip3 install --break-system-packages git+https://github.com/Rafficer/linux-cli-community.git@v$PVPN_CLI_VER#egg=protonvpn-cli
|
||||||
|
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
COPY --from=proton /root/.pvpn-cli /root/.pvpn-cli
|
|
||||||
COPY --from=proton /app/proton-privoxy/run /app/proton
|
COPY --from=proton /app/proton-privoxy/run /app/proton
|
||||||
|
COPY --from=proton /root/.pvpn-cli/pvpn-cli.cfg.clean /root/.pvpn-cli/pvpn-cli.cfg
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
sed -i \
|
sed -i \
|
||||||
|
@ -32,43 +56,7 @@ RUN \
|
||||||
&& install -t /usr/local/bin /app/proton \
|
&& install -t /usr/local/bin /app/proton \
|
||||||
&& rm /app/proton
|
&& rm /app/proton
|
||||||
|
|
||||||
RUN apt-get update -y \
|
|
||||||
&& apt-get upgrade -y \
|
|
||||||
&& apt-get install -y \
|
|
||||||
curl \
|
|
||||||
gnupg \
|
|
||||||
&& curl https://repo.protonvpn.com/debian/dists/stable/main/binary-all/protonvpn-stable-release_1.0.3-3_all.deb -o proton.deb \
|
|
||||||
&& dpkg --install proton.deb \
|
|
||||||
&& apt-get remove -y \
|
|
||||||
curl \
|
|
||||||
&& apt-get update -y \
|
|
||||||
&& apt-get install -y protonvpn-cli \
|
|
||||||
&& rm -rf /var/lib/apt/lists
|
|
||||||
|
|
||||||
RUN apt-get update -y \
|
|
||||||
&& apt-get upgrade -y \
|
|
||||||
&& apt-get install -y \
|
|
||||||
git \
|
|
||||||
iproute2 \
|
|
||||||
iptables \
|
|
||||||
natpmpc \
|
|
||||||
pipenv \
|
|
||||||
python3-setuptools \
|
|
||||||
sudo \
|
|
||||||
&& rm -rf /var/lib/apt/lists
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
cd /app \
|
|
||||||
&& PIPENV_VENV_IN_PROJECT=1 pipenv install git+https://github.com/Rafficer/linux-cli-community.git@v$PVPN_CLI_VER#egg=protonvpn-cli
|
|
||||||
|
|
||||||
RUN printf "%s\n" \
|
RUN printf "%s\n" \
|
||||||
"#!/usr/bin/env -S dbus-run-session -- bash" \
|
|
||||||
"mkdir -p /proton/{keyrings,protonvpn}" \
|
|
||||||
"mkdir -p ~/.local/share" \
|
|
||||||
"mkdir -p ~/.config" \
|
|
||||||
"ln -Ts /proton/keyrings ~/.local/share/keyrings >/dev/null 2>&1" \
|
|
||||||
"ln -Ts /proton/protonvpn ~/.config/protonvpn >/dev/null 2>&1" \
|
|
||||||
"eval \"\$(echo -n 'root' | gnome-keyring-daemon --unlock)\"" \
|
|
||||||
"python3 /app/pvpn-cli.py \"\$@\"" > ./pvpn-cli \
|
"python3 /app/pvpn-cli.py \"\$@\"" > ./pvpn-cli \
|
||||||
&& install -Dm 755 ./pvpn-cli /usr/local/bin \
|
&& install -Dm 755 ./pvpn-cli /usr/local/bin \
|
||||||
&& rm ./pvpn-cli
|
&& rm ./pvpn-cli
|
||||||
|
@ -77,7 +65,20 @@ RUN printf "%s\n" \
|
||||||
"#!/bin/bash" \
|
"#!/bin/bash" \
|
||||||
"groupadd --gid \$PGID ${USERNAME} > /dev/null" \
|
"groupadd --gid \$PGID ${USERNAME} > /dev/null" \
|
||||||
"useradd --create-home --home-dir \$PHOME ${USERNAME} --uid \$PUID -g ${USERNAME} 2>/dev/null" \
|
"useradd --create-home --home-dir \$PHOME ${USERNAME} --uid \$PUID -g ${USERNAME} 2>/dev/null" \
|
||||||
|
"chown ${USERNAME} \$PHOME" \
|
||||||
'[ ! -z "$1" ] && [ "$1" = "init" ] && export PVPN_CMD_ARGS="$@"' \
|
'[ ! -z "$1" ] && [ "$1" = "init" ] && export PVPN_CMD_ARGS="$@"' \
|
||||||
|
'if [ -z "$PVPN_USERNAME" ] && [ -z "$PVPN_USERNAME_FILE" ]; then' \
|
||||||
|
" echo 'Error: Either env var \$PVPN_USERNAME or \$PVPN_USERNAME_FILE is required.'" \
|
||||||
|
"exit 1" \
|
||||||
|
"fi" \
|
||||||
|
"" \
|
||||||
|
'if [ -z "$PVPN_PASSWORD" ] && [ -z "$PVPN_PASSWORD_FILE" ]; then' \
|
||||||
|
"echo 'Error: Either env var \$PVPN_PASSWORD or \$PVPN_PASSWORD_FILE is required.'" \
|
||||||
|
"exit 1" \
|
||||||
|
"fi" \
|
||||||
|
"" \
|
||||||
|
'[ -f "$PVPN_USERNAME_FILE" ] && PVPN_USERNAME=$(cat "$PVPN_USERNAME_FILE")' \
|
||||||
|
'[ -f "$PVPN_PASSWORD_FILE" ] && PVPN_PASSWORD=$(cat "$PVPN_PASSWORD_FILE")' \
|
||||||
"pvpn-cli || exit" \
|
"pvpn-cli || exit" \
|
||||||
'ip link show proton0 > /dev/null 2>&1 || exit' \
|
'ip link show proton0 > /dev/null 2>&1 || exit' \
|
||||||
'fallback="$(expr ${NATPMP_TIMEOUT} \* 3 / 4)"' \
|
'fallback="$(expr ${NATPMP_TIMEOUT} \* 3 / 4)"' \
|
||||||
|
|
Loading…
Reference in a new issue