Author: Isomer <isomer@coders.net>
[ircu2.10.12-pk.git] / ircd / m_create.c
index c3d537bf9a6c8058c36d6b04440fc4901ace6a45..0892850310806d99df600626469ae41d9171ee3a 100644 (file)
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
+#include "config.h"
+
 #include "channel.h"
 #include "client.h"
 #include "hash.h"
@@ -97,6 +91,8 @@
 #include "numeric.h"
 #include "numnicks.h"
 #include "s_debug.h"
+#include "s_misc.h"
+#include "s_user.h"
 #include "send.h"
 
 #include <assert.h>
@@ -117,14 +113,12 @@ int ms_create(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   struct ModeBuf mbuf; /* a mode buffer */
   int badop; /* a flag */
 
-  if (IsServer(sptr)) {
-    Debug((DEBUG_ERROR, "%s tried to CREATE a channel", sptr->name));
-    return 0;
-  }
+  if (IsServer(sptr))
+    return protocol_violation(sptr,"%s tried to CREATE a channel", cli_name(sptr));
 
   /* sanity checks: Only accept CREATE messages from servers */
-  if (!IsServer(cptr) || parc < 3 || *parv[2] == '\0')
-    return 0;
+  if (parc < 3 || *parv[2] == '\0')
+    return need_more_params(sptr,"CREATE");
 
   chanTS = atoi(parv[2]);
 
@@ -136,7 +130,18 @@ int ms_create(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    */
   if (!IsBurstOrBurstAck(sptr) && 0 != chanTS &&
       MAGIC_REMOTE_JOIN_TS != chanTS)
-    sptr->user->server->serv->lag = TStime() - chanTS;
+    cli_serv(cli_user(sptr)->server)->lag = TStime() - chanTS;
+
+  /* If this server is >1 minute fast, warn */
+  if (TStime() - chanTS<-60) {
+    static int rate;
+    sendto_opmask_butone_ratelimited(0,SNO_NETWORK,&rate,
+       "Timestamp drift from %s (%is)",cli_name(cptr),chanTS-TStime());
+
+    /* If this server is >5 minutes fast, squit it */
+    if (TStime() - chanTS<-5*60*60)
+      return exit_client(sptr, sptr, &me, "Timestamp Drift/Bogus TS");
+  }
 
   /* For each channel in the comma seperated list: */
   for (name = ircd_strtok(&p, parv[1], ","); name;