aboutsummaryrefslogtreecommitdiff
path: root/src/irc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc.cpp')
-rw-r--r--src/irc.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/irc.cpp b/src/irc.cpp
index fe96a90a1c..8805c7fd5b 100644
--- a/src/irc.cpp
+++ b/src/irc.cpp
@@ -22,22 +22,25 @@ void ThreadIRCSeed2(void* parg);
#pragma pack(push, 1)
struct ircaddr
{
- int ip;
+ struct in_addr ip;
short port;
};
#pragma pack(pop)
-string EncodeAddress(const CAddress& addr)
+string EncodeAddress(const CService& addr)
{
struct ircaddr tmp;
- tmp.ip = addr.ip;
- tmp.port = addr.port;
+ if (addr.GetInAddr(&tmp.ip))
+ {
+ tmp.port = htons(addr.GetPort());
- vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp));
- return string("u") + EncodeBase58Check(vch);
+ vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp));
+ return string("u") + EncodeBase58Check(vch);
+ }
+ return "";
}
-bool DecodeAddress(string str, CAddress& addr)
+bool DecodeAddress(string str, CService& addr)
{
vector<unsigned char> vch;
if (!DecodeBase58Check(str.substr(1), vch))
@@ -48,7 +51,7 @@ bool DecodeAddress(string str, CAddress& addr)
return false;
memcpy(&tmp, &vch[0], sizeof(tmp));
- addr = CAddress(tmp.ip, ntohs(tmp.port), NODE_NETWORK);
+ addr = CService(tmp.ip, ntohs(tmp.port));
return true;
}
@@ -204,7 +207,7 @@ bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
}
}
-bool GetIPFromIRC(SOCKET hSocket, string strMyName, unsigned int& ipRet)
+bool GetIPFromIRC(SOCKET hSocket, string strMyName, CNetAddr& ipRet)
{
Send(hSocket, strprintf("USERHOST %s\r", strMyName.c_str()).c_str());
@@ -227,10 +230,10 @@ bool GetIPFromIRC(SOCKET hSocket, string strMyName, unsigned int& ipRet)
printf("GetIPFromIRC() got userhost %s\n", strHost.c_str());
if (fUseProxy)
return false;
- CAddress addr(strHost, 0, true);
+ CNetAddr addr(strHost, true);
if (!addr.IsValid())
return false;
- ipRet = addr.ip;
+ ipRet = addr;
return true;
}
@@ -267,9 +270,9 @@ void ThreadIRCSeed2(void* parg)
while (!fShutdown)
{
- CAddress addrConnect("92.243.23.21", 6667); // irc.lfnet.org
+ CService addrConnect("92.243.23.21", 6667); // irc.lfnet.org
- CAddress addrIRC("irc.lfnet.org", 6667, true);
+ CService addrIRC("irc.lfnet.org", 6667, true);
if (addrIRC.IsValid())
addrConnect = addrIRC;
@@ -325,15 +328,15 @@ void ThreadIRCSeed2(void* parg)
Sleep(500);
// Get our external IP from the IRC server and re-nick before joining the channel
- CAddress addrFromIRC;
- if (GetIPFromIRC(hSocket, strMyName, addrFromIRC.ip))
+ CNetAddr addrFromIRC;
+ if (GetIPFromIRC(hSocket, strMyName, addrFromIRC))
{
- printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToStringIP().c_str());
+ printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToString().c_str());
if (!fUseProxy && addrFromIRC.IsRoutable())
{
// IRC lets you to re-nick
fGotExternalIP = true;
- addrLocalHost.ip = addrFromIRC.ip;
+ addrLocalHost.SetIP(addrFromIRC);
strMyName = EncodeAddress(addrLocalHost);
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
}