diff options
Diffstat (limited to 'src/irc.cpp')
-rw-r--r-- | src/irc.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/irc.cpp b/src/irc.cpp index 237497055d..1049188411 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "irc.h" #include "net.h" @@ -12,7 +12,6 @@ using namespace std; using namespace boost; int nGotIRCAddresses = 0; -bool fGotExternalIP = false; void ThreadIRCSeed2(void* parg); @@ -201,7 +200,7 @@ void ThreadIRCSeed(void* parg) } catch (...) { PrintExceptionContinue(NULL, "ThreadIRCSeed()"); } - printf("ThreadIRCSeed exiting\n"); + printf("ThreadIRCSeed exited\n"); } void ThreadIRCSeed2(void* parg) @@ -216,7 +215,6 @@ void ThreadIRCSeed2(void* parg) printf("ThreadIRCSeed started\n"); int nErrorWait = 10; int nRetryWait = 10; - bool fNameInUse = false; while (!fShutdown) { @@ -248,10 +246,12 @@ void ThreadIRCSeed2(void* parg) return; } + CNetAddr addrIPv4("1.2.3.4"); // arbitrary IPv4 address to make GetLocal prefer IPv4 addresses + CService addrLocal; string strMyName; - if (addrLocalHost.IsRoutable() && !fUseProxy && !fNameInUse) - strMyName = EncodeAddress(addrLocalHost); - else + if (GetLocal(addrLocal, &addrIPv4)) + strMyName = EncodeAddress(GetLocalAddress(&addrConnect)); + if (strMyName == "") strMyName = strprintf("x%u", GetRand(1000000000)); Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); @@ -265,7 +265,6 @@ void ThreadIRCSeed2(void* parg) if (nRet == 2) { printf("IRC name already in use\n"); - fNameInUse = true; Wait(10); continue; } @@ -285,9 +284,8 @@ void ThreadIRCSeed2(void* parg) if (!fUseProxy && addrFromIRC.IsRoutable()) { // IRC lets you to re-nick - fGotExternalIP = true; - addrLocalHost.SetIP(addrFromIRC); - strMyName = EncodeAddress(addrLocalHost); + AddLocal(addrFromIRC, LOCAL_IRC); + strMyName = EncodeAddress(GetLocalAddress(&addrConnect)); Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); } } |