I'm tryig to make a proxy pac file for my Squid. I suppose to change redirection if the user is in my network or if he is at home for example, and I try to make it whith the myAdress() function.
I have test this PAC, whith most of function that we can use in a PAC : http://findproxyforurl.com/debug-pac-file/ .
function FindProxyForURL(url, host) {
debugPAC ="PAC Debug Information\n";
debugPAC +="-----------------------------------\n";
debugPAC +="Machine IP: " + myIpAddress() + "\n"; <-----|
debugPAC +="Hostname: " + host + "\n";
if (isResolvable(host)) {resolvableHost = "True"} else {resolvableHost = "False"};
debugPAC +="Host Resolvable: " + resolvableHost + "\n";
debugPAC +="Hostname IP: " + dnsResolve(host) + "\n";
if (isPlainHostName(host)) {plainHost = "True"} else {plainHost = "False"};
debugPAC +="Plain Hostname: " + plainHost + "\n";
debugPAC +="Domain Levels: " + dnsDomainLevels(host) + "\n";
debugPAC +="URL: " + url + "\n";
// Protocol can only be determined by reading the entire URL.
if (url.substring(0,5)=="http:") {protocol="HTTP";} else
if (url.substring(0,6)=="https:") {protocol="HTTPS";} else
if (url.substring(0,4)=="ftp:") {protocol="FTP";}
else {protocol="Unknown";}
debugPAC +="Protocol: " + protocol + "\n";
// Reduce volume of alerts to a useable level, e.g. only alert on static text pages.
if (!shExpMatch(url,"*.(js|xml|ico|gif|png|jpg|jpeg|css|swf)*")) {alert(debugPAC);}
return "DIRECT";
}
But on the output, I have ipv6 address ?!
PAC-alert: PAC Debug Information
-----------------------------------
Machine IP: fe80::xxx:xxx:xxxx:xxxx <-----|
Hostname: download.cdn.mozilla.net
Host Resolvable: True
Hostname IP: 93.184.221.133
Plain Hostname: False
Domain Levels: 3
URL: http://download.cdn.mozilla.net/pub/firefox/releases/37.0.2/update/win32/fr/firefox-37.0.2.complete.mar
Protocol: HTTP
Is that normal ? Or there another method for getting ipv4 address of the user ? If so, I can not make test like :
if ( isInNet(myAddress, "10.0.0.0","255.0.0.0") ) ?
Thanks for your help