Jump to content

Javascript Proxy Pac file funktioniert nicht wie gewollt


Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Empfohlene Beiträge

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 von Keamas
Link zu diesem Kommentar
Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Schreibe einen Kommentar

Du kannst jetzt antworten und Dich später registrieren. Falls Du bereits ein Mitglied bist, logge Dich jetzt ein.

Gast
Auf dieses Thema antworten...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Editor-Fenster leeren

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...