diff options
Diffstat (limited to 'src/modules/m_spanningtree.cpp')
-rw-r--r-- | src/modules/m_spanningtree.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index d2e583d39..2577bdb18 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -1690,6 +1690,45 @@ class TreeSocket : public InspSocket } return true; } + + bool Time(std::string prefix, std::deque<std::string> ¶ms) + { + // :source.server TIME remote.server sendernick + // :remote.server TIME source.server sendernick TS + if (params.size() == 2) + { + // someone querying our time? + if (Srv->MatchText(Srv->GetServerName(),params[0])) + { + userrec* u = Srv->FindNick(params[1]); + if (u) + { + char curtime[256]; + snprintf(curtime,256,"%lu",(unsigned long)time(NULL)); + params.push_back(curtime); + params[0] = prefix; + DoOneToOne(Srv->GetServerName(),"TIME",params,u->server); + } + } + } + else if (params.size() == 3) + { + // a response to a previous TIME + userrec* u = Srv->FindNick(params[1]); + if ((u) && (IS_LOCAL(u))) + { + time_t rawtime = atol(params[2]); + struct tm * timeinfo; + timeinfo = localtime(&rawtime); + WriteServ(u->fd,"391 %s %s :%s",u->nick,source,asctime(timeinfo)); + } + else + { + DoOneToOne(source,"TIME",params,u->server); + } + } + return true; + } bool LocalPing(std::string prefix, std::deque<std::string> ¶ms) { @@ -2144,6 +2183,10 @@ class TreeSocket : public InspSocket { return this->Push(prefix,params); } + else if (command == "TIME") + { + return this->Time(prefix,params); + } else if (command == "SVSJOIN") { if (prefix == "") |