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
this->Type = type;
this->Reason = reason;
this->IP = ip;
- this->Expiry = time(NULL) + seconds;
+ this->Expiry = ServerInstance->Time() + seconds;
}
};
/** 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();
}
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;
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);
/* 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;
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]);
}
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)
{
}
this->Modes = 0;
this->Res = 0;
+ // Initialise TIME
+ this->TIME = time(NULL);
memset(&server, 0, sizeof(server));
memset(&client, 0, sizeof(client));
class QueryInfo
{
+private:
+ InspIRCd* ServerInstance;
public:
QueryState qs;
unsigned long id;
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;
id = i;
category = cat;
sourceid = nickid = hostid = -1;
- date = time(NULL);
+ date = ServerInstance->Time();
insert = false;
}
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;
}
/* 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"));
}
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"));
}
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())
{
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))
joinfloodsettings(int b, int c) : secs(b), joins(c)
{
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
counter = 0;
locked = false;
};
void addjoin()
{
counter++;
- if (time(NULL) > reset)
+ if (ServerInstance->Time() > reset)
{
counter = 0;
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
}
}
{
if (locked)
{
- if (time(NULL) > unlocktime)
+ if (ServerInstance->Time() > unlocktime)
{
locked = false;
return false;
void lock()
{
locked = true;
- unlocktime = time(NULL) + 60;
+ unlocktime = ServerInstance->Time() + 60;
}
};
for (delaylist::iterator iter = dl->begin(); iter != dl->end(); iter++)
{
- if (iter->second > time(NULL))
+ if (iter->second > ServerInstance->Time())
{
if (iter->first == user)
{
dl = new delaylist;
chan->Extend("norejoinusers", dl);
}
- (*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J'));
+ (*dl)[user] = ServerInstance->Time() + strtoint(chan->GetModeParameter('J'));
}
}
*/
class floodsettings : public classbase
{
+ private:
+ InspIRCd *ServerInstance;
public:
bool ban;
int secs;
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)
{
counters[who] = 1;
}
- if (time(NULL) > reset)
+ if (ServerInstance->Time() > reset)
{
counters.clear();
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
}
}
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);
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);
nickfloodsettings(int b, int c) : secs(b), nicks(c)
{
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
counter = 0;
locked = false;
};
void addnick()
{
counter++;
- if (time(NULL) > reset)
+ if (ServerInstance->Time() > reset)
{
counter = 0;
- reset = time(NULL) + secs;
+ reset = ServerInstance->Time() + secs;
}
}
{
if (locked)
{
- if (time(NULL) > unlocktime)
+ if (ServerInstance->Time() > unlocktime)
{
locked = false;
return false;
void lock()
{
locked = true;
- unlocktime = time(NULL) + 60;
+ unlocktime = ServerInstance->Time() + 60;
}
};
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);
/* $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();
}
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;
}
- 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");
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");
SocketEngine::SocketEngine(InspIRCd* Instance) : ServerInstance(Instance)
{
TotalEvents = WriteEvents = ReadEvents = ErrorEvents = 0;
- lastempty = time(NULL);
+ lastempty = ServerInstance->Time();
indata = outdata = 0;
}
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;
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)
{
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)
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)
{