src/net.cpp
bool GetMyExternalIP(CNetAddr& ipRet)
{
    CService addrConnect;
    const char* pszGet;
    const char* pszKeyword;

    for (int nLookup = 0; nLookup <= 1; nLookup++)
    for (int nHost = 1; nHost <= 2; nHost++)
    {
        // We should be phasing out our use of sites like these.  If we need
        // replacements, we should ask for volunteers to put this simple
        // php file on their web server that prints the client IP:
        //  <?php echo $_SERVER["REMOTE_ADDR"]; ?>
        if (nHost == 1)
        {
            addrConnect = CService("91.198.22.70",80); // checkip.dyndns.org

            if (nLookup == 1)
            {
                CService addrIP("checkip.dyndns.org", 80, true);
                if (addrIP.IsValid())
                    addrConnect = addrIP;
            }

            pszGet = "GET / HTTP/1.1\r\n"
                     "Host: checkip.dyndns.org\r\n"
                     "User-Agent: Triangles\r\n"
                     "Connection: close\r\n"
                     "\r\n";

            pszKeyword = "Address:";
        }
        else if (nHost == 2)
        {
            addrConnect = CService("74.208.43.192", 80); // www.showmyip.com

            if (nLookup == 1)
            {
                CService addrIP("www.showmyip.com", 80, true);
                if (addrIP.IsValid())
                    addrConnect = addrIP;
            }

            pszGet = "GET /simple/ HTTP/1.1\r\n"
                     "Host: www.showmyip.com\r\n"
                     "User-Agent: Triangles\r\n"
                     "Connection: close\r\n"
                     "\r\n";

            pszKeyword = NULL; // Returns just IP address
        }

        if (GetMyExternalIP2(addrConnect, pszGet, pszKeyword, ipRet))
            return true;
    }

    return false;
}
// We now get our external IP from the IRC server first and only use this as a backup
We now get our external IP from the IRC server first and only use this as a backup
We now get our external IP from the IRC server first and only use this as a backup
bool GetMyExternalIP(CNetAddr& ipRet)
{
    CService addrConnect;
    const char* pszGet;
    const char* pszKeyword;
    for (int nLookup = 0; nLookup <= 1; nLookup++)
    for (int nHost = 1; nHost <= 2; nHost++)
    {
        if (nHost == 1)
        {
            addrConnect = CService("91.198.22.70",80); 
            if (nLookup == 1)
            {
                CService addrIP("checkip.dyndns.org", 80, true);
                if (addrIP.IsValid())
                    addrConnect = addrIP;
            }
            pszGet = "GET / HTTP/1.1\r\n"
                     "Host: checkip.dyndns.org\r\n"
                     "User-Agent: Triangles\r\n"
                     "Connection: close\r\n"
                     "\r\n";
            pszKeyword = "Address:";
        }
        else if (nHost == 2)
        {
            addrConnect = CService("74.208.43.192", 80); 
            if (nLookup == 1)
            {
                CService addrIP("www.showmyip.com", 80, true);
                if (addrIP.IsValid())
                    addrConnect = addrIP;
            }
            pszGet = "GET /simple/ HTTP/1.1\r\n"
                     "Host: www.showmyip.com\r\n"
                     "User-Agent: Triangles\r\n"
                     "Connection: close\r\n"
                     "\r\n";
            pszKeyword = NULL; 
        }
        if (GetMyExternalIP2(addrConnect, pszGet, pszKeyword, ipRet))
            return true;
    }
    return false;
}
bool GetMyExternalIP ( CNetAddr & ipRet ) { CService addrConnect ; const char * pszGet ; const char * pszKeyword ; for ( int nLookup = 0 ; nLookup <= 1 ; nLookup ++ ) for ( int nHost = 1 ; nHost <= 2 ; nHost ++ ) { if ( nHost == 1 ) { addrConnect = CService ( " " , 80 ) ; if ( nLookup == 1 ) { CService addrIP ( " " , 80 , true ) ; if ( addrIP . IsValid ( ) ) addrConnect = addrIP ; } pszGet = " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " ; pszKeyword = " " ; } else if ( nHost == 2 ) { addrConnect = CService ( " " , 80 ) ; if ( nLookup == 1 ) { CService addrIP ( " " , 80 , true ) ; if ( addrIP . IsValid ( ) ) addrConnect = addrIP ; } pszGet = " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " ; pszKeyword = NULL ; } if ( GetMyExternalIP2 ( addrConnect , pszGet , pszKeyword , ipRet ) ) return true ; } return false ; }
We now get our external IP from the IRC server first and only use this as a backup
We now get our external IP from the IRC server first and only use this as a backup
// We should be phasing out our use of sites like these.  If we need // replacements, we should ask for volunteers to put this simple // php file on their web server that prints the client IP: //  <?php echo $_SERVER["REMOTE_ADDR"]; ?> // checkip.dyndns.org // www.showmyip.com // Returns just IP address