Go implementation of FindProxyForURL
C:\work> findproxy.exe
findproxy.exe proxy.pac url...
// proxy.pac
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".foo.co.jp")) {
return "PROXY proxy1:8000"
}
if (shExpMatch(host, "*.com")) {
return "PROXY proxy2:8080";
}
if (isInNet(host, "192.168.1.0", "255.255.255.0")) {
return "PROXY 192.168.3.2:8000";
}
return "DIRECT";
}
C:\work> findproxy.exe proxy.pac https://hogehoge/hoge https://hoge.com/hoge https://192.168.1.45/ https://www.foo.co.jp/
https://hogehoge/hoge => DIRECT
https://hoge.com/hoge => PROXY proxy2:8080
https://192.168.1.45/ => PROXY 192.168.3.2:8000
https://www.foo.co.jp/ => PROXY proxy1:8000