WPAC configuration in Tiger (and beyond)
WPAC configuration in Tiger (and beyond)
- Subject: WPAC configuration in Tiger (and beyond)
- From: Nathan Herring <email@hidden>
- Date: Fri, 05 Aug 2005 08:26:52 -0700
- Organization: Microsoft Corporation / Macintosh Business Unit
- Thread-topic: WPAC configuration in Tiger (and beyond)
[Originally sent to CarbonIT before I realized this list existed.]
Our IT department has a PAC file for use with our Windows browsers.
However, if in 10.4.2, I try and set my proxies "Using a PAC file",
nothing works outside of the firewall.
The CFDictionary information we use to connect shows a bunch of the
proxy server information correctly set in, but the XXXXEnable setting is
false, and we use that to determine whether or not to use that proxy
server.
Q: Is it a known issue that the proxy settings don't quite configure
correctly?
Q: How do you differentiate between internal servers (i.e. proxy
exceptions) and others?
AFAICT, unless you meta-interpret the Java script to extract the known
proxy exceptions, there's no good way to build the list -- you just have
to ask the script how to connect to server X for each server X.
What is the future direction of development here? Should we (as network
applications writers) be expected to use PAC files? Or will Apple
provide a functional intermediate layer above the PAC file? Or will the
proxy settings dictionary eventually "just work"?
TIA,
nh
----
Nathan Herring
MacBU SDE/Development
//Copyright (c) 1997-2004 Microsoft Corporation
BackupRoute="DIRECT";
UseDirectForLocal=true;
function MakeIPs(){
this[0]="10.0.0.0";
this[1]="255.255.0.0";
this[2]="10.1.0.0";
this[3]="255.255.192.0";
}
DirectIPs=new MakeIPs();
cDirectIPs=4;
function MakeCARPExceptions(){
this[0]="*internal.domain.com";
this[1]="*domain.com";
this[2]="*another.domain.com";
}
CARPExceptions=new MakeCARPExceptions();
cCARPExceptions=4;
function MakeNames(){
this[0]="127.0.0.1";
this[1]="internal2.com";
this[2]="*.internal3.com";
}
DirectNames=new MakeNames();
cDirectNames=3;
HttpPort="80";
cNodes=2;
function MakeProxies(){
this[0]=new Node("10.1.1.2",2360414784,0.967845);
this[1]=new Node("10.1.1.3",3429791868,0.967845);
}
Proxies = new MakeProxies();
function Node(name, hash, load){
this.name = name;
this.hash = hash;
this.load = load;
this.score = 0;
return this;
}
function FindProxyForURL(url, host){
var hash=0, urllower, ibest, bestscore, pl, list, i, j, port=HttpPort, carp=0, fIp=false, ip;
urllower = url.toLowerCase();
if((urllower.substring(0,5)=="rtsp:") ||
(urllower.substring(0,6)=="rtspt:") ||
(urllower.substring(0,6)=="rtspu:") ||
(urllower.substring(0,4)=="mms:") ||
(urllower.substring(0,5)=="mmst:") ||
(urllower.substring(0,5)=="mmsu:"))
return "DIRECT";
if(UseDirectForLocal){
if(isPlainHostName(host))
fIp = true;
for(i = 0; i < cDirectNames; i++)
if(shExpMatch(host, DirectNames[i])){
fIp = true;
break;}
if(cDirectIPs == 0){
if (fIp)
return "DIRECT";}
else{
ip = host;
if(fIp)
ip = dnsResolve(host);
var isIpAddr = /^(\d+.){3}\d+$/;
if( isIpAddr.test(ip) ){
for(i = 0; i < cDirectIPs; i += 2){
if(isInNet(ip, DirectIPs[i], DirectIPs[i+1]))
return "DIRECT";}}
else if(isPlainHostName(host))
return "DIRECT";
}}
if(cCARPExceptions > 0){
for(i = 0; i < cCARPExceptions; i++){
if(shExpMatch(host, CARPExceptions[i])) {
carp = 1;
if("*/*" == CARPExceptions[i])
carp = 2;
break;
}}}
if( carp != 2 ){
hash = HashString(host,hash);
}
if(carp != 0){
hash = HashString(myIpAddress(), hash);
}
for (i = 0; i<cNodes; i++)
Proxies[i].score = Proxies[i].load * Scramble(hash ^ Proxies[i].hash);
pl = new Array();
for (i = 0; i<cNodes; i++)
pl[i] = i;
list = "";
for(j = 0; j < cNodes; j++){
bestscore = -1;
for(i = 0; i < cNodes-j; i++){
if(Proxies[i].score > bestscore){
bestscore = Proxies[i].score;
ibest = i;
}}
list = list + "PROXY " + Proxies[pl[ibest]].name + ":" + port + "; ";
pl[ibest] = pl[cNodes-j-1];
}
list = list + BackupRoute;
return list;
}
var h_tbl = new Array(0,0x10D01913,0x21A03226,0x31702B35,0x4340644C,0x53907D5F,0x62E0566A,0x72304F79,0x8680C898,0x9650D18B,0xA720FABE,0xB7F0E3AD,0xC5C0ACD4,0xD510B5C7,0xE4609EF2,0xF4B087E1);
function HashString(str, h){
for(var i=0; i<str.length; i++){
var c = str.charAt(i);
c = CharToAscii(c.toLowerCase());
h = (h >>> 4) ^ h_tbl[(h ^ c) & 15];
h = (h >>> 4) ^ h_tbl[(h ^ (c>>>4)) & 15];
h = MakeInt(h);
}
return h;
}
function Scramble(h){
h += ((h & 0xffff) * 0x1965) + ((((h >> 16) & 0xffff) * 0x1965) << 16) + (((h & 0xffff) * 0x6253) << 16);
h = MakeInt(h);
h += (((h & 0x7ff) << 21) | ((h >> 11) & 0x1fffff));
return MakeInt(h);
}
var Chars =" !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~???????????????????????? ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ ";
function CharToAscii(c){
return Chars.indexOf(c) + 32;
}
function MakeInt(x){
x %= 4294967296;
if(x < 0)
x += 4294967296;
return x;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden