summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-02 22:57:28 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-02 22:57:28 +0000
commit8509727e16f1d9ce6c9719c8d62c7715d3699858 (patch)
tree68343ec18f5d0738c5fedaafc25d79fe5014edd0 /src/users.cpp
parent7f7e508640db92ce3535afe498bc1cc5a70a1cdd (diff)
Cache User::GetIPString()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8795 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 6b2aebfc7..7847d8281 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -926,6 +926,8 @@ bool User::ForceNickChange(const char* newnick)
void User::SetSockAddr(int protocol_family, const char* ip, int port)
{
+ this->cachedip = "";
+
switch (protocol_family)
{
#ifdef SUPPORT_IP6LINKS
@@ -1001,6 +1003,9 @@ const char* User::GetIPString()
if (this->ip == NULL)
return "";
+ if (!this->cachedip.empty())
+ return this->cachedip.c_str();
+
switch (this->GetProtocolFamily())
{
#ifdef SUPPORT_IP6LINKS
@@ -1015,8 +1020,11 @@ const char* User::GetIPString()
{
strlcpy(&temp[1], buf, sizeof(temp) - 1);
*temp = '0';
+ this->cachedip = temp;
return temp;
}
+
+ this->cachedip = buf;
return buf;
}
break;
@@ -1025,12 +1033,15 @@ const char* User::GetIPString()
{
sockaddr_in* sin = (sockaddr_in*)this->ip;
inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
+ this->cachedip = buf;
return buf;
}
break;
default:
break;
}
+
+ // Unreachable, probably
return "";
}