Don't force IRC off if not listening, do force it off if IPv4 is off.
Previously Bitcoin would refuse to use IRC if it was either not accepting inbound connections or not making outbound. Instead this changes it to not use IRC only if it's not doing either or if IPv4 is off completely. If Bitcoin is not listening this will use the default random nicks rather than the IP based ones.
This commit is contained in:
parent
5f38875807
commit
3595b18793
1 changed files with 12 additions and 5 deletions
15
src/irc.cpp
15
src/irc.cpp
|
@ -207,10 +207,15 @@ void ThreadIRCSeed(void* parg)
|
||||||
|
|
||||||
void ThreadIRCSeed2(void* parg)
|
void ThreadIRCSeed2(void* parg)
|
||||||
{
|
{
|
||||||
/* Don't advertise on IRC if we don't allow incoming connections */
|
// Don't connect to IRC if we won't use IPv4 connections.
|
||||||
if (mapArgs.count("-connect") || fNoListen)
|
if (IsLimited(NET_IPV4))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// ... or if we won't make outbound connections and won't accept inbound ones.
|
||||||
|
if (mapArgs.count("-connect") && fNoListen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// ... or if IRC is not enabled.
|
||||||
if (!GetBoolArg("-irc", false))
|
if (!GetBoolArg("-irc", false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -251,7 +256,8 @@ void ThreadIRCSeed2(void* parg)
|
||||||
CNetAddr addrIPv4("1.2.3.4"); // arbitrary IPv4 address to make GetLocal prefer IPv4 addresses
|
CNetAddr addrIPv4("1.2.3.4"); // arbitrary IPv4 address to make GetLocal prefer IPv4 addresses
|
||||||
CService addrLocal;
|
CService addrLocal;
|
||||||
string strMyName;
|
string strMyName;
|
||||||
if (GetLocal(addrLocal, &addrIPv4))
|
// Don't use our IP as our nick if we're not listening
|
||||||
|
if (!fNoListen && GetLocal(addrLocal, &addrIPv4))
|
||||||
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
|
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
|
||||||
if (strMyName == "")
|
if (strMyName == "")
|
||||||
strMyName = strprintf("x%u", GetRand(1000000000));
|
strMyName = strprintf("x%u", GetRand(1000000000));
|
||||||
|
@ -283,7 +289,8 @@ void ThreadIRCSeed2(void* parg)
|
||||||
if (GetIPFromIRC(hSocket, strMyName, addrFromIRC))
|
if (GetIPFromIRC(hSocket, strMyName, addrFromIRC))
|
||||||
{
|
{
|
||||||
printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToString().c_str());
|
printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToString().c_str());
|
||||||
if (addrFromIRC.IsRoutable())
|
// Don't use our IP as our nick if we're not listening
|
||||||
|
if (!fNoListen && addrFromIRC.IsRoutable())
|
||||||
{
|
{
|
||||||
// IRC lets you to re-nick
|
// IRC lets you to re-nick
|
||||||
AddLocal(addrFromIRC, LOCAL_IRC);
|
AddLocal(addrFromIRC, LOCAL_IRC);
|
||||||
|
|
Loading…
Reference in a new issue