feat: SURFSHARK_CONFIGS_ENDPOINT

This commit is contained in:
Matteo Pietro Dazzi
2024-06-10 18:14:29 +02:00
parent fedf854bb3
commit 9512511f7a
3 changed files with 7 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ ENV SURFSHARK_USER=
ENV SURFSHARK_PASSWORD=
ENV SURFSHARK_COUNTRY=
ENV SURFSHARK_CITY=
ENV SURFSHARK_CONFIGS_ENDPOINT=https://my.surfshark.com/vpn/api/v1/server/configurations
ENV OPENVPN_OPTS=
ENV CONNECTION_TYPE=tcp
ENV LAN_NETWORK=

View File

@@ -27,6 +27,7 @@ The container is configurable using different environment variables:
|SURFSHARK_PASSWORD|Yes|Password provided by SurfShark|
|SURFSHARK_COUNTRY|No|The country, supported by SurfShark, in which you want to connect|
|SURFSHARK_CITY|No|The city of the country in which you want to connect|
|SURFSHARK_CONFIGS_ENDPOINT|No|The endpoint to be used to read Surfshark's configuration zip|
|OPENVPN_OPTS|No|Any additional options for OpenVPN|
|CONNECTION_TYPE|No|The connection type that you want to use: tcp, udp|
|LAN_NETWORK|No|Lan network used to access the web ui of attached containers. Can be comma seperated for multiple subnets Comment out or leave blank: example 192.168.0.0/24|

View File

@@ -1,20 +1,20 @@
#!/bin/sh
rm -rf ovpn_configs*
if [ -z "${OVPN_CONFIGS}" ]; then
wget -O ovpn_configs.zip https://my.surfshark.com/vpn/api/v1/server/configurations
OVPN_CONFIGS=ovpn_configs.zip
wget -O ${OVPN_CONFIGS} "${SURFSHARK_CONFIGS_ENDPOINT}"
fi
unzip "${OVPN_CONFIGS}" -d ovpn_configs
cd ovpn_configs
VPN_FILE=$(ls *"${SURFSHARK_COUNTRY}"-* | grep "${SURFSHARK_CITY}" | grep "${CONNECTION_TYPE}" | shuf | head -n 1)
echo Chose: ${VPN_FILE}
echo Chose: "${VPN_FILE}"
printf "${SURFSHARK_USER}\n${SURFSHARK_PASSWORD}" > vpn-auth.txt
if [ -n ${LAN_NETWORK} ]
if [ -n "${LAN_NETWORK}" ]
then
DEFAULT_GATEWAY=$(ip -4 route list 0/0 | cut -d ' ' -f 3)
splitSubnets=$(echo ${LAN_NETWORK} | tr "," "\n")
splitSubnets=$(echo "${LAN_NETWORK}" | tr "," "\n")
for subnet in $splitSubnets
do
@@ -46,7 +46,7 @@ if [ "${ENABLE_SOCKS_SERVER}" = "true" ]; then
OPTIONAL_SOCKS_SCRIPT="--up /vpn/sockd.sh"
fi
openvpn --config $VPN_FILE --auth-user-pass vpn-auth.txt --mute-replay-warnings $OPENVPN_OPTS --script-security 2 ${OPTIONAL_SOCKS_SCRIPT}
openvpn --config "$VPN_FILE" --auth-user-pass vpn-auth.txt --mute-replay-warnings "$OPENVPN_OPTS" --script-security 2 "${OPTIONAL_SOCKS_SCRIPT}"
if [ "${ENABLE_KILL_SWITCH}" = "true" ]; then
ufw reset