--- a/trb 9ea74927110848cf3d3ae4b3f4a60e8f30dfcc4193e382bfe922cb6239380d8e3e872ce59ee33e433ced4ad92e9a5baf7b8cace28d4dac9e61520679ea50a5f8 +++ b/trb 91e7fa825ff1d0b52d3261ebe2715badb632a58b81da9548725c060143fe56dcc8279ea25599490e1694915c43a82eb3a841170e8c8fe21a92178b1574546989 @@ -15306,7 +15306,7 @@ } ############################################################################## -47311 @ ./bitcoin/src/net.cpp +42984 @ ./bitcoin/src/net.cpp ############################################################################## // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers @@ -15573,114 +15573,6 @@ return fRet; } -bool GetMyExternalIP2(const CAddress& addrConnect, const char* pszGet, const char* pszKeyword, unsigned int& ipRet) -{ - SOCKET hSocket; - if (!ConnectSocket(addrConnect, hSocket)) - return error("GetMyExternalIP() : connection to %s failed", addrConnect.ToString().c_str()); - - send(hSocket, pszGet, strlen(pszGet), MSG_NOSIGNAL); - - string strLine; - while (RecvLine(hSocket, strLine)) - { - if (strLine.empty()) // HTTP response is separated from headers by blank line - { - loop - { - if (!RecvLine(hSocket, strLine)) - { - closesocket(hSocket); - return false; - } - if (pszKeyword == NULL) - break; - if (strLine.find(pszKeyword) != -1) - { - strLine = strLine.substr(strLine.find(pszKeyword) + strlen(pszKeyword)); - break; - } - } - closesocket(hSocket); - if (strLine.find("<") != -1) - strLine = strLine.substr(0, strLine.find("<")); - strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r")); - while (strLine.size() > 0 && isspace(strLine[strLine.size()-1])) - strLine.resize(strLine.size()-1); - CAddress addr(strLine,0,true); - printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str()); - if (addr.ip == 0 || addr.ip == INADDR_NONE || !addr.IsRoutable()) - return false; - ipRet = addr.ip; - return true; - } - } - closesocket(hSocket); - return error("GetMyExternalIP() : connection closed"); -} - -// We now get our external IP from the IRC server first and only use this as a backup -bool GetMyExternalIP(unsigned int& ipRet) -{ - CAddress addrConnect; - const char* pszGet; - const char* pszKeyword; - - if (fUseProxy) - return false; - - 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 webserver that prints the client IP: - // - if (nHost == 1) - { - addrConnect = CAddress("91.198.22.70",80); // checkip.dyndns.org - - if (nLookup == 1) - { - CAddress 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: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n" - "Connection: close\r\n" - "\r\n"; - - pszKeyword = "Address:"; - } - else if (nHost == 2) - { - addrConnect = CAddress("74.208.43.192", 80); // www.showmyip.com - - if (nLookup == 1) - { - CAddress 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: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n" - "Connection: close\r\n" - "\r\n"; - - pszKeyword = NULL; // Returns just IP address - } - - if (GetMyExternalIP2(addrConnect, pszGet, pszKeyword, ipRet)) - return true; - } - - return false; -} void ThreadGetMyExternalIP(void* parg) { @@ -15696,26 +15588,10 @@ } // Fallback in case IRC fails to get it - if (GetMyExternalIP(addrLocalHost.ip)) - { - printf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str()); - if (addrLocalHost.IsRoutable()) - { - // If we already connected to a few before we had our IP, go back and addr them. - // setAddrKnown automatically filters any duplicate sends. - CAddress addr(addrLocalHost); - addr.nTime = GetAdjustedTime(); - CRITICAL_BLOCK(cs_vNodes) - BOOST_FOREACH(CNode* pnode, vNodes) - pnode->PushAddress(addr); - } - } + // ... nope. } - - - bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) { if (!addr.IsRoutable())