From cf2b0d0e480c5b88dddf8905101815161e33f0da Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 11 Feb 2006 17:51:06 +0000 Subject: Added remote TIME (do not use yet) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3156 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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 ¶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 ¶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 == "") -- cgit v1.2.3