diff options
-rw-r--r-- | include/hashcomp.h | 23 | ||||
-rw-r--r-- | src/dns.cpp | 1 | ||||
-rw-r--r-- | src/hashcomp.cpp | 23 | ||||
-rw-r--r-- | src/inspsocket.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_cgiirc.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_ident.cpp | 31 |
6 files changed, 25 insertions, 59 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index abcc1e94e..445c4c4ea 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -36,7 +36,6 @@ using namespace std; using irc::sockets::insp_aton; using irc::sockets::insp_ntoa; -using irc::sockets::insp_inaddr; #ifndef LOWERMAP #define LOWERMAP @@ -69,17 +68,6 @@ namespace nspace */ void strlower(char *n); - /** Hashing function to hash insp_inaddr structs - */ - template<> struct hash<insp_inaddr> - { - /** Hash an insp_inaddr - * @param a An insp_inaddr to hash - * @return The hash value - */ - size_t operator()(const insp_inaddr &a) const; - }; - /** Hashing function to hash std::string without respect to case */ template<> struct hash<std::string> @@ -109,17 +97,6 @@ namespace irc }; - /** This class returns true if two insp_inaddr structs match. - * Checking is done by copying both into a size_t then doing a - * numeric comparison of the two. - */ - struct InAddr_HashComp - { - /** The operator () does the actual comparison in hash_map - */ - bool operator()(const insp_inaddr &s1, const insp_inaddr &s2) const; - }; - /** irc::stringjoiner joins string lists into a string, using * the given seperator string. * This class can join a vector of std::string, a deque of diff --git a/src/dns.cpp b/src/dns.cpp index 2eaff68b9..33dba1abb 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -32,7 +32,6 @@ looks like this, walks like this or tastes like this. #include "configreader.h" #include "socket.h" -using irc::sockets::insp_sockaddr; using irc::sockets::insp_inaddr; using irc::sockets::insp_ntoa; using irc::sockets::insp_aton; diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 55b3f9b58..f8d131675 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -39,10 +39,6 @@ * Scandanavian Comparisons: The characters [, ], \ will * be considered the lowercase of {, } and |. * - * This file also contains hashing methods for hashing - * insp_inaddr structs, we use this if we want to cache IP - * addresses. - * ******************************************************/ using namespace irc::sockets; @@ -65,13 +61,6 @@ void nspace::strlower(char *n) } } -size_t nspace::hash<insp_inaddr>::operator()(const insp_inaddr &a) const -{ - size_t q; - memcpy(&q,&a,sizeof(size_t)); - return q; -} - size_t nspace::hash<string>::operator()(const string &s) const { /* XXX: NO DATA COPIES! :) @@ -104,18 +93,6 @@ bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) return (lowermap[*n1] == lowermap[*n2]); } -bool irc::InAddr_HashComp::operator()(const insp_inaddr &s1, const insp_inaddr &s2) const -{ -#ifdef IPV6 - for (int n = 0; n < 16; n++) - if (s2.s6_addr[n] != s1.s6_addr[n]) - return false; - return true; -#else - return (s1.s_addr == s1.s_addr); -#endif -} - /****************************************************** * * This is the implementation of our special irc::string diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index c311a78fa..093b133f0 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -18,8 +18,6 @@ #include "inspircd.h" using irc::sockets::OpenTCPSocket; -using irc::sockets::insp_inaddr; -using irc::sockets::insp_sockaddr; bool InspSocket::Readable() { diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index beed70424..2a399df03 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -236,7 +236,7 @@ public: bool valid = false; #ifdef IPV6 - if (strchr(user->password,':')) + if (user->GetAddressFamily() == AF_INET6) valid = (inet_pton(AF_INET6, user->password, &((sockaddr_in6*)&user->ip)->sin6_addr) > 0); else valid = (inet_aton(user->password, &((sockaddr_in*)&user->ip)->sin_addr)); @@ -300,7 +300,7 @@ public: user->Extend("cgiirc_realhost", new std::string(user->host)); user->Extend("cgiirc_realip", new std::string(user->GetIPString())); #ifdef IPV6 - if (strchr(user->password,':')) + if (user->GetAddressFamily() == AF_INET6) inet_pton(AF_INET6, newip, &((sockaddr_in6*)&user->ip)->sin6_addr); else inet_aton(newip, &((sockaddr_in*)&user->ip)->sin_addr); diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 01b268edd..6c7d36974 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -27,9 +27,6 @@ class RFC1413 : public InspSocket { protected: - // Server* class used for core communications - insp_sockaddr sock_us; // our port number - insp_sockaddr sock_them; // their port number socklen_t uslen; // length of our port number socklen_t themlen; // length of their port number char ident_request[128]; // buffer used to make up the request string @@ -140,9 +137,24 @@ class RFC1413 : public InspSocket { if (u && (Instance->SE->GetRef(ufd) == u)) { - uslen = sizeof(sock_us); - themlen = sizeof(sock_them); - if ((getsockname(this->u->GetFd(),(sockaddr*)&sock_us,&uslen) || getpeername(this->u->GetFd(), (sockaddr*)&sock_them, &themlen))) + sockaddr* sock_us = new sockaddr; + sockaddr* sock_them = new sockaddr; + bool success = false; + uslen = sizeof(sockaddr_in); + themlen = sizeof(sockaddr_in); +#ifdef IPV6 + if (this->u->GetAddressFamily() == AF_INET6) + { + themlen = sizeof(sockaddr_in6); + uslen = sizeof(sockaddr_in6); + success = ((getsockname(this->u->GetFd(),sock_us,&uslen) || getpeername(this->u->GetFd(), sock_them, &themlen))); + } + else + success = ((getsockname(this->u->GetFd(),sock_us,&uslen) || getpeername(this->u->GetFd(), sock_them, &themlen))); +#else + success = ((getsockname(this->u->GetFd(),sock_us,&uslen) || getpeername(this->u->GetFd(), sock_them, &themlen))); +#endif + if (success) { Instance->Log(DEBUG,"BUG: Ident: failed to get socket names"); return false; @@ -151,9 +163,12 @@ class RFC1413 : public InspSocket { // send the request in the following format: theirsocket,oursocket #ifdef IPV6 - snprintf(ident_request,127,"%d,%d\r\n",ntohs(sock_them.sin6_port),ntohs(sock_us.sin6_port)); + if (this->u->GetAddressFamily() == AF_INET6) + snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in6*)sock_them)->sin6_port),ntohs(((sockaddr_in6*)sock_us)->sin6_port)); + else + snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in*)sock_them)->sin_port),ntohs(((sockaddr_in*)sock_us)->sin_port)); #else - snprintf(ident_request,127,"%d,%d\r\n",ntohs(sock_them.sin_port),ntohs(sock_us.sin_port)); + snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in*)sock_them)->sin_port),ntohs(((sockaddr_in*)sock_us)->sin_port)); #endif this->Write(ident_request); return true; |