summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xline.h1
-rw-r--r--modules/protocol/bahamut.cpp17
-rw-r--r--modules/protocol/hybrid.cpp18
-rw-r--r--modules/protocol/inspircd20.cpp27
-rw-r--r--modules/protocol/ngircd.cpp9
-rw-r--r--modules/protocol/ratbox.cpp9
-rw-r--r--modules/protocol/unreal.cpp18
-rw-r--r--src/xline.cpp6
8 files changed, 56 insertions, 49 deletions
diff --git a/include/xline.h b/include/xline.h
index 208bc0145..8f772fbe8 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -72,6 +72,7 @@ class CoreExport XLine : public Serialize::Object
const Anope::string &GetReal() const;
Anope::string GetReasonWithID();
+ bool IsExpired();
bool HasNickOrReal() const;
bool IsRegex();
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 211570ccb..0d9b22786 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -65,11 +65,11 @@ void bahamut::senders::Akill::Send(User* u, XLine* x)
}
}
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800)
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+ // Calculate the time left before this would expire
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->GetBy(), Anope::CurTime, x->GetReason());
}
@@ -194,10 +194,11 @@ void bahamut::senders::SQLineDel::Send(XLine* x)
void bahamut::senders::SZLine::Send(User*, XLine* x)
{
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+
+ // Calculate the time left before this would expire
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
/* this will likely fail so its only here for legacy */
Uplink::Send("SZLINE", x->GetHost(), x->GetReason());
/* this is how we are supposed to deal with it */
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index 76cad6fd3..d65a6c45f 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -62,12 +62,11 @@ void hybrid::senders::Akill::Send(User* u, XLine* x)
x->GetMask(), u->GetMask(), u->realname, old->GetMask());
}
- /* Calculate the time left before this would expire, capping it at 2 days */
- time_t timeleft = x->GetExpires() - Anope::CurTime;
-
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+ /* Calculate the time left before this would expire */
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
Uplink::Send(Config->GetClient("OperServ"), "KLINE", timeleft, x->GetUser(), x->GetHost(), x->GetReason());
}
@@ -173,12 +172,11 @@ void hybrid::senders::SQLineDel::Send(XLine* x)
void hybrid::senders::SZLine::Send(User*, XLine* x)
{
- /* Calculate the time left before this would expire, capping it at 2 days */
- time_t timeleft = x->GetExpires() - Anope::CurTime;
-
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+ /* Calculate the time left before this would expire */
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
Uplink::Send(Config->GetClient("OperServ"), "DLINE", "*", timeleft, x->GetHost(), x->GetReason());
}
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 774d214c6..6fce47af8 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -39,10 +39,11 @@ static unsigned int spanningtree_proto_ver = 0;
void inspircd20::senders::Akill::Send(User* u, XLine* x)
{
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+
+ // Calculate the time left before this would expire
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
/* InspIRCd may support regex bans, if they do we can send this and forget about it */
if (x->IsRegex() && Servers::Capab.count("RLINE"))
@@ -218,10 +219,11 @@ void inspircd20::senders::MessageServer::Send(Server* server)
void inspircd20::senders::SQLine::Send(User*, XLine* x)
{
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+
+ // Calculate the time left before this would expire
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
proto->SendAddLine("Q", x->GetMask(), timeleft, x->GetBy(), x->GetReason());
}
@@ -247,10 +249,11 @@ void inspircd20::senders::SQuit::Send(Server *s, const Anope::string &message)
void inspircd20::senders::SZLine::Send(User*, XLine* x)
{
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+
+ // Calculate the time left before this would expire
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
proto->SendAddLine("Z", x->GetHost(), timeleft, x->GetBy(), x->GetReason());
}
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index bbb594ff8..1c95b3942 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -26,10 +26,11 @@
void ngircd::senders::Akill::Send(User* u, XLine* x)
{
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+
+ // Calculate the time left before this would expire
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
Uplink::Send(Me, "GLINE", x->GetMask(), timeleft, x->GetReason() + " (" + x->GetBy() + ")");
}
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 4541419b7..f8a6d979c 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -46,12 +46,11 @@ void ratbox::senders::Logout::Send(User *u)
void ratbox::senders::SQLine::Send(User*, XLine* x)
{
- /* Calculate the time left before this would expire, capping it at 2 days */
- time_t timeleft = x->GetExpires() - Anope::CurTime;
-
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
+ if (x->IsExpired())
+ return;
+ /* Calculate the time left before this would expire */
+ time_t timeleft = x->GetExpires() > 0 ? x->GetExpires() - Anope::CurTime : 0;
#warning "find introduced"
// Uplink::Send(FindIntroduced(), "ENCAP", "*", "RESV", timeleft, x->GetMask(), 0, x->GetReason());
}
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index bf4a6a8a8..0ccbc4008 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -73,11 +73,10 @@ void unreal::senders::Akill::Send(User* u, XLine* x)
}
}
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
- Uplink::Send("TKL", "+", "G", x->GetUser(), x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason());
+ if (x->IsExpired())
+ return;
+
+ Uplink::Send("TKL", "+", "G", x->GetUser(), x->GetHost(), x->GetBy(), x->GetExpires(), x->GetCreated(), x->GetReason());
}
void unreal::senders::AkillDel::Send(XLine* x)
@@ -209,11 +208,10 @@ void unreal::senders::SQLineDel::Send(XLine* x)
void unreal::senders::SZLine::Send(User*, XLine* x)
{
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->GetExpires() - Anope::CurTime;
- if (timeleft > 172800 || !x->GetExpires())
- timeleft = 172800;
- Uplink::Send("TKL", "+", "Z", "*", x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason());
+ if (x->IsExpired())
+ return;
+
+ Uplink::Send("TKL", "+", "Z", "*", x->GetHost(), x->GetBy(), x->GetExpires(), x->GetCreated(), x->GetReason());
}
void unreal::senders::SZLineDel::Send(XLine* x)
diff --git a/src/xline.cpp b/src/xline.cpp
index c64761297..d0e058f09 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -199,6 +199,12 @@ Anope::string XLine::GetReasonWithID()
return r;
}
+bool XLine::IsExpired()
+{
+ time_t expires = GetExpires();
+ return expires > 0 && expires <= Anope::CurTime;
+}
+
bool XLine::HasNickOrReal() const
{
return !this->GetNick().empty() || !this->GetReal().empty();