Last active
February 18, 2020 05:14
-
-
Save AlLongley/ef9f13833f3901a4161f65c0370c61b9 to your computer and use it in GitHub Desktop.
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
# Sets tcp_outgoing_address in squid.conf to point to IP of ppp0 | |
# Ensure the line tcp_outgoing_address already exists in squid.conf! | |
# Crontab set up to reconnect Mac OS VPN like so: | |
# */1 * * * * networksetup -connectpppoeservice "VPN"; ~/SCRIPTS/SetProxyIP.sh; | |
export VPNIP='' | |
CONFDIR=/usr/local/etc/squid.conf | |
for i in 1 2 3 4 5; do | |
# Parse ifconfig for the IP of ppp9 | |
export VPNIP="$(ifconfig ppp0 | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')" | |
echo "GETTING VPN IP" $VPNIP | |
# If we got something that looks like an IP... | |
if [[ $VPNIP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; | |
then | |
# Rewrite Squid conf with that address | |
sed -i .bak 's/.*tcp_outgoing_address.*.*/tcp_outgoing_address '$VPNIP'/' $CONFDIR | |
#kill -9 `cat /tmp/squid.pid` || : | |
#killall squid | |
#/usr/local/squid/sbin/squid -f ~/Library/Preferences/squid.conf | |
# Then hot reload | |
/usr/local/opt/squid/sbin/squid -k reconfigure | |
break | |
fi | |
sleep 1 | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment