From 5f4095e595fe36c6f83df96b7c59cb459b966ed3 Mon Sep 17 00:00:00 2001 From: danieldg Date: Tue, 1 Sep 2009 15:07:11 +0000 Subject: 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 --- src/modules/m_cgiirc.cpp | 12 ++++++------ src/modules/m_cloaking.cpp | 8 ++++---- src/modules/m_connectban.cpp | 2 +- src/modules/m_spanningtree/uid.cpp | 5 +---- 4 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 580060464..048f8bde0 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -117,7 +117,7 @@ class CGIResolver : public Resolver them->host.assign(result,0, 64); them->dhost.assign(result, 0, 64); if (querytype) - them->SetSockAddr(them->GetProtocolFamily(), result.c_str(), them->GetPort()); + them->SetSockAddr(result.c_str(), them->GetPort()); them->ident.assign("~cgiirc", 0, 8); them->InvalidateCache(); them->CheckLines(true); @@ -318,7 +318,7 @@ public: if(user->GetExt("cgiirc_webirc_ip", webirc_ip)) { ServerInstance->Users->RemoveCloneCounts(user); - user->SetSockAddr(user->GetProtocolFamily(), webirc_ip->c_str(), user->GetPort()); + user->SetSockAddr(webirc_ip->c_str(), user->GetPort()); delete webirc_ip; user->InvalidateCache(); user->Shrink("cgiirc_webirc_ip"); @@ -342,10 +342,10 @@ public: bool valid = false; ServerInstance->Users->RemoveCloneCounts(user); #ifdef IPV6 - if (user->GetProtocolFamily() == AF_INET6) - valid = (inet_pton(AF_INET6, user->password.c_str(), &((sockaddr_in6*)user->ip)->sin6_addr) > 0); + if (user->ip.sa.sa_family == AF_INET6) + valid = (inet_pton(AF_INET6, user->password.c_str(), &user->ip.in6.sin6_addr) > 0); else - valid = (inet_aton(user->password.c_str(), &((sockaddr_in*)user->ip)->sin_addr)); + valid = (inet_aton(user->password.c_str(), &user->ip.in4.sin_addr)); #else if (inet_aton(user->password.c_str(), &((sockaddr_in*)user->ip)->sin_addr)) valid = true; @@ -407,7 +407,7 @@ public: user->Extend("cgiirc_realhost", new std::string(user->host)); user->Extend("cgiirc_realip", new std::string(user->GetIPString())); ServerInstance->Users->RemoveCloneCounts(user); - user->SetSockAddr(user->GetProtocolFamily(), newip, user->GetPort()); + user->SetSockAddr(newip, user->GetPort()); ServerInstance->Users->AddLocalClone(user); ServerInstance->Users->AddGlobalClone(user); user->CheckClass(); diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 59dd008af..29a5e1421 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -413,10 +413,10 @@ class ModuleCloaking : public Module #ifdef IPV6 in6_addr testaddr; in_addr testaddr2; - if ((dest->GetProtocolFamily() == AF_INET6) && (inet_pton(AF_INET6,dest->host.c_str(),&testaddr) < 1) && (hostcloak.length() <= 64)) + if ((dest->ip.sa.sa_family == AF_INET6) && (inet_pton(AF_INET6,dest->host.c_str(),&testaddr) < 1) && (hostcloak.length() <= 64)) /* Invalid ipv6 address, and ipv6 user (resolved host) */ b = hostcloak; - else if ((dest->GetProtocolFamily() == AF_INET) && (inet_aton(dest->host.c_str(),&testaddr2) < 1) && (hostcloak.length() <= 64)) + else if ((dest->ip.sa.sa_family == AF_INET) && (inet_aton(dest->host.c_str(),&testaddr2) < 1) && (hostcloak.length() <= 64)) /* Invalid ipv4 address, and ipv4 user (resolved host) */ b = hostcloak; else @@ -435,10 +435,10 @@ class ModuleCloaking : public Module else { #ifdef IPV6 - if (dest->GetProtocolFamily() == AF_INET6) + if (dest->ip.sa.sa_family == AF_INET6) b = cu->Cloak6(dest->GetIPString()); + else #endif - if (dest->GetProtocolFamily() == AF_INET) b = cu->Cloak4(dest->GetIPString()); } diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 524edb8a5..a00fc6733 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -72,7 +72,7 @@ class ModuleConnectBan : public Module int range = 32; clonemap::iterator i; - switch (u->GetProtocolFamily()) + switch (u->ip.sa.sa_family) { case AF_INET6: range = ipv6_cidr; diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 40f8e18ab..5b155e188 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -157,10 +157,7 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque &pa if (params[8][0] != '+') params[8] = "+" + params[8]; - if (params[6].find_first_of(":") != std::string::npos) - _new->SetSockAddr(AF_INET6, params[6].c_str(), 0); - else - _new->SetSockAddr(AF_INET, params[6].c_str(), 0); + _new->SetSockAddr(params[6].c_str(), 0); ServerInstance->Users->AddGlobalClone(_new); -- cgit v1.2.3