Last active
October 15, 2020 20:30
-
-
Save mlavergn/3892ef0f5d22a2a9a4b96df775aa6429 to your computer and use it in GitHub Desktop.
Proxy PAC
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
/* | |
curl -o /www/proxy.pac -L https://gist.github.com/mlavergn/5a03b23e8a92115ad6b206cbcf865fa9/raw/ | |
networksetup -listallnetworkservices | |
networksetup -getautoproxyurl Wi-Fi | |
scp proxy.pac root@192.168.2.1:/www | |
networksetup -setautoproxystate Wi-Fi off | |
networksetup -setautoproxystate Wi-Fi on | |
*/ | |
function FindProxyForURL(url, host) { | |
var clientIp = myIpAddress(); | |
var clientIpValid = (clientIp.length > 0 && clientIp != '127.0.0.1'); | |
var proxyPort = 8888; | |
var proxyIp = dnsResolve('CALA-AM01023443.lan'); | |
var proxyIpValid = (proxyIp.length > 0 && proxyIp != '127.0.0.1'); | |
if (!proxyIpValid) { | |
if (clientIpValid) { | |
var seg = clientIp.split('.'); | |
seg[3] = '46'; | |
proxyIp = seg.join('.') | |
} else { | |
proxyIp = '10.148.12.46'; | |
} | |
} | |
// proxy | |
if (dnsDomainIs(host, '.disney.com') || dnsDomainIs(host, '.disney.network') || dnsDomainIs(host, '.go.com') || dnsDomainIs(host, '.starwave.com')) { | |
return `PROXY ${proxyIp}:${proxyPort}; DIRECT`; | |
} | |
// default | |
return 'DIRECT'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment