Keamas 10 Geschrieben 26. September 2014 Melden Geschrieben 26. September 2014 (bearbeitet) Hallo, ich möchte gerade ein Proxy Pac File programmieren und habe dabei folgendes Problem: Das Script sollte den richtigen Proxy wählen abhängig aus welchem Netz der Host kommt. Allerdings gibt es in dem Script ein paar ausnahmen wie microsoft.com. Allerdings scheint es als würde das Script diese Zeilen nicht auslesen. Laut meinem Testtol kommt er nie da an. Kann mir bitte jemand helfen und sagen wo der Fehler hier ist oder habe ich einen Denkfehler drin oder funktioniert das was ich machen will ganz anders? function FindProxyForURL(url, host) { { /* The following is a load distribution and failover for the different locations. */ /* EXAMPLE: if (isInNet(myIpAddress(), "10.1.0.0", "255.255.0.0")) { return "PROXY wcg1.example.com:8080; " + "PROXY wcg2.example.com:8080"; } */ //USA if (isInNet(myIpAddress(), "10.1.0.0", "255.255.255.0") || //Clients isInNet(myIpAddress(), "10.2.0.0", "255.255.255.0")) //Servers { return "PROXY proxy-us.example.com:8080;" } //Europe if (isInNet(myIpAddress(), "10.20.0.0", "255.255.255.0") || //Clients isInNet(myIpAddress(), "10.21.0.0", "255.255.255.0") || //Servers isInNet(myIpAddress(), "10.22.0.0", "255.255.255.0") || //Developer isInNet(myIpAddress(), "10.23.0.0", "255.255.255.0")) //Client VPN { return "PROXY proxy_eu.example.com:8080;" } /* If no networks matches use the proxy servers. */ else return "PROXY proxy.example.com:8080"; /* Normalize the URL for pattern matching url = url.toLowerCase(); host = host.toLowerCase(); { /* Don't proxy local hostnames */ /* If the requested website is hosted within the internal network, send direct.*/ if (isPlainHostName(host)) { return 'DIRECT'; } /* Don't proxy local domains */ if (dnsDomainIs(host, ".example1.com") || (host == "example1.com") || dnsDomainIs(host, ".example2.com") || (host == "example2.com") || dnsDomainIs(host, ".example3.com") || (host == "example3.com")) { return 'DIRECT'; } /* Don't proxy Windows Update */ if ((host == "download.microsoft.com") || (host == "ntservicepack.microsoft.com") || (host == "cdm.microsoft.com") || (host == "wustat.windows.com") || (host == "windowsupdate.microsoft.com") || (dnsDomainIs(host, ".windowsupdate.microsoft.com")) || (host == "update.microsoft.com") || (dnsDomainIs(host, ".update.microsoft.com")) || (dnsDomainIs(host, ".windowsupdate.com"))) { return 'DIRECT'; } if (isResolvable(host)) { var hostIP = dnsResolve(host); /* Don't proxy non-routable addresses (RFC 3330) */ if (isInNet(hostIP, '0.0.0.0', '255.0.0.0') || isInNet(hostIP, '10.0.0.0', '255.0.0.0') || isInNet(hostIP, '127.0.0.0', '255.0.0.0') || isInNet(hostIP, '169.254.0.0', '255.255.0.0') || isInNet(hostIP, '172.16.0.0', '255.240.0.0') || isInNet(hostIP, '192.0.2.0', '255.255.255.0') || isInNet(hostIP, '192.88.99.0', '255.255.255.0') || isInNet(hostIP, '192.168.0.0', '255.255.0.0') || isInNet(hostIP, '198.18.0.0', '255.254.0.0') || isInNet(hostIP, '224.0.0.0', '240.0.0.0') || isInNet(hostIP, '240.0.0.0', '240.0.0.0')) { return 'DIRECT'; } /* Don't proxy local addresses.*/ if (false) { return 'DIRECT'; } } if (url.substring(0, 5) == 'http:' || url.substring(0, 6) == 'https:' || url.substring(0, 4) == 'ftp:') { return 'PROXY proxy.example.com:8080'; } return 'DIRECT'; } } bearbeitet 26. September 2014 von Keamas
Doso 77 Geschrieben 26. September 2014 Melden Geschrieben 26. September 2014 Wir haben ein recht großes PAC Script im Einsatz, das ist dann mit if gefolgt von else if am ende else gebaut. Evtl. ist das so notwendig.
daabm 1.435 Geschrieben 27. September 2014 Melden Geschrieben 27. September 2014 Spätestens hier else return "PROXY proxy.example.com:8080"; ist Ende in Deinem PAC - Du hast hier IF/ELSE, wie sollen die Zeilen danach noch erreicht werden?
Empfohlene Beiträge
Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren
Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können
Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!
Neues Benutzerkonto erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde dich hier an.
Jetzt anmelden