diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-12-15 22:43:51 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-12-15 22:43:51 +0000 |
commit | 629e37dde1fa93f6ce31544d1ebb5ee5c19052cb (patch) | |
tree | 4b8e7ae1cc3ed5b07a75a2d11f04660aac442c81 /irc.cpp | |
parent | fc73ad644f0b87b91f49b7f6f6b2348f78bdbbf4 (diff) |
get external ip from irc
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@202 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'irc.cpp')
-rw-r--r-- | irc.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -5,6 +5,7 @@ #include "headers.h" int nGotIRCAddresses = 0; +bool fGotExternalIP = false; void ThreadIRCSeed2(void* parg); @@ -223,6 +224,8 @@ bool GetIPFromIRC(SOCKET hSocket, string strMyName, unsigned int& ipRet) } else { + // Hybrid IRC used by lfnet always returns IP when you userhost yourself, + // but in case another IRC is ever used this should work. printf("GetIPFromIRC() got userhost %s\n", strHost.c_str()); if (fUseProxy) return false; @@ -327,14 +330,15 @@ void ThreadIRCSeed2(void* parg) } Sleep(500); - // Get my external IP from IRC server + // Get our external IP from the IRC server and re-nick before joining the channel CAddress addrFromIRC; if (GetIPFromIRC(hSocket, strMyName, addrFromIRC.ip)) { - // Just using it as a backup for now printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToStringIP().c_str()); - if (addrFromIRC.IsRoutable() && !fUseProxy && !addrLocalHost.IsRoutable()) + if (!fUseProxy && addrFromIRC.IsRoutable()) { + // IRC lets you to re-nick + fGotExternalIP = true; addrLocalHost.ip = addrFromIRC.ip; strMyName = EncodeAddress(addrLocalHost); Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); |