summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-11 00:03:03 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-11 00:03:03 +0000
commite20a0915892b965b345db80d25fed25b8ef3a52f (patch)
tree12c35f8d4c9043765c668ae7495a2dc4d52b916a
parente6de2ea580f3fa25dbe8bdd2ed8267e18144b315 (diff)
Much faster way of checking if the user is 4in6, avoid strncmp in User::GetIPString(), do it in User::SetSockAddr()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9455 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/users.h6
-rw-r--r--src/users.cpp6
2 files changed, 9 insertions, 3 deletions
diff --git a/include/users.h b/include/users.h
index c563431d2..f91e8b152 100644
--- a/include/users.h
+++ b/include/users.h
@@ -653,7 +653,7 @@ class CoreExport User : public connection
/** Get IP string from sockaddr, using static internal buffer
* @return The IP string
*/
- const char* GetIPString();
+ const char* GetIPString(bool translate4in6 = true);
/* Write error string
*/
@@ -663,6 +663,10 @@ class CoreExport User : public connection
*/
bool exempt;
+ /** True if the user is a 4in6 ip (0::ffff:1.2.3.4) and requires special translation in GetIPString()
+ */
+ bool is4in6;
+
/** This value contains how far into the penalty threshold the user is. Once its over
* the penalty threshold then commands are held and processed on-timer.
*/
diff --git a/src/users.cpp b/src/users.cpp
index cdacdc5c2..80515ffb8 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -191,7 +191,7 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
Penalty = 0;
lines_in = lastping = signon = idle_lastmsg = nping = registered = 0;
ChannelCount = timeout = bytes_in = bytes_out = cmds_in = cmds_out = 0;
- quietquit = OverPenalty = ExemptFromPenalty = quitting = exempt = haspassed = dns_done = false;
+ is4in6 = quietquit = OverPenalty = ExemptFromPenalty = quitting = exempt = haspassed = dns_done = false;
fd = -1;
recvq.clear();
sendq.clear();
@@ -1030,6 +1030,8 @@ void User::SetSockAddr(int protocol_family, const char* sip, int port)
ServerInstance->Logs->Log("USERS",DEBUG,"Uh oh, I dont know protocol %d to be set on '%s'!", protocol_family, this->nick);
break;
}
+
+ is4in6 = !strncmp(GetIPString(), "0::ffff:", 8);
}
int User::GetPort()
@@ -1096,7 +1098,7 @@ const char* User::GetIPString(bool translate4in6)
{
strlcpy(&temp[1], buf, sizeof(temp) - 1);
*temp = '0';
- if (translate4in6 && !strncmp(temp, "0::ffff:", 8))
+ if (translate4in6 && is4in6)
{
this->cachedip = temp + 8;
return temp + 8;