Created
July 24, 2020 08:42
-
-
Save mort3za/7ce404b78da06ccf8f1ea526101f0b60 to your computer and use it in GitHub Desktop.
Fix surfshark openvpn configs for Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start tor service and test if `tor-resolve github.com` returns an IP | |
# create a file 'login' beside of config files with content: | |
# OPENVPN_USERNAME | |
# OPENVPN_PASSWORD | |
# download https://github.com/alfredopalhares/openvpn-update-resolv-conf project to somewhere and update bottom path | |
openvpnUpdateResolvePath="/path/to/openvpn-update-resolv-conf" | |
for f in /path/to/Surfshark_Config/*.ovpn | |
do | |
# convert subdomains to IP | |
domain=$(awk 'FNR == 4 {print $2}' $f) | |
echo $domain | |
if [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "no need to process" | |
else | |
echo "processing" | |
domainIP=$(tor-resolve $domain) | |
echo $domainIP | |
sed -i "s/$domain/$domainIP/" $f | |
fi | |
# use login file to prevent asking username/password on connect | |
sed -i "s/auth-user-pass/auth-user-pass login/" $f | |
# insert three line of config at line 21 | |
sed -i "21iscript-security 2\nup $openvpnUpdateResolvePath/update-resolv-conf.sh\ndown $openvpnUpdateResolvePath/update-resolv-conf.sh\n" $f | |
echo "Finished processing of: $f" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment