Upload 11 files
Browse files- .github/dependabot.yml +8 -0
- .github/workflows/docker.yml +39 -0
- Dockerfile +27 -0
- LICENSE.md +25 -0
- app/proton-privoxy/config +6 -0
- app/proton-privoxy/run +68 -0
- pvpn-cli/pvpn-cli.cfg.clean +14 -0
- test/docker_secrets_test/creds/password +1 -0
- test/docker_secrets_test/creds/username +1 -0
- test/docker_secrets_test/docker-compose.yml +18 -0
- test/docker_secrets_test/test.sh +28 -0
.github/dependabot.yml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
version: 2
|
| 3 |
+
updates:
|
| 4 |
+
# Maintain dependencies for GitHub Actions
|
| 5 |
+
- package-ecosystem: "github-actions"
|
| 6 |
+
directory: "/"
|
| 7 |
+
schedule:
|
| 8 |
+
interval: "weekly"
|
.github/workflows/docker.yml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CI
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [ master ]
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
schedule:
|
| 8 |
+
- cron: "0 8 * * 1"
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
buildx:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
- name: Checkout
|
| 15 |
+
uses: actions/checkout@v4
|
| 16 |
+
|
| 17 |
+
- name: Docker Login
|
| 18 |
+
uses: docker/login-action@v3.0.0
|
| 19 |
+
with:
|
| 20 |
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
| 21 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 22 |
+
|
| 23 |
+
- name: Set up QEMU
|
| 24 |
+
uses: docker/setup-qemu-action@v3
|
| 25 |
+
|
| 26 |
+
- name: Set up Docker Buildx
|
| 27 |
+
id: buildx
|
| 28 |
+
uses: docker/setup-buildx-action@v3
|
| 29 |
+
|
| 30 |
+
- name: Build and push latest
|
| 31 |
+
uses: docker/build-push-action@v5
|
| 32 |
+
with:
|
| 33 |
+
context: .
|
| 34 |
+
file: ./Dockerfile
|
| 35 |
+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
| 36 |
+
push: true
|
| 37 |
+
tags: |
|
| 38 |
+
walt3rl/proton-privoxy:latest
|
| 39 |
+
walt3rl/proton-privoxy:0.4.2
|
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM alpine:3.16
|
| 2 |
+
LABEL maintainer="Walter Leibbrandt"
|
| 3 |
+
LABEL version="0.4.3"
|
| 4 |
+
# XXX Copy version to Docker image tag in .github/workflows/docker.yml when changing!
|
| 5 |
+
|
| 6 |
+
EXPOSE 8080
|
| 7 |
+
|
| 8 |
+
ARG PVPN_CLI_VER=2.2.12
|
| 9 |
+
ENV PVPN_USERNAME= \
|
| 10 |
+
PVPN_USERNAME_FILE= \
|
| 11 |
+
PVPN_PASSWORD= \
|
| 12 |
+
PVPN_PASSWORD_FILE= \
|
| 13 |
+
PVPN_TIER=2 \
|
| 14 |
+
PVPN_PROTOCOL=udp \
|
| 15 |
+
PVPN_CMD_ARGS="connect --fastest" \
|
| 16 |
+
PVPN_DEBUG= \
|
| 17 |
+
HOST_NETWORK= \
|
| 18 |
+
DNS_SERVERS_OVERRIDE=
|
| 19 |
+
|
| 20 |
+
COPY app /app
|
| 21 |
+
COPY pvpn-cli /root/.pvpn-cli
|
| 22 |
+
|
| 23 |
+
RUN apk --update add coreutils openvpn privoxy procps python3 runit git \
|
| 24 |
+
&& python3 -m ensurepip \
|
| 25 |
+
&& pip3 install git+https://github.com/Rafficer/linux-cli-community.git@v$PVPN_CLI_VER
|
| 26 |
+
|
| 27 |
+
CMD ["runsvdir", "/app"]
|
LICENSE.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
=====================
|
| 3 |
+
|
| 4 |
+
Copyright © 2020 Walter Leibbrandt
|
| 5 |
+
|
| 6 |
+
Permission is hereby granted, free of charge, to any person
|
| 7 |
+
obtaining a copy of this software and associated documentation
|
| 8 |
+
files (the “Software”), to deal in the Software without
|
| 9 |
+
restriction, including without limitation the rights to use,
|
| 10 |
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
copies of the Software, and to permit persons to whom the
|
| 12 |
+
Software is furnished to do so, subject to the following
|
| 13 |
+
conditions:
|
| 14 |
+
|
| 15 |
+
The above copyright notice and this permission notice shall be
|
| 16 |
+
included in all copies or substantial portions of the Software.
|
| 17 |
+
|
| 18 |
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
OTHER DEALINGS IN THE SOFTWARE.
|
app/proton-privoxy/config
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
confdir /app/proton-privoxy
|
| 2 |
+
logdir /var/log/privoxy
|
| 3 |
+
listen-address 0.0.0.0:8080
|
| 4 |
+
|
| 5 |
+
#debug 1 # show each GET/POST/CONNECT request
|
| 6 |
+
debug 4096 # Startup banner and warnings
|
app/proton-privoxy/run
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
|
| 3 |
+
# Create the necessary file structure for /dev/net/tun
|
| 4 |
+
# required to run on docker swarm, as there are no devices available
|
| 5 |
+
if ( [ ! -c /dev/net/tun ] ); then
|
| 6 |
+
if ( [ ! -d /dev/net ] ); then
|
| 7 |
+
mkdir -m 755 /dev/net
|
| 8 |
+
fi
|
| 9 |
+
mknod /dev/net/tun c 10 200
|
| 10 |
+
chmod 0755 /dev/net/tun
|
| 11 |
+
echo "Created /dev/net/tun."
|
| 12 |
+
fi
|
| 13 |
+
|
| 14 |
+
PVDIR=/root/.pvpn-cli
|
| 15 |
+
|
| 16 |
+
if [ -z "$PVPN_USERNAME" ] && [ -z "$PVPN_USERNAME_FILE" ]; then
|
| 17 |
+
echo "Error: Either env var \$PVPN_USERNAME or \$PVPN_USERNAME_FILE is required."
|
| 18 |
+
exit 1
|
| 19 |
+
fi
|
| 20 |
+
|
| 21 |
+
if [ -z "$PVPN_PASSWORD" ] && [ -z "$PVPN_PASSWORD_FILE" ]; then
|
| 22 |
+
echo "Error: Either env var \$PVPN_PASSWORD or \$PVPN_PASSWORD_FILE is required."
|
| 23 |
+
exit 1
|
| 24 |
+
fi
|
| 25 |
+
|
| 26 |
+
[ -f "$PVPN_USERNAME_FILE" ] && PVPN_USERNAME=$(cat "$PVPN_USERNAME_FILE")
|
| 27 |
+
[ -f "$PVPN_PASSWORD_FILE" ] && PVPN_PASSWORD=$(cat "$PVPN_PASSWORD_FILE")
|
| 28 |
+
|
| 29 |
+
# Initialize config
|
| 30 |
+
if [ ! -f $PVDIR/pvpn-cli.cfg ]; then
|
| 31 |
+
cp $PVDIR/pvpn-cli.cfg.clean $PVDIR/pvpn-cli.cfg
|
| 32 |
+
sed -i \
|
| 33 |
+
-e "s/PVPN_USERNAME/$PVPN_USERNAME/" \
|
| 34 |
+
-e "s/PVPN_PROTOCOL/$PVPN_PROTOCOL/" \
|
| 35 |
+
-e "s/PVPN_TIER/$PVPN_TIER/" \
|
| 36 |
+
$PVDIR/pvpn-cli.cfg
|
| 37 |
+
fi
|
| 38 |
+
|
| 39 |
+
echo "$PVPN_USERNAME" > $PVDIR/pvpnpass
|
| 40 |
+
echo "$PVPN_PASSWORD" >> $PVDIR/pvpnpass
|
| 41 |
+
chmod 0600 $PVDIR/pvpnpass
|
| 42 |
+
|
| 43 |
+
# Connect to ProtonVPN
|
| 44 |
+
protonvpn refresh
|
| 45 |
+
# shellcheck disable=SC2086
|
| 46 |
+
protonvpn $PVPN_CMD_ARGS
|
| 47 |
+
|
| 48 |
+
if ! ip link show proton0 > /dev/null; then
|
| 49 |
+
echo "Failed to bring up VPN :("
|
| 50 |
+
exit 1
|
| 51 |
+
fi
|
| 52 |
+
|
| 53 |
+
if [ -n "$DNS_SERVERS_OVERRIDE" ]; then
|
| 54 |
+
# This needs to run at this point, because ProtonVPN will have changed the
|
| 55 |
+
# DNS servers in /etc/resolv.conf.
|
| 56 |
+
cp /etc/resolv.conf /etc/resolv.conf.bak
|
| 57 |
+
echo "$DNS_SERVERS_OVERRIDE" | sed -e 's/^/nameserver /' -e 's/,/\nnameserver /' > /etc/resolv.conf
|
| 58 |
+
fi
|
| 59 |
+
|
| 60 |
+
# Setup route for host network
|
| 61 |
+
if [ -n "$HOST_NETWORK" ]; then
|
| 62 |
+
gw=$(ip route | awk '$1 == "default" { print $3 }')
|
| 63 |
+
ip route add "$HOST_NETWORK" via "$gw"
|
| 64 |
+
fi
|
| 65 |
+
|
| 66 |
+
# Start Privoxy
|
| 67 |
+
ln -s /etc/privoxy/templates /app/proton-privoxy/
|
| 68 |
+
exec privoxy --no-daemon
|
pvpn-cli/pvpn-cli.cfg.clean
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[USER]
|
| 2 |
+
username = PVPN_USERNAME
|
| 3 |
+
tier = PVPN_TIER
|
| 4 |
+
default_protocol = PVPN_PROTOCOL
|
| 5 |
+
initialized = 1
|
| 6 |
+
dns_leak_protection = 1
|
| 7 |
+
custom_dns = None
|
| 8 |
+
check_update_interval = 3
|
| 9 |
+
killswitch = 0
|
| 10 |
+
|
| 11 |
+
[metadata]
|
| 12 |
+
last_api_pull = 1587943789
|
| 13 |
+
last_update_check = 1587943788
|
| 14 |
+
|
test/docker_secrets_test/creds/password
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
password from file
|
test/docker_secrets_test/creds/username
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
username from file
|
test/docker_secrets_test/docker-compose.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: "3"
|
| 2 |
+
services:
|
| 3 |
+
proton-privoxy:
|
| 4 |
+
image: walt3rl/proton-privoxy:0.4.2-dev
|
| 5 |
+
container_name: proton-privoxy
|
| 6 |
+
environment:
|
| 7 |
+
- PVPN_USERNAME_FILE=/test/creds/username
|
| 8 |
+
- PVPN_PASSWORD_FILE=/test/creds/password
|
| 9 |
+
volumes:
|
| 10 |
+
- /etc/localtime:/etc/localtime:ro
|
| 11 |
+
- .:/test
|
| 12 |
+
ports:
|
| 13 |
+
- 8888:8080
|
| 14 |
+
restart: unless-stopped
|
| 15 |
+
devices:
|
| 16 |
+
- /dev/net/tun
|
| 17 |
+
cap_add:
|
| 18 |
+
- NET_ADMIN
|
test/docker_secrets_test/test.sh
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
|
| 3 |
+
#docker build -t walt3rl/proton-privoxy:0.4.2-dev ../..
|
| 4 |
+
docker-compose up -d
|
| 5 |
+
pvpnpass=$(docker-compose exec proton-privoxy cat /root/.pvpn-cli/pvpnpass)
|
| 6 |
+
docker-compose down
|
| 7 |
+
|
| 8 |
+
username=$(echo "$pvpnpass" | head -n 1 | sed 's/\s*$//g')
|
| 9 |
+
password=$(echo "$pvpnpass" | tail -n 1 | sed 's/\s*$//g')
|
| 10 |
+
errcode=0
|
| 11 |
+
|
| 12 |
+
if [ "$username" == "$(cat creds/username)" ]; then
|
| 13 |
+
echo "✅ Username is correct"
|
| 14 |
+
else
|
| 15 |
+
echo "❌ Username does NOT match creds/username: $username"
|
| 16 |
+
command -v xxd &> /dev/null && echo "$username" | xxd
|
| 17 |
+
errcode=1
|
| 18 |
+
fi
|
| 19 |
+
|
| 20 |
+
if [ "$password" == "$(cat creds/password)" ]; then
|
| 21 |
+
echo "✅ Password is correct"
|
| 22 |
+
else
|
| 23 |
+
echo "❌ Password does NOT match creds/password: $password"
|
| 24 |
+
command -v xxd &> /dev/null && echo "$password" | xxd
|
| 25 |
+
errcode=1
|
| 26 |
+
fi
|
| 27 |
+
|
| 28 |
+
exit $errcode
|