added gnutls backend and moved backend code into new files
[ircu2.10.12-pk.git] / ircd / m_pong.c
index f66668d41432de98867ce68ad0b8b61a4081e57f..df29b9f6714ace850041b1f669e08094c62e2226 100644 (file)
@@ -91,6 +91,7 @@
 #include "numeric.h"
 #include "numnicks.h"
 #include "opercmds.h"
+#include "s_auth.h"
 #include "s_user.h"
 #include "send.h"
 
@@ -118,8 +119,8 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   }
   origin      = parv[1];
   destination = parv[2];
-  ClrFlag(cptr, FLAG_PINGSENT);
-  ClrFlag(sptr, FLAG_PINGSENT);
+  ClearPingSent(cptr);
+  ClearPingSent(sptr);
   cli_lasttime(cptr) = CurrentTime;
 
   if (parc > 5)
@@ -128,6 +129,7 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     cli_serv(cptr)->asll_rtt = atoi(militime_float(parv[3]));
     cli_serv(cptr)->asll_to = atoi(parv[4]);
     cli_serv(cptr)->asll_from = atoi(militime_float(parv[5]));
+    cli_serv(cptr)->asll_last = CurrentTime;
     return 0;
   }
   
@@ -161,27 +163,8 @@ int mr_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   assert(cptr == sptr);
   assert(!IsRegistered(sptr));
 
-  ClrFlag(cptr, FLAG_PINGSENT);
-  cli_lasttime(cptr) = CurrentTime;
-  /*
-   * Check to see if this is a PONG :cookie reply from an
-   * unregistered user.  If so, process it. -record
-   */
-  if (0 != cli_cookie(sptr) && COOKIE_VERIFIED != cli_cookie(sptr)) {
-    if (parc > 1 && cli_cookie(sptr) == atol(parv[parc - 1])) {
-      cli_cookie(sptr) = COOKIE_VERIFIED;
-      cli_unreg(sptr) &= ~CLIREG_COOKIE; /* cookie has been returned... */
-      if (!cli_unreg(sptr)) /* no more registration tasks... */
-        /*
-         * NICK and USER OK
-         */
-        return register_user(cptr, sptr, cli_name(sptr), cli_user(sptr)->username);
-    }
-    else  
-      send_reply(sptr, SND_EXPLICIT | ERR_BADPING,
-                ":To connect, type /QUOTE PONG %u", cli_cookie(sptr));
-  }
-  return 0;
+  ClearPingSent(cptr);
+  return (parc > 1) ? auth_set_pong(cli_auth(sptr), strtoul(parv[parc - 1], NULL, 10)) : 0;
 }
 
 /*
@@ -195,7 +178,8 @@ int m_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   assert(0 != cptr);
   assert(cptr == sptr);
-  ClrFlag(cptr, FLAG_PINGSENT);
+
+  ClearPingSent(cptr);
   cli_lasttime(cptr) = CurrentTime;
   return 0;
 }