commit bc30748636bb0cf00ec5905c2c9a43219f123df8
parent d0056ce1ded08597b1413efc91303e96f6ea971e
Author: Shinoa-Fores <btcinfo@sdf.org>
Date: Wed, 13 Jan 2021 17:21:09 -0500
asciilifeform_zap_showmyip_crud.vpatch
Diffstat:
M | bitcoin/src/net.cpp | | | 126 | +------------------------------------------------------------------------------ |
1 file changed, 1 insertion(+), 125 deletions(-)
diff --git a/bitcoin/src/net.cpp b/bitcoin/src/net.cpp
@@ -263,114 +263,6 @@ bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLooku
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:
- // <?php echo $_SERVER["REMOTE_ADDR"]; ?>
- 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)
{
@@ -386,26 +278,10 @@ void ThreadGetMyExternalIP(void* parg)
}
// 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())