diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-01 15:07:11 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-01 15:07:11 +0000 |
commit | 5f4095e595fe36c6f83df96b7c59cb459b966ed3 (patch) | |
tree | 868b4a7d1f9bfcf3b85d9679fd7cbe48c6cc2005 /src/usermanager.cpp | |
parent | a64a4665e0a2898ec08cf5996bdbf63c2567310e (diff) |
Change IP address storage in User to use more IPv4/IPv6 common code
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11575 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/usermanager.cpp')
-rw-r--r-- | src/usermanager.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 0ebf1f6c7..14f022972 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -18,7 +18,7 @@ #include "bancache.h" /* add a client connection to the sockets list */ -void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscached, sockaddr* ip, const std::string &targetip) +void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscached, irc::sockets::sockaddrs* ip, const std::string &targetip) { /* NOTE: Calling this one parameter constructor for User automatically * allocates a new UUID and places it in the hash_map. @@ -35,16 +35,8 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache return; } - char ipaddr[MAXBUF]; -#ifdef IPV6 - if (ip->sa_family == AF_INET6) - inet_ntop(AF_INET6, &((const sockaddr_in6*)ip)->sin6_addr, ipaddr, sizeof(ipaddr)); - else -#endif - inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr)); - New->SetFd(socket); - New->SetSockAddr(ip->sa_family, ipaddr, port); + memcpy(&New->ip, ip, sizeof(*ip)); /* Give each of the modules an attempt to hook the user for I/O */ FOREACH_MOD_I(Instance, I_OnHookUserIO, OnHookUserIO(New, targetip)); @@ -53,7 +45,7 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache { try { - New->GetIOHook()->OnRawSocketAccept(socket, ipaddr, port); + New->GetIOHook()->OnRawSocketAccept(socket, New->GetIPString(), port); } catch (CoreException& modexcept) { @@ -220,7 +212,7 @@ void UserManager::AddLocalClone(User *user) { int range = 32; clonemap::iterator x; - switch (user->GetProtocolFamily()) + switch (user->ip.sa.sa_family) { case AF_INET6: range = ServerInstance->Config->c_ipv6_range; @@ -241,7 +233,7 @@ void UserManager::AddGlobalClone(User *user) { int range = 32; clonemap::iterator x; - switch (user->GetProtocolFamily()) + switch (user->ip.sa.sa_family) { case AF_INET6: range = ServerInstance->Config->c_ipv6_range; @@ -261,7 +253,7 @@ void UserManager::AddGlobalClone(User *user) void UserManager::RemoveCloneCounts(User *user) { int range = 32; - switch (user->GetProtocolFamily()) + switch (user->ip.sa.sa_family) { case AF_INET6: range = ServerInstance->Config->c_ipv6_range; @@ -295,7 +287,7 @@ void UserManager::RemoveCloneCounts(User *user) unsigned long UserManager::GlobalCloneCount(User *user) { int range = 32; - switch (user->GetProtocolFamily()) + switch (user->ip.sa.sa_family) { case AF_INET6: range = ServerInstance->Config->c_ipv6_range; @@ -314,7 +306,7 @@ unsigned long UserManager::GlobalCloneCount(User *user) unsigned long UserManager::LocalCloneCount(User *user) { int range = 32; - switch (user->GetProtocolFamily()) + switch (user->ip.sa.sa_family) { case AF_INET6: range = ServerInstance->Config->c_ipv6_range; |