diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-04 11:03:21 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-04 11:03:21 +0000 |
commit | b8c3c5d25b84b358fc93eea0e885372dcad01480 (patch) | |
tree | d34a50599900d4b6d51d1c1635546c5be828781b /src/users.cpp | |
parent | a361a0bbc980a44e775c868b34d6c01f545a8515 (diff) |
Safety wrapper defines for ipv6 code on ipv4 ircds
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4697 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/users.cpp b/src/users.cpp index 85d64d462..74f70b458 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -895,20 +895,11 @@ long FindMatchingGlobal(userrec* user) long x = 0; for (user_hash::const_iterator a = clientlist.begin(); a != clientlist.end(); a++) { -#ifdef IPV6 - /* I dont think theres any faster way of matching two ipv6 addresses than memcmp - * Let me know if you think of one. - */ - in6_addr* s1 = &(((sockaddr_in6*)&a->second->ip)->sin6_addr); - in6_addr* s2 = &(((sockaddr_in6*)&user->ip)->sin6_addr); - if (!memcmp(s1->s6_addr, s2->s6_addr, sizeof(in6_addr))) - x++; -#else - in_addr* s1 = &((sockaddr_in*)&a->second->ip)->sin_addr; - in_addr* s2 = &((sockaddr_in*)&user->ip)->sin_addr; - if (s1->s_addr == s2->s_addr) - x++; -#endif + /* We have to match ip's as strings - we don't know what protocol + * a remote user may be using + */ + if (!strcasecmp(a->second->GetIPString(), user->GetIPString())) + x++; } return x; } @@ -1111,6 +1102,7 @@ void userrec::SetSockAddr(int protocol_family, const char* ip, int port) { switch (protocol_family) { +#ifdef SUPPORT_IP6LINKS case AF_INET6: { sockaddr_in6* sin = (sockaddr_in6*)&this->ip; @@ -1119,6 +1111,7 @@ void userrec::SetSockAddr(int protocol_family, const char* ip, int port) inet_pton(AF_INET6, ip, &sin->sin6_addr); } break; +#endif case AF_INET: { sockaddr_in* sin = (sockaddr_in*)&this->ip; @@ -1137,12 +1130,14 @@ int userrec::GetPort() { switch (this->GetProtocolFamily()) { +#ifdef SUPPORT_IP6LINKS case AF_INET6: { sockaddr_in6* sin = (sockaddr_in6*)&this->ip; return sin->sin6_port; } break; +#endif case AF_INET: { sockaddr_in* sin = (sockaddr_in*)&this->ip; @@ -1168,6 +1163,7 @@ const char* userrec::GetIPString() switch (this->GetProtocolFamily()) { +#ifdef SUPPORT_IP6LINKS case AF_INET6: { sockaddr_in6* sin = (sockaddr_in6*)&this->ip; @@ -1175,6 +1171,7 @@ const char* userrec::GetIPString() return buf; } break; +#endif case AF_INET: { sockaddr_in* sin = (sockaddr_in*)&this->ip; |