diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-02-19 20:44:35 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-05-04 16:12:23 +0200 |
commit | 19b6958cfd5c5207ffe8259ef48ebbd24ca89725 (patch) | |
tree | 454edd591d114938e4f7d19b972bde3b00e609c1 /src/net.cpp | |
parent | 39857190dee3ed296112cfcfd79b0a375143b6c6 (diff) |
Added -externalip and -discover
-externalip=<ip> can be used to explicitly set the public IP address
of your node. -discover=0 can be used to disable the automatic public
IP discovery system.
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/src/net.cpp b/src/net.cpp index 0a78bc445f..c626e49b1b 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -973,19 +973,21 @@ void ThreadMapPort2(void* parg) r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); if (r == 1) { - 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]) + if (GetBoolArg("-discover", true)) { + char externalIPAddress[40]; + r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); + if(r != UPNPCOMMAND_SUCCESS) + printf("UPnP: GetExternalIPAddress() returned %d\n", r); + else { - printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); - AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP); + if(externalIPAddress[0]) + { + printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); + AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP); + } + else + printf("UPnP: GetExternalIPAddress failed.\n"); } - else - printf("UPnP: GetExternalIPAddress failed.\n"); } string strDesc = "Bitcoin " + FormatFullVersion(); @@ -1695,18 +1697,10 @@ bool BindListenPort(string& strError) return true; } -void StartNode(void* parg) +void static Discover() { -#ifdef USE_UPNP -#if USE_UPNP - fUseUPnP = GetBoolArg("-upnp", true); -#else - fUseUPnP = GetBoolArg("-upnp", false); -#endif -#endif - - if (pnodeLocalHost == NULL) - pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); + if (!GetBoolArg("-discover", true)) + return; #ifdef WIN32 // Get local host ip @@ -1764,6 +1758,22 @@ void StartNode(void* parg) { CreateThread(ThreadGetMyExternalIP, NULL); } +} + +void StartNode(void* parg) +{ +#ifdef USE_UPNP +#if USE_UPNP + fUseUPnP = GetBoolArg("-upnp", true); +#else + fUseUPnP = GetBoolArg("-upnp", false); +#endif +#endif + + if (pnodeLocalHost == NULL) + pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); + + Discover(); // // Start threads |