this is a quick and dirty little hack to let mozilla use the dhcpinform program. That program will let you use the dhcp aspect of the wpad protocol for automatically identifying where the proxy pac file may lie on the network. DHCP is one of two widely used methods for implementing wpad (the other is via DNS) and it is by far the more sensible one. When MSIE says "automatically detect settings" it means use wpad. dhcpinform is implemented as a different program because it requires special permissions to bind to a low number port to implement the dhcp protocol. to use it specify your pac location as either dhcp:// (if dhcpinform is located in your MOZILLA_FIVE_HOME directory), or for something like /usr/local/bin/dhcpinform use dhcp:///usr/local/bin/dhcpinform This is a perfectly safe default for shipping - if now wpad option is found from the dhcp server, no proxy is used. The dhcpinform program lives at http://www.ducksong.com:81/dhcpinform Index: nsProtocolProxyService.cpp =================================================================== RCS file: /cvsroot/mozilla/netwerk/base/src/nsProtocolProxyService.cpp,v retrieving revision 1.36 diff -c -u -b -r1.36 nsProtocolProxyService.cpp --- nsProtocolProxyService.cpp 16 Apr 2002 07:41:47 -0000 1.36 +++ nsProtocolProxyService.cpp 19 Apr 2002 18:45:33 -0000 @@ -44,6 +44,8 @@ #include "nsIIOService.h" #include "nsIEventQueueService.h" #include "nsIProtocolHandler.h" +#include "prenv.h" +#include "nsIFileSpec.h" static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -271,6 +273,63 @@ NS_ERROR("HandlePACLoadEvent owner is null"); return; } + +#if defined(XP_UNIX) + if (!PL_strncasecmp("dhcp://", pps->mPACURL.get(),7)) // we're going to use dhcp to get pac + { + nsXPIDLCString wpn; + FILE *p; + int sb; + char tb[16]; + nsCOMPtr fileSpec; + nsresult rv; + + + wpn.Adopt ( PL_strdup(pps->mPACURL)); + wpn.Cut (0,7); + + + if (!wpn.Length()) + { + wpn.Adopt (PR_GetEnv ("MOZILLA_FIVE_HOME")); + + if (wpn.Length()) + wpn += "/"; + else + wpn += "./"; + + wpn += "dhcpinform"; + } + + rv = NS_NewFileSpec (getter_AddRefs(fileSpec)); + + if (!NS_FAILED(rv)) + { + // fprintf (stderr,"cmd is %s\n",wpn.get()); + + fileSpec->SetUnixStyleFilePath (wpn.get()); + PRBool exists = false; + fileSpec->Exists(&exists); + + if (exists) + { + wpn.Append (" wpad"); + p = popen (wpn.get(),"r"); + + if (p) + { + pps->mPACURL.Truncate(); + while ((sb=fread(tb,1,16,p)) > 0) + pps->mPACURL.Append (tb,sb); + + + pclose (p); + } + } + } + + } +#endif // create pac js component pps->mPAC = do_CreateInstance(NS_PROXY_AUTO_CONFIG_CONTRACTID, &rv);