trb

trb
Log | Files | Refs

commit fe89cdb7b2e039fd3999b8ca0499f824f616edec
parent 2eab12afd13ecec6bb61f57c670f84d8c9ace12c
Author: Shinoa-Fores <btcinfo@sdf.org>
Date:   Wed, 13 Jan 2021 16:55:20 -0500

rm_rf_upnp.vpatch

Diffstat:
Mbitcoin/src/db.cpp | 4----
Mbitcoin/src/init.cpp | 13-------------
Mbitcoin/src/main.cpp | 5-----
Mbitcoin/src/main.h | 6------
Mbitcoin/src/makefile.linux-mingw | 7-------
Mbitcoin/src/makefile.unix | 10----------
Mbitcoin/src/net.cpp | 164-------------------------------------------------------------------------------
7 files changed, 0 insertions(+), 209 deletions(-)

diff --git a/bitcoin/src/db.cpp b/bitcoin/src/db.cpp @@ -927,7 +927,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet) if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose; if (strKey == "fUseProxy") ssValue >> fUseProxy; if (strKey == "addrProxy") ssValue >> addrProxy; - if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP; } else if (strType == "minversion") { @@ -950,9 +949,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet) printf("fMinimizeOnClose = %d\n", fMinimizeOnClose); printf("fUseProxy = %d\n", fUseProxy); printf("addrProxy = %s\n", addrProxy.ToString().c_str()); - if (fHaveUPnP) - printf("fUseUPnP = %d\n", fUseUPnP); - // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000)) diff --git a/bitcoin/src/init.cpp b/bitcoin/src/init.cpp @@ -188,13 +188,6 @@ bool AppInit2(int argc, char* argv[]) " -bantime=<n> \t " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)\n") + " -maxreceivebuffer=<n>\t " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)\n") + " -maxsendbuffer=<n>\t " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 10000)\n") + -#ifdef USE_UPNP -#if USE_UPNP - " -noupnp \t " + _("Don't attempt to use UPnP to map the listening port\n") + -#else - " -upnp \t " + _("Attempt to use UPnP to map the listening port\n") + -#endif -#endif " -paytxfee=<amt> \t " + _("Fee per kB to add to transactions you send\n") + #if !defined(WIN32) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + @@ -460,8 +453,6 @@ bool AppInit2(int argc, char* argv[]) SoftSetArg("-nolisten", true); SoftSetArg("-noirc", true); SoftSetArg("-nodnsseed", true); - SoftSetArg("-noupnp", true); - SoftSetArg("-upnp", false); SoftSetArg("-dns", false); } @@ -469,10 +460,6 @@ bool AppInit2(int argc, char* argv[]) fNoListen = GetBoolArg("-nolisten"); // Command-line args override in-wallet settings: - if (mapArgs.count("-upnp")) - fUseUPnP = GetBoolArg("-upnp"); - else if (mapArgs.count("-noupnp")) - fUseUPnP = !GetBoolArg("-noupnp"); if (!fNoListen) { diff --git a/bitcoin/src/main.cpp b/bitcoin/src/main.cpp @@ -57,11 +57,6 @@ int fLimitProcessors = false; int nLimitProcessors = 1; int fMinimizeToTray = true; int fMinimizeOnClose = true; -#if USE_UPNP -int fUseUPnP = true; -#else -int fUseUPnP = false; -#endif ////////////////////////////////////////////////////////////////////////////// diff --git a/bitcoin/src/main.h b/bitcoin/src/main.h @@ -40,11 +40,6 @@ inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONE static const int COINBASE_MATURITY = 100; // Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. static const int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC -#ifdef USE_UPNP -static const int fHaveUPnP = true; -#else -static const int fHaveUPnP = false; -#endif @@ -74,7 +69,6 @@ extern int fLimitProcessors; extern int nLimitProcessors; extern int fMinimizeToTray; extern int fMinimizeOnClose; -extern int fUseUPnP; diff --git a/bitcoin/src/makefile.linux-mingw b/bitcoin/src/makefile.linux-mingw @@ -4,8 +4,6 @@ DEPSDIR:=/usr/i586-mingw32msvc -USE_UPNP:=0 - INCLUDEPATHS= \ -I"$(DEPSDIR)/boost_1_47_0" \ -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ @@ -53,11 +51,6 @@ HEADERS = \ wallet.h -ifdef USE_UPNP - LIBPATHS += -L"$(DEPSDIR)/miniupnpc" - LIBS += -l miniupnpc -l iphlpapi - DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) -endif LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi diff --git a/bitcoin/src/makefile.unix b/bitcoin/src/makefile.unix @@ -2,8 +2,6 @@ # Distributed under the MIT/X11 software license, see the accompanying # file license.txt or http://www.opensource.org/licenses/mit-license.php. -USE_UPNP:=0 - DEFS=-DNOPCH DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) @@ -31,14 +29,6 @@ LIBS += \ -l ssl \ -l crypto -ifndef USE_UPNP - override USE_UPNP = - -endif -ifneq (${USE_UPNP}, -) - LIBS += -l miniupnpc - DEFS += -DUSE_UPNP=$(USE_UPNP) -endif - ifneq (${USE_SSL}, 0) DEFS += -DUSE_SSL endif diff --git a/bitcoin/src/net.cpp b/bitcoin/src/net.cpp @@ -14,12 +14,6 @@ #include <string.h> #endif -#ifdef USE_UPNP -#include <miniupnpc/miniwget.h> -#include <miniupnpc/miniupnpc.h> -#include <miniupnpc/upnpcommands.h> -#include <miniupnpc/upnperrors.h> -#endif using namespace std; using namespace boost; @@ -29,9 +23,6 @@ static const int MAX_OUTBOUND_CONNECTIONS = 8; void ThreadMessageHandler2(void* parg); void ThreadSocketHandler2(void* parg); void ThreadOpenConnections2(void* parg); -#ifdef USE_UPNP -void ThreadMapPort2(void* parg); -#endif void ThreadDNSAddressSeed2(void* parg); bool OpenNetworkConnection(const CAddress& addrConnect); @@ -1110,153 +1101,6 @@ void ThreadSocketHandler2(void* parg) -#ifdef USE_UPNP -void ThreadMapPort(void* parg) -{ - IMPLEMENT_RANDOMIZE_STACK(ThreadMapPort(parg)); - try - { - vnThreadsRunning[5]++; - ThreadMapPort2(parg); - vnThreadsRunning[5]--; - } - catch (std::exception& e) { - vnThreadsRunning[5]--; - PrintException(&e, "ThreadMapPort()"); - } catch (...) { - vnThreadsRunning[5]--; - PrintException(NULL, "ThreadMapPort()"); - } - printf("ThreadMapPort exiting\n"); -} - -void ThreadMapPort2(void* parg) -{ - printf("ThreadMapPort started\n"); - - char port[6]; - sprintf(port, "%d", GetListenPort()); - - const char * multicastif = 0; - const char * minissdpdpath = 0; - struct UPNPDev * devlist = 0; - char lanaddr[64]; - -#ifndef UPNPDISCOVER_SUCCESS - /* miniupnpc 1.5 */ - devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); -#else - /* miniupnpc 1.6 */ - int error = 0; - devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); -#endif - - struct UPNPUrls urls; - struct IGDdatas data; - int r; - - r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); - if (r == 1) - { - if (!addrLocalHost.IsRoutable()) - { - char externalIPAddress[40]; - r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); - if(r != UPNPCOMMAND_SUCCESS) - printf("UPnP: GetExternalIPAddress() returned %d\n", r); - else - { - if(externalIPAddress[0]) - { - printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); - CAddress addrExternalFromUPnP(externalIPAddress, 0, false, nLocalServices); - if (addrExternalFromUPnP.IsRoutable()) - addrLocalHost = addrExternalFromUPnP; - } - else - printf("UPnP: GetExternalIPAddress failed.\n"); - } - } - - string strDesc = "Bitcoin " + FormatFullVersion(); -#ifndef UPNPDISCOVER_SUCCESS - /* miniupnpc 1.5 */ - r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0); -#else - /* miniupnpc 1.6 */ - r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); -#endif - - if(r!=UPNPCOMMAND_SUCCESS) - printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", - port, port, lanaddr, r, strupnperror(r)); - else - printf("UPnP Port Mapping successful.\n"); - int i = 1; - loop { - if (fShutdown || !fUseUPnP) - { - r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port, "TCP", 0); - printf("UPNP_DeletePortMapping() returned : %d\n", r); - freeUPNPDevlist(devlist); devlist = 0; - FreeUPNPUrls(&urls); - return; - } - if (i % 600 == 0) // Refresh every 20 minutes - { -#ifndef UPNPDISCOVER_SUCCESS - /* miniupnpc 1.5 */ - r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0); -#else - /* miniupnpc 1.6 */ - r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); -#endif - - if(r!=UPNPCOMMAND_SUCCESS) - printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", - port, port, lanaddr, r, strupnperror(r)); - else - printf("UPnP Port Mapping successful.\n");; - } - Sleep(2000); - i++; - } - } else { - printf("No valid UPnP IGDs found\n"); - freeUPNPDevlist(devlist); devlist = 0; - if (r != 0) - FreeUPNPUrls(&urls); - loop { - if (fShutdown || !fUseUPnP) - return; - Sleep(2000); - } - } -} - -void MapPort(bool fMapPort) -{ - if (fUseUPnP != fMapPort) - { - fUseUPnP = fMapPort; - WriteSetting("fUseUPnP", fUseUPnP); - } - if (fUseUPnP && vnThreadsRunning[5] < 1) - { - if (!CreateThread(ThreadMapPort, NULL)) - printf("Error: ThreadMapPort(ThreadMapPort) failed\n"); - } -} -#else -void MapPort(bool /* unused fMapPort */) -{ - // Intentionally left blank. -} -#endif @@ -1872,10 +1716,6 @@ void StartNode(void* parg) if (!CreateThread(ThreadDNSAddressSeed, NULL)) printf("Error: CreateThread(ThreadDNSAddressSeed) failed\n"); - // Map ports with UPnP - if (fHaveUPnP) - MapPort(fUseUPnP); - // Get addresses from IRC and advertise ours if (!CreateThread(ThreadIRCSeed, NULL)) printf("Error: CreateThread(ThreadIRCSeed) failed\n"); @@ -1903,9 +1743,6 @@ bool StopNode() nTransactionsUpdated++; int64 nStart = GetTime(); while (vnThreadsRunning[0] > 0 || vnThreadsRunning[1] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0 -#ifdef USE_UPNP - || vnThreadsRunning[5] > 0 -#endif ) { if (GetTime() - nStart > 20) @@ -1917,7 +1754,6 @@ bool StopNode() if (vnThreadsRunning[2] > 0) printf("ThreadMessageHandler still running\n"); if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n"); if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n"); - if (fHaveUPnP && vnThreadsRunning[5] > 0) printf("ThreadMapPort still running\n"); if (vnThreadsRunning[6] > 0) printf("ThreadDNSAddressSeed still running\n"); while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0) Sleep(20);