This commit is contained in:
SkyperTHC 2022-09-28 18:16:00 +01:00
parent e7dce75107
commit 71e65955f3
No known key found for this signature in database
GPG Key ID: A9BD386DF9113CD6
7 changed files with 11 additions and 228 deletions

@ -1,28 +0,0 @@
#!/usr/bin/with-contenv bash
PUID=${PUID:-911}
PGID=${PGID:-911}
groupmod -o -g "$PGID" abc
usermod -o -u "$PUID" abc
time32="$(date +%Y)"
if [[ "${time32}" == "1970" || "${time32}" == "1969" ]] && [ "$(uname -m)" == "armv7l" ]; then
echo '
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Your DockerHost is running an outdated version of libseccomp
To fix this, please visit https://docs.linuxserver.io/faq#libseccomp
Apps will not behave correctly without this
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'
sleep infinity
fi
chown abc:abc /app
chown abc:abc /config
chown abc:abc /defaults

@ -1,6 +0,0 @@
FROM bubuntux/nordlynx
COPY md5-orig.txt /
RUN md5sum -c /md5-orig.txt || { echo -e "\e[1;31m@@@@ NordLYNX got updated. Might need to adjust our scripts @@@@\e[0m"; exit 255; sleep 10; }
COPY run /etc/services.d/wireguard/
COPY 10-adduser /etc/cont-init.d/

@ -1,3 +0,0 @@
all: Dockerfile
docker build -t sf-nordvpn .

@ -1,2 +0,0 @@
aba39f2363b5e5ec89d9e91fdf11b2d6 /etc/services.d/wireguard/run
3227c3440128d3838be4a3d9ae8ed1c2 /etc/cont-init.d/10-adduser

@ -1,86 +0,0 @@
#!/usr/bin/with-contenv bash
if [[ -z ${PUBLIC_KEY} || -z ${END_POINT} ]]; then
echo "[$(date -Iseconds)] Finding the best server..."
recommendations=$(curl --retry 3 -LsS "https://api.nordvpn.com/v1/servers/recommendations?&filters\[servers_technologies\]\[identifier\]=wireguard_udp&limit=1&${QUERY}")
server=$(jq -r '.[0] | del(.services, .technologies)' <<< "${recommendations}")
if [[ -z ${server} ]]; then
echo "[$(date -Iseconds)] Unable to select a server ¯\_(⊙︿⊙)_/¯"
sleep 1
exit 250
fi
#echo "[$(date -Iseconds)] Using server: ${server}"
if [[ -z ${PUBLIC_KEY} ]]; then
PUBLIC_KEY=$(jq -r '.[0].technologies[] | select( .identifier == "wireguard_udp" ) | .metadata[] | select( .name == "public_key" ) | .value' <<< "${recommendations}")
fi
if [[ -z ${END_POINT} ]]; then
END_POINT=$(jq -r '.[0].hostname' <<< "${recommendations}"):51820
fi
fi
[[ -z "${PRIVATE_KEY}" ]] && [[ -f "${PRIVATE_KEY_FILE}" ]] && PRIVATE_KEY="$(head -n 1 "${PRIVATE_KEY_FILE}")"
( umask 077 && { cat >/etc/wireguard/wg0.conf <<-EOF
[Interface]
PrivateKey = ${PRIVATE_KEY}
ListenPort = ${LISTEN_PORT:-51820}
Address = ${ADDRESS:-10.5.0.2/32}
DNS = ${DNS}
Table = ${TABLE}
PreUp = ${PRE_UP}
PostUp = ${POST_UP}
PreDown = ${PRE_DOWN}
PostDown = ${POST_DOWN}
[Peer]
Endpoint = ${END_POINT}
PublicKey = ${PUBLIC_KEY}
AllowedIPs = ${ALLOWED_IPS:-0.0.0.0/0}
PersistentKeepalive = ${PERSISTENT_KEEP_ALIVE:-25}
EOF
} && sync )
echo "[$(date -Iseconds)] Connecting..."
wg-quick up wg0
n=0
while :; do
last=$(wg show wg0 latest-handshakes 2>/dev/null)
last="${last##*[[:space:]]}"
[[ $last -gt 0 ]] && break
((n++))
[[ $n -gt 20 ]] && { echo "Timeout..."; sleep 5; exit; }
sleep 0.5
done
echo "[$(date -Iseconds)] Connected! \(ᵔᵕᵔ)/"
if [[ -n ${RECONNECT} ]]; then
echo "[$(date -Iseconds)] Reconnecting in ${RECONNECT} seconds"
re=$RECONNECT
fi
n=0
while :; do
last=$(wg show wg0 latest-handshakes 2>/dev/null)
last="${last##*[[:space:]]}"
[ -z "$last" ] && break
hs_age=$(( $(date -u +%s) - "${last}" ))
if [ $hs_age -le 180 ]; then
[ $n -gt 0 ] && echo "[$(date -Iseconds)] Re-Handshake complete!"
n=0
else
((n++))
echo -e "[$(date -Iseconds)] Strike #${n}: No handshake for $hs_age sec..."
[ $n -gt 3 ] && break
fi
sleep 10
[[ -n $RECONNECT ]] && {
re=$((re - 10))
[ $re -le 0 ] && break
}
done
echo "[$(date -Iseconds)] RESTARTING..."
sleep 5

@ -1,94 +0,0 @@
#! /bin/bash
# [output filename] [post_up/post_down] [interface]
# From all files update the VPN status file
create_vpn_status()
{
local loc
local exit_ip
loc=()
exit_ip=()
for f in "${DSTDIR}"/status-*.log; do
[[ ! -f "${f}" ]] && break
# shellcheck disable=SC1090
source "${f}"
# loc+=("${SFVPN_LOCATION}[$SFVPN_EXIT_IP]")
loc+=("${SFVPN_LOCATION}")
exit_ip+=("$SFVPN_EXIT_IP")
done
# Delete vpn_status unless there is at least 1 VPN
if [[ ${#loc[@]} -eq 0 ]]; then
rm -f "/config/guest/vpn_status"
return
fi
echo -en "\
IS_VPN_CONNECTED=1\n\
VPN_LOCATION=\"${loc[*]}\"\n\
VPN_EXIT_IP=\"${exit_ip[*]}\"\n" >"/config/guest/vpn_status"
}
post_down()
{
[[ -f "${LOGFNAME}" ]] && rm -f "${LOGFNAME}"
create_vpn_status
}
post_up()
{
local t
local country
local geo
local city
local exit_ip
t="$(wg show "${DEV:-wg0}" endpoints)" && {
t="${t##*[[:space:]]}"
EP_IP="${t%:*}"
geo=$(curl https://ipinfo.io 2>/dev/null) && {
t=$(echo "$geo" | jq .country)
country="${t//[^A-Za-z]}"
t=$(echo "$geo" | jq .city)
city="${t//[^A-Za-z]/}"
t=$(echo "$geo" | jq .ip)
exit_ip="${t//[^0-9.]/}"
}
} # wg show
if [[ -z $EP_IP ]]; then
rm -f "${LOGFNAME}"
else
echo -en "\
SFVPN_EXEC_TS=$(date -u +%s)\n\
SFVPN_ENDPOINT_IP=\"${EP_IP}\"\n\
SFVPN_LOCATION=\"${city}/${country}\"\n\
SFVPN_EXIT_IP=\"${exit_ip}\"\n" >"${LOGFNAME}"
fi
create_vpn_status
}
[[ -z $2 ]] && exit 254
LOGFNAME="$1"
OP="$2"
DEV="${3:-wg0}"
DSTDIR="$(dirname "${LOGFNAME}")"
[[ ! -d "${DSTDIR}" ]] && { umask 077; mkdir -p "${DSTDIR}"; }
[[ "$OP" == "post_down" ]] && { post_down; exit; }
[[ "$OP" == "post_up" ]] && { post_up; exit; }
[[ "$OP" == "vpn_status" ]] && { create_vpn_status; exit; }
echo >&2 "Useage: [output filename] [post_up/post_down/vpn_status] [interface]"
exit 255

@ -47,30 +47,32 @@ post_up()
local geo
local city
local exit_ip
local ep_ip
t="$(wg show "${DEV:-wg0}" endpoints)" && {
t="${t##*[[:space:]]}"
EP_IP="${t%:*}"
ep_ip="${t%:*}"
geo=$(curl --retry 3 --max-time 15 https://ipinfo.io 2>/dev/null) && {
t=$(echo "$geo" | jq .country)
geo=$(curl -fsSL --retry 3 --max-time 15 https://ipinfo.io 2>/dev/null) && {
t=$(echo "$geo" | jq '.country | select(. != null)')
country="${t//[^A-Za-z]}"
t=$(echo "$geo" | jq .city)
t=$(echo "$geo" | jq '.city | select(. != null)')
city="${t//[^A-Za-z]/}"
t=$(echo "$geo" | jq .ip)
t=$(echo "$geo" | jq '.ip | select(. != null)')
exit_ip="${t//[^0-9.]/}"
}
[[ -z $exit_ip ]] && exit_ip=$(curl -fsSL --max-time 15 ifconfig.me 2>/dev/null)
} # wg show
if [[ -z $EP_IP ]]; then
if [[ -z $ep_ip ]]; then
rm -f "${LOGFNAME}"
else
echo -en "\
SFVPN_MY_IP=\"$(ipbydev eth0)\"\n\
SFVPN_EXEC_TS=$(date -u +%s)\n\
SFVPN_ENDPOINT_IP=\"${EP_IP}\"\n\
SFVPN_LOCATION=\"${city:-???}/${country:-???}\"\n\
SFVPN_EXIT_IP=\"${exit_ip:-0.0.0.0}\"\n" >"${LOGFNAME}"
SFVPN_ENDPOINT_IP=\"${ep_ip}\"\n\
SFVPN_LOCATION=\"${city:-Artemis}/${country:-Moon}\"\n\
SFVPN_EXIT_IP=\"${exit_ip:-333.1.2.3}\"\n" >"${LOGFNAME}"
fi
create_vpn_status