summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-07 19:56:35 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-07 19:56:35 +0000
commit0b460e6f324aa72cdbfb4143918971d582f62a77 (patch)
tree25332570a9fe25b7b5f6f7c7e255d9dd7caceabd /src/modules
parent24a6c24858d4ae3e747884f6486796d161d6c301 (diff)
Ident fixes,
removal of some old craq we dont use. cgiirc optimizations and tidyups git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6541 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_cgiirc.cpp4
-rw-r--r--src/modules/m_ident.cpp31
2 files changed, 25 insertions, 10 deletions
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;