Skip to content

Commit 6fae18f

Browse files
committed
install ca-certificates explicitly
1 parent f24fb56 commit 6fae18f

File tree

7 files changed

+48
-4
lines changed

7 files changed

+48
-4
lines changed

.goreleaser.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dockers:
1717
- 'ghcr.io/tprasadtp/{{ .ProjectName }}:{{ .FullCommit }}-amd64'
1818

1919
build_flag_templates:
20+
- --build-arg=VERSION={{ .Version }}
2021
- --label=org.opencontainers.image.created={{.Date}}
2122
- --label=org.opencontainers.image.revision={{.FullCommit}}
2223
- --label=org.opencontainers.image.version={{.Version}}
@@ -65,6 +66,7 @@ dockers:
6566
- 'ghcr.io/tprasadtp/{{ .ProjectName }}:{{ .FullCommit }}-arm64'
6667

6768
build_flag_templates:
69+
- --build-arg=VERSION={{ .Version }}
6870
- --label=org.opencontainers.image.created={{.Date}}
6971
- --label=org.opencontainers.image.revision={{.FullCommit}}
7072
- --label=org.opencontainers.image.version={{.Version}}
@@ -105,6 +107,7 @@ dockers:
105107
- 'ghcr.io/tprasadtp/{{ .ProjectName }}:{{ .FullCommit }}-arm'
106108

107109
build_flag_templates:
110+
- --build-arg=VERSION={{ .Version }}
108111
- --label=org.opencontainers.image.created={{.Date}}
109112
- --label=org.opencontainers.image.revision={{.FullCommit}}
110113
- --label=org.opencontainers.image.version={{.Version}}

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
FROM ubuntu:focal-20210921 as upstream
44
FROM upstream as base
55

6+
ARG VERSION="v0.0.0"
7+
ENV VERSION="${VERSION}"
8+
69
# Overlay defaults
710
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
811
S6_CMD_WAIT_FOR_SERVICES=1 \
@@ -34,9 +37,11 @@ RUN --mount=type=tmpfs,target=/downloads/ \
3437
curl \
3538
procps \
3639
iptables \
40+
ca-certificates \
3741
openvpn \
3842
dialog \
3943
python3-pip \
44+
&& update-ca-certificates \
4045
&& ARCH="$(uname -m)" \
4146
&& export ARCH \
4247
&& if [ "$ARCH" = "x86_64" ]; then \

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ UPSTREAM_URL := https://github.com/ProtonVPN/linux-cli
2727
include $(REPO_ROOT)/makefiles/help.mk
2828
include $(REPO_ROOT)/makefiles/docker.mk
2929

30+
# Inject Version into image
31+
DOCKER_EXTRA_ARGS := --build-arg VERSION=$(VERSION_ID)
3032

3133
.PHONY: shellcheck
3234
shellcheck: ## Runs shellcheck

docs/healthcheck.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,33 @@
22

33
- There is a `healthcheck.py` script available under /usr/local/bin. It will use `PROTONVPN_IPCHECK_ENDPOINT` (`https://ip.prasadt.workers.dev/` by default) to verify the IP address matches with one of the logical servers. By default service will keep checking every `PROTONVPN_CHECK_INTERVAL` _(default = 90)_ seconds using the same api endpoint.
44

5-
- `https://ip.prasadt.workers.dev/` Service runs as a cloudflare worker and is fast, as it sits at their edge network. It is very simple, It returns your public IP and nothing else. You can use any of the following services by setting the variable (or host your own) as they too return your public IP address.
5+
- `https://ip.prasadt.workers.dev/` Service runs as a cloudflare worker and is fast, as it sits at their edge network. It is very simple, It returns your public IP and nothing else.
6+
7+
- You can use any of the following services by setting the variable (or host your own) as they too return your public IP address. These can also be used if default endpoint is rate limited or unavailable.
68
* https://ip.prasadt.workers.dev/
7-
* https://checkip.amazonaws.com/
89
* https://icanhazip.com/
10+
* https://checkip.amazonaws.com/
911
* https://api.ipify.org/
1012

1113
- Version 4.x and below use `https://ipinfo.io` as healthcheck endpoint and check for connected country. This endpoint be changed. If you are hitting rate limits, you should upgrade to v5.0.0+ or reduce check interval via `PROTONVPN_CHECK_INTERVAL` to 180 seconds or more.
14+
15+
## Hosting your own ip worker
16+
17+
- Signup for [Cloudflare workers](https://dash.cloudflare.com/sign-up/workers)
18+
- Create a new worker
19+
- Code for worker is extremely dumb and simple its less than 10 lines of code. You can simply copy paste the following snipet, or look under worker folder.
20+
```js
21+
addEventListener("fetch", (event) => {
22+
event.respondWith(
23+
handleRequest(event.request).catch(
24+
(err) => new Response(err.stack, { status: 500 })
25+
)
26+
);
27+
});
28+
29+
async function handleRequest(request) {
30+
return new Response(request.headers.get("CF-Connecting-IP"))
31+
}
32+
```
33+
-. Hit save and deploy. Please note that the preview is not available in the cloudflare console,
34+
as the script uses CF-* headers which are not availablein preview.

makefiles/help.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ else
8282
GIT_BRANCH :=
8383
endif
8484

85+
# Version ID
86+
# This can return only commit id, if in a shallow clone repo,
87+
# otherwise can return something like 5.0.1-3-gf24fb56-dirty
88+
VERSION_ID := $(shell git -c log.showSignature=false describe --tags --always --broken --dirty 2> /dev/null )
89+
export VERSION_ID
90+
8591
# Base Buidler/CI Info collector
8692
# -------------------------------------
8793

@@ -146,6 +152,7 @@ show-vars-base: ## Show Base variables
146152
@echo "GIT_COMMIT_TIMESTAMP : $(GIT_COMMIT_TIMESTAMP)"
147153
@echo "GIT_DEFAULT_BRANCH : $(GIT_DEFAULT_BRANCH)"
148154
@echo "GIT_TREE_STATE : $(GIT_TREE_STATE)"
155+
@echo "VERSION_ID : $(VERSION_ID)"
149156

150157
@echo "----------- BASE BUILD VARIABLES --------------"
151158
@echo "BUILD_HOST : $(BUILD_HOST)"

root/etc/services.d/protonvpn/run

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ function api_check() {
8282
thrshold_f=0
8383
else
8484
log_error "Healthcheck #$((++thrshold_f)) Failed!"
85-
log_error "Connected to #${COUNTRY} instead of #${PROTONVPN_COUNTRY}"
8685
if [[ $thrshold_f -gt "${PROTONVPN_FAIL_THRESHOLD}" ]]; then
8786
log_error "Reconnecting! (${PROTONVPN_FAIL_THRESHOLD})"
8887
reconnect_vpn

root/usr/bin/healthcheck

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,17 @@ logging.debug(f"Allowed IPs: {connected_server_ips}")
4949

5050
ip_endpoint = os.getenv("PROTONVPN_IPCHECK_ENDPOINT",
5151
"https://ip.prasadt.workers.dev/")
52+
hciv = os.getenv("PROTONVPN_CHECK_INTERVAL", "0")
53+
version = os.getenv("VERSION", "v0.0.0")
54+
user_agent = f"protonvpn-docker/{version}/{hciv}"
55+
5256
logging.debug(f"Fetch Public IP from {ip_endpoint}")
57+
logging.debug(f"Using User-Agent - {user_agent}")
5358

5459
ip_resp_request = urllib.request.Request(
5560
ip_endpoint,
5661
data=None,
57-
headers={"User-Agent": "protonvpn-cli-docker"},
62+
headers={"User-Agent": user_agent},
5863
)
5964
with urllib.request.urlopen(ip_resp_request) as ip_response:
6065
current_ip = str(ip_response.read(), "utf-8")

0 commit comments

Comments
 (0)