diff options
-rw-r--r-- | include/sockets.h | 3 | ||||
-rw-r--r-- | modules/commands/os_session.cpp | 2 | ||||
-rw-r--r-- | src/sockets.cpp | 10 |
3 files changed, 13 insertions, 2 deletions
diff --git a/include/sockets.h b/include/sockets.h index 8b7b78a7f..93afe2ec5 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -54,6 +54,9 @@ union CoreExport sockaddrs */ Anope::string addr() const; + /* Is this address ipv6? */ + bool ipv6() const; + /** Check if this sockaddr has data in it */ bool operator()() const; diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 71f6a8401..7b0ee1fb1 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -699,7 +699,7 @@ class OSSession : public Module ++session->hits; if (max_session_kill && session->hits >= max_session_kill && akills) { - const Anope::string &akillmask = "*@" + u->ip; + const Anope::string &akillmask = "*@" + session->addr.mask(); XLine *x = new XLine(akillmask, OperServ ? OperServ->nick : "", Anope::CurTime + session_autokill_expiry, "Session limit exceeded", XLineManager::GenerateUID()); akills->AddXLine(x); akills->Send(NULL, x); diff --git a/src/sockets.cpp b/src/sockets.cpp index e3065a1e8..3ce6c8eac 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -91,6 +91,11 @@ Anope::string sockaddrs::addr() const return ""; } +bool sockaddrs::ipv6() const +{ + return sa.sa_family == AF_INET6; +} + bool sockaddrs::operator()() const { return valid(); @@ -218,7 +223,10 @@ cidr::cidr(const Anope::string &ip, unsigned char len) Anope::string cidr::mask() const { - return Anope::printf("%s/%d", this->cidr_ip.c_str(), this->cidr_len); + if ((this->addr.ipv6() && this->cidr_len == 128) || (!this->addr.ipv6() && this->cidr_len == 32)) + return this->cidr_ip; + else + return Anope::printf("%s/%d", this->cidr_ip.c_str(), this->cidr_len); } bool cidr::match(const sockaddrs &other) |