summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/bancache.h4
-rw-r--r--include/u_listmode.h6
-rw-r--r--src/bancache.cpp4
-rw-r--r--src/commands/cmd_invite.cpp2
-rw-r--r--src/dns.cpp2
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/modules/extra/m_sqllog.cpp9
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp2
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp2
-rw-r--r--src/modules/extra/m_testclient.cpp2
-rw-r--r--src/modules/m_callerid.cpp2
-rw-r--r--src/modules/m_joinflood.cpp10
-rw-r--r--src/modules/m_kicknorejoin.cpp4
-rw-r--r--src/modules/m_messageflood.cpp16
-rw-r--r--src/modules/m_nickflood.cpp10
-rw-r--r--src/modules/m_randquote.cpp2
-rw-r--r--src/modules/m_spanningtree/handshaketimer.cpp2
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.cpp2
-rw-r--r--src/modules/m_timedbans.cpp2
-rw-r--r--src/socketengine.cpp6
-rw-r--r--src/users.cpp6
22 files changed, 53 insertions, 46 deletions
diff --git a/include/bancache.h b/include/bancache.h
index b6e037f79..7771feb75 100644
--- a/include/bancache.h
+++ b/include/bancache.h
@@ -45,7 +45,7 @@ class CoreExport BanCacheHit : public classbase
this->Type = type;
this->Reason = reason;
this->IP = ip;
- this->Expiry = time(NULL) + 86400; // a day. this might seem long, but entries will be removed as glines/etc expire.
+ this->Expiry = ServerInstance->Time() + 86400; // a day. this might seem long, but entries will be removed as glines/etc expire.
}
// overridden to allow custom time
@@ -55,7 +55,7 @@ class CoreExport BanCacheHit : public classbase
this->Type = type;
this->Reason = reason;
this->IP = ip;
- this->Expiry = time(NULL) + seconds;
+ this->Expiry = ServerInstance->Time() + seconds;
}
};
diff --git a/include/u_listmode.h b/include/u_listmode.h
index 358ccbf83..6e654f64f 100644
--- a/include/u_listmode.h
+++ b/include/u_listmode.h
@@ -16,10 +16,10 @@
/** Get the time as a string
*/
-inline std::string stringtime()
+inline std::string stringtime(InspIRCd* Instance)
{
std::ostringstream TIME;
- TIME << time(NULL);
+ TIME << Instance->Time();
return TIME.str();
}
@@ -331,7 +331,7 @@ class ListModeBase : public ModeHandler
ListItem e;
e.mask = parameter;
e.nick = servermode ? ServerInstance->Config->ServerName : source->nick;
- e.time = stringtime();
+ e.time = stringtime(ServerInstance);
el->push_back(e);
return MODEACTION_ALLOW;
diff --git a/src/bancache.cpp b/src/bancache.cpp
index 826244b55..9fe70cb41 100644
--- a/src/bancache.cpp
+++ b/src/bancache.cpp
@@ -50,7 +50,7 @@ BanCacheHit *BanCacheManager::GetHit(const std::string &ip)
return NULL; // free and safe
else
{
- if (time(NULL) > i->second->Expiry)
+ if (ServerInstance->Time() > i->second->Expiry)
{
ServerInstance->Logs->Log("BANCACHE", DEBUG, "Hit on " + ip + " is out of date, removing!");
RemoveHit(i->second);
@@ -137,7 +137,7 @@ void BanCacheManager::RehashCache()
/* Safe to delete items here through iterator 'n' */
BanCacheHit *b = n->second;
- if (time(NULL) > b->Expiry)
+ if (ServerInstance->Time() > b->Expiry)
{
/* we need to remove this one. */
delete b;
diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp
index ac9ad08f9..1a70fbe0e 100644
--- a/src/commands/cmd_invite.cpp
+++ b/src/commands/cmd_invite.cpp
@@ -33,7 +33,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
if (parameters.size() == 3)
{
if (IS_LOCAL(user))
- timeout = time(NULL) + ServerInstance->Duration(parameters[2]);
+ timeout = ServerInstance->Time() + ServerInstance->Duration(parameters[2]);
else
timeout = ConvToInt(parameters[2]);
}
diff --git a/src/dns.cpp b/src/dns.cpp
index 63b523bfd..85d620982 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -126,7 +126,7 @@ class RequestTimeout : public Timer
DNSRequest* watch;
int watchid;
public:
- RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, time(NULL)), ServerInstance(SI), watch(watching), watchid(id)
+ RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, SI->Time()), ServerInstance(SI), watch(watching), watchid(id)
{
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 518b1b5bb..c0391b679 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -443,6 +443,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
this->Modes = 0;
this->Res = 0;
+ // Initialise TIME
+ this->TIME = time(NULL);
memset(&server, 0, sizeof(server));
memset(&client, 0, sizeof(client));
diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp
index e57e40354..a3f995355 100644
--- a/src/modules/extra/m_sqllog.cpp
+++ b/src/modules/extra/m_sqllog.cpp
@@ -28,6 +28,8 @@ std::map<unsigned long,QueryInfo*> active_queries;
class QueryInfo
{
+private:
+ InspIRCd* ServerInstance;
public:
QueryState qs;
unsigned long id;
@@ -41,8 +43,9 @@ public:
time_t date;
bool insert;
- QueryInfo(const std::string &n, const std::string &s, const std::string &h, unsigned long i, int cat)
+ QueryInfo(InspIRCd* Instance, const std::string &n, const std::string &s, const std::string &h, unsigned long i, int cat)
{
+ ServerInstance = Instance;
qs = FIND_SOURCE;
nick = n;
source = s;
@@ -50,7 +53,7 @@ public:
id = i;
category = cat;
sourceid = nickid = hostid = -1;
- date = time(NULL);
+ date = ServerInstance->Time();
insert = false;
}
@@ -250,7 +253,7 @@ class ModuleSQLLog : public Module
SQLrequest req = SQLrequest(this, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % source);
if(req.Send())
{
- QueryInfo* i = new QueryInfo(nick, source, host, req.id, category);
+ QueryInfo* i = new QueryInfo(ServerInstance, nick, source, host, req.id, category);
i->qs = FIND_SOURCE;
active_queries[req.id] = i;
}
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index adbd48fb6..cd0af7e8b 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -903,7 +903,7 @@ class ModuleSSLGnuTLS : public Module
/* Beware here we do not check for errors.
*/
- if ((gnutls_x509_crt_get_expiration_time(cert) < time(0)) || (gnutls_x509_crt_get_activation_time(cert) > time(0)))
+ if ((gnutls_x509_crt_get_expiration_time(cert) < ServerInstance->Time()) || (gnutls_x509_crt_get_activation_time(cert) > ServerInstance->Time()))
{
certinfo->data.insert(std::make_pair("error","Not activated, or expired certificate"));
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 389fffb85..796db66d7 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -871,7 +871,7 @@ class ModuleSSLOpenSSL : public Module
certinfo->data.insert(std::make_pair("fingerprint",irc::hex(md, n)));
}
- if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), time(NULL)) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), time(NULL)) == 0))
+ if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), ServerInstance->Time()) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), ServerInstance->Time()) == 0))
{
certinfo->data.insert(std::make_pair("error","Not activated, or expired certificate"));
}
diff --git a/src/modules/extra/m_testclient.cpp b/src/modules/extra/m_testclient.cpp
index c5c07efc0..d80070939 100644
--- a/src/modules/extra/m_testclient.cpp
+++ b/src/modules/extra/m_testclient.cpp
@@ -40,7 +40,7 @@ public:
if(target)
{
SQLrequest foo = SQLrequest(this, target, "foo",
- SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % time(NULL));
+ SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % ServerInstance->Time());
if(foo.Send())
{
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 0204ee77f..d8e50b280 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -338,7 +338,7 @@ public:
if (i == dat->accepting.end())
{
- time_t now = time(NULL);
+ time_t now = ServerInstance->Time();
/* +g and *not* accepted */
user->WriteNumeric(716, "%s %s :is in +g mode (server-side ignore).", user->nick.c_str(), dest->nick.c_str());
if (now > (dat->lastnotify + (time_t)notify_cooldown))
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index 33ba98aa4..40a007c2c 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -33,7 +33,7 @@ class joinfloodsettings : public classbase
joinfloodsettings(int b, int c) : secs(b), joins(c)
{
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
counter = 0;
locked = false;
};
@@ -41,10 +41,10 @@ class joinfloodsettings : public classbase
void addjoin()
{
counter++;
- if (time(NULL) > reset)
+ if (ServerInstance->Time() > reset)
{
counter = 0;
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
}
}
@@ -62,7 +62,7 @@ class joinfloodsettings : public classbase
{
if (locked)
{
- if (time(NULL) > unlocktime)
+ if (ServerInstance->Time() > unlocktime)
{
locked = false;
return false;
@@ -78,7 +78,7 @@ class joinfloodsettings : public classbase
void lock()
{
locked = true;
- unlocktime = time(NULL) + 60;
+ unlocktime = ServerInstance->Time() + 60;
}
};
diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp
index cd027f089..bf5e10595 100644
--- a/src/modules/m_kicknorejoin.cpp
+++ b/src/modules/m_kicknorejoin.cpp
@@ -141,7 +141,7 @@ public:
for (delaylist::iterator iter = dl->begin(); iter != dl->end(); iter++)
{
- if (iter->second > time(NULL))
+ if (iter->second > ServerInstance->Time())
{
if (iter->first == user)
{
@@ -180,7 +180,7 @@ public:
dl = new delaylist;
chan->Extend("norejoinusers", dl);
}
- (*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J'));
+ (*dl)[user] = ServerInstance->Time() + strtoint(chan->GetModeParameter('J'));
}
}
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index c374c5346..53df408f6 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -19,6 +19,8 @@
*/
class floodsettings : public classbase
{
+ private:
+ InspIRCd *ServerInstance;
public:
bool ban;
int secs;
@@ -26,10 +28,10 @@ class floodsettings : public classbase
time_t reset;
std::map<User*,int> counters;
- floodsettings() : ban(0), secs(0), lines(0) {};
- floodsettings(bool a, int b, int c) : ban(a), secs(b), lines(c)
+ floodsettings(InspIRCd *Instance) : ServerInstance(Instance), ban(0), secs(0), lines(0) {};
+ floodsettings(InspIRCd *Instance, bool a, int b, int c) : ServerInstance(Instance), ban(a), secs(b), lines(c)
{
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
};
void addmessage(User* who)
@@ -43,10 +45,10 @@ class floodsettings : public classbase
{
counters[who] = 1;
}
- if (time(NULL) > reset)
+ if (ServerInstance->Time() > reset)
{
counters.clear();
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
}
}
@@ -140,7 +142,7 @@ class MsgFlood : public ModeHandler
if (!channel->GetExt("flood", f))
{
parameter = std::string(ban ? "*" : "") + ConvToStr(nlines) + ":" +ConvToStr(nsecs);
- floodsettings *fs = new floodsettings(ban,nsecs,nlines);
+ floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines);
channel->Extend("flood",fs);
channel->SetMode('f', true);
channel->SetModeParam('f', parameter.c_str(), true);
@@ -160,7 +162,7 @@ class MsgFlood : public ModeHandler
if ((((nlines != f->lines) || (nsecs != f->secs) || (ban != f->ban))) && (((nsecs > 0) && (nlines > 0))))
{
delete f;
- floodsettings *fs = new floodsettings(ban,nsecs,nlines);
+ floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines);
channel->Shrink("flood");
channel->Extend("flood",fs);
channel->SetModeParam('f', cur_param.c_str(), false);
diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp
index 72e2831da..4961e97a0 100644
--- a/src/modules/m_nickflood.cpp
+++ b/src/modules/m_nickflood.cpp
@@ -33,7 +33,7 @@ class nickfloodsettings : public classbase
nickfloodsettings(int b, int c) : secs(b), nicks(c)
{
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
counter = 0;
locked = false;
};
@@ -41,10 +41,10 @@ class nickfloodsettings : public classbase
void addnick()
{
counter++;
- if (time(NULL) > reset)
+ if (ServerInstance->Time() > reset)
{
counter = 0;
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
}
}
@@ -62,7 +62,7 @@ class nickfloodsettings : public classbase
{
if (locked)
{
- if (time(NULL) > unlocktime)
+ if (ServerInstance->Time() > unlocktime)
{
locked = false;
return false;
@@ -78,7 +78,7 @@ class nickfloodsettings : public classbase
void lock()
{
locked = true;
- unlocktime = time(NULL) + 60;
+ unlocktime = ServerInstance->Time() + 60;
}
};
diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp
index c03b2777a..8092d5162 100644
--- a/src/modules/m_randquote.cpp
+++ b/src/modules/m_randquote.cpp
@@ -64,7 +64,7 @@ class ModuleRandQuote : public Module
conf = new ConfigReader(ServerInstance);
// Sort the Randomizer thingie..
- srand(time(NULL));
+ srand(ServerInstance->Time());
q_file = conf->ReadValue("randquote","file",0);
prefix = conf->ReadValue("randquote","prefix",0);
diff --git a/src/modules/m_spanningtree/handshaketimer.cpp b/src/modules/m_spanningtree/handshaketimer.cpp
index 44938bafa..facbf6c30 100644
--- a/src/modules/m_spanningtree/handshaketimer.cpp
+++ b/src/modules/m_spanningtree/handshaketimer.cpp
@@ -27,7 +27,7 @@
/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
-HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay) : Timer(delay, time(NULL)), Instance(Inst), sock(s), lnk(l), Utils(u)
+HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay) : Timer(delay, Inst->Time()), Instance(Inst), sock(s), lnk(l), Utils(u)
{
thefd = sock->GetFd();
}
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index c3167b9b3..a286150b2 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -67,7 +67,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
bursting = false;
VersionString.clear();
ServerUserCount = ServerOperCount = 0;
- this->SetNextPingTime(time(NULL) + Utils->PingFreq);
+ this->SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
this->SetPingFlag();
Warned = DupError = false;
StartBurst = rtt = 0;
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 48d829f6f..06851619c 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -536,7 +536,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
}
- L.NextConnectTime = time(NULL) + L.AutoConnect;
+ L.NextConnectTime = ServerInstance->Time() + L.AutoConnect;
if (L.Name.find('.') == std::string::npos)
throw CoreException("The link name '"+assign(L.Name)+"' is invalid and must contain at least one '.' character");
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index a10f90819..5e0650a3d 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -64,7 +64,7 @@ class CommandTban : public Command
TimedBan T;
std::string channelname = parameters[0];
long duration = ServerInstance->Duration(parameters[1]);
- unsigned long expire = duration + time(NULL);
+ unsigned long expire = duration + ServerInstance->Time();
if (duration < 1)
{
user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid ban time");
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 0a0717964..300a08bcc 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -96,7 +96,7 @@ void SocketEngine::WantWrite(EventHandler* eh)
SocketEngine::SocketEngine(InspIRCd* Instance) : ServerInstance(Instance)
{
TotalEvents = WriteEvents = ReadEvents = ErrorEvents = 0;
- lastempty = time(NULL);
+ lastempty = ServerInstance->Time();
indata = outdata = 0;
}
@@ -263,9 +263,9 @@ void SocketEngine::RecoverFromFork()
void SocketEngine::UpdateStats(size_t len_in, size_t len_out)
{
- if (lastempty != time(NULL))
+ if (lastempty != ServerInstance->Time())
{
- lastempty = time(NULL);
+ lastempty = ServerInstance->Time();
indata = outdata = 0;
}
indata += len_in;
diff --git a/src/users.cpp b/src/users.cpp
index 848f2a1eb..0a196d798 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -398,7 +398,7 @@ const std::string& User::GetFullRealHost()
bool User::IsInvited(const irc::string &channel)
{
- time_t now = time(NULL);
+ time_t now = ServerInstance->Time();
InvitedList::iterator safei;
for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
{
@@ -420,7 +420,7 @@ bool User::IsInvited(const irc::string &channel)
InvitedList* User::GetInviteList()
{
- time_t now = time(NULL);
+ time_t now = ServerInstance->Time();
/* Weed out expired invites here. */
InvitedList::iterator safei;
for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
@@ -438,7 +438,7 @@ InvitedList* User::GetInviteList()
void User::InviteTo(const irc::string &channel, time_t invtimeout)
{
- time_t now = time(NULL);
+ time_t now = ServerInstance->Time();
if (invtimeout != 0 && now > invtimeout) return; /* Don't add invites that are expired from the get-go. */
for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
{