Last active
March 15, 2019 13:39
-
-
Save rostegg/8d8cc8bd7d0b7fcc8f4077574393c079 to your computer and use it in GitHub Desktop.
Setup random proxy for gnome desktop (https://free-proxy-list.net/)
This file contains hidden or 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
#!/bin/bash | |
# for removing proxy use: gsettings set org.gnome.system.proxy mode 'none' | |
TEMP_PROXY_DATA=$(wget https://free-proxy-list.net/ -q -O - | tr -d '[:space:]') | |
TABLE=$(echo "$TEMP_PROXY_DATA" | grep -o -P '(?<=\<tr\>).*?(?=\<\/tr\>)') | |
strADRRESES=$(echo "$TABLE" | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') | |
arrADDRESES=(${strADRRESES// / }) | |
strPORTS=$(echo "$TABLE" |grep -o -P '(?<=\<td\>)(\d+)(?=\<\/td\>)') | |
arrPORTS=(${strPORTS// / }) | |
strHTTPS=$(echo "$TABLE" |grep -o -P "(?<=\<tdclass\='hx'\>)\w{2,3}(?=\<\/td\>)") | |
arrHTTPS=(${strHTTPS// / }) | |
# random number from list | |
rndSERVER=$(((RANDOM%${#arrPORTS[@]})-1)) | |
: ' | |
If you want connect only to proxy with HTTPS support, uncomment this | |
while [ ${arrHTTPS[$rndSERVER]} != "yes" ] | |
do | |
rndSERVER=$(((RANDOM%${#arrPORTS[@]})-1)) | |
done | |
' | |
gsettings set org.gnome.system.proxy mode 'manual' | |
gsettings set org.gnome.system.proxy.http host ${arrADDRESES[$rndSERVER]} | |
gsettings set org.gnome.system.proxy.http port ${arrPORTS[$rndSERVER]} | |
if [ ${arrHTTPS[$rndSERVER]} = "yes" ] | |
then | |
gsettings set org.gnome.system.proxy.https host ${arrADDRESES[$rndSERVER]} | |
gsettings set org.gnome.system.proxy.https port ${arrPORTS[$rndSERVER]} | |
fi | |
gsettings set org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8', '10.0.0.0/8', '192.168.0.0/16', '172.16.0.0/12']" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment