Apply minor fixes from patches@, SF tracker, and others.
[ircu2.10.12-pk.git] / ircd / s_misc.c
index 62a3372acd22ddbb858e8da41ed288840ebc05b0..e2f56ae57615d323c403461117bdbca7668ceb25 100644 (file)
@@ -31,8 +31,9 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_auth.h"
+#include "ircd_features.h"
 #include "ircd_log.h"
-#include "ircd_policy.h"
 #include "ircd_reply.h"
 #include "ircd_snprintf.h"
 #include "ircd_string.h"
@@ -47,6 +48,7 @@
 #include "s_bsd.h"
 #include "s_conf.h"
 #include "s_debug.h"
+#include "s_stats.h"
 #include "s_user.h"
 #include "send.h"
 #include "struct.h"
@@ -54,7 +56,6 @@
 #include "sys.h"
 #include "uping.h"
 #include "userload.h"
-#include "map.h"
 
 #include <assert.h>
 #include <fcntl.h>
@@ -170,7 +171,8 @@ const char* get_client_name(const struct Client* sptr, int showip)
   if (MyConnect(sptr)) {
     if (showip)
       ircd_snprintf(0, nbuf, sizeof(nbuf), "%s[%s@%s]", cli_name(sptr),
-            (IsIdented(sptr)) ? cli_username(sptr) : "", cli_sock_ip(sptr));
+                    IsIdented(sptr) ? cli_username(sptr) : "unknown",
+                    cli_sock_ip(sptr));
     else
         return cli_name(sptr);
     return nbuf;
@@ -294,6 +296,8 @@ static void exit_one_client(struct Client* bcptr, const char* comment)
     assert(!IsServer(bcptr));
     /* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */
     RemoveYXXClient(cli_user(bcptr)->server, cli_yxx(bcptr));
+    if (IsIAuthed(bcptr) || cli_iauth(bcptr))
+        iauth_exit_client(bcptr);
   }
 
   /* Remove bcptr from the client list */
@@ -390,17 +394,29 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
 
   char comment1[HOSTLEN + HOSTLEN + 2];
   assert(killer);
-  if (MyConnect(victim)) {
-    cli_flags(victim) |= FLAGS_CLOSING;
+  if (MyConnect(victim))
+  {
+    SetFlag(victim, FLAG_CLOSING);
+
+    if (feature_bool(FEAT_CONNEXIT_NOTICES) && IsUser(victim))
+      sendto_opmask_butone(0, SNO_CONNEXIT,
+                           "Client exiting: %s (%s@%s) [%s] [%s] <%s%s>",
+                           cli_name(victim), cli_user(victim)->username,
+                           cli_user(victim)->host, comment,
+                           ircd_ntoa((const char*) &(cli_ip(victim))),
+                           NumNick(victim) /* two %s's */);
     update_load();
 
     on_for = CurrentTime - cli_firsttime(victim);
 
     if (IsUser(victim))
-      log_write(LS_USER, L_TRACE, 0, "%s (%3d:%02d:%02d): %s@%s (%s)",
-               myctime(cli_firsttime(victim)), on_for / 3600,
-               (on_for % 3600) / 60, on_for % 60, cli_user(victim)->username,
-               cli_sockhost(victim), cli_name(victim));
+      log_write(LS_USER, L_TRACE, 0, "%Tu %i %s@%s %s %s %s%s %s :%s",
+               cli_firsttime(victim), on_for,
+               cli_user(victim)->username, cli_sockhost(victim),
+                ircd_ntoa((const char*) &(cli_ip(victim))),
+                IsAccount(victim) ? cli_username(victim) : "0",
+                NumNick(victim), /* two %s's */
+                cli_name(victim), cli_info(victim));
 
     if (victim != cli_from(killer)  /* The source knows already */
         && IsClient(victim))    /* Not a Ping struct or Log file */
@@ -456,13 +472,15 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
 
   if (IsServer(victim))
   {
-#ifdef HEAD_IN_SAND_NETSPLIT
-    strcpy(comment1, "*.net *.split");
-#else
-    strcpy(comment1, cli_name(cli_serv(victim)->up));
-    strcat(comment1, " ");
-    strcat(comment1, cli_name(victim));
-#endif
+    if (feature_bool(FEAT_HIS_NETSPLIT))
+      strcpy(comment1, "*.net *.split");
+    else
+    {
+      strcpy(comment1, cli_name(cli_serv(victim)->up));
+      strcat(comment1, " ");
+      strcat(comment1, cli_name(victim));
+    }
+
     if (IsUser(killer))
       sendto_opmask_butone(killer, SNO_OLDSNO, "%s SQUIT by %s [%s]:",
                           (cli_user(killer)->server == victim ||
@@ -478,20 +496,17 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
                         cli_serv(victim)->up, victim, comment);
   }
 
-#ifdef HEAD_IN_SAND_MAP    
-  map_update(victim);
-#endif
-
   /*
    * First generate the needed protocol for the other server links
    * except the source:
    */
   for (dlp = cli_serv(&me)->down; dlp; dlp = dlp->next) {
-    if (dlp->value.cptr != cli_from(killer) && dlp->value.cptr != victim) {
+    if (dlp->value.cptr != cli_from(killer) && dlp->value.cptr != victim)
+    {
       if (IsServer(victim))
        sendcmdto_one(killer, CMD_SQUIT, dlp->value.cptr, "%s %Tu :%s",
                      cli_name(victim), cli_serv(victim)->timestamp, comment);
-      else if (IsUser(victim) && 0 == (cli_flags(victim) & FLAGS_KILLED))
+      else if (IsUser(victim) && !HasFlag(victim, FLAG_KILLED))
        sendcmdto_one(victim, CMD_QUIT, dlp->value.cptr, ":%s", comment);
     }
   }
@@ -536,7 +551,7 @@ void initstats(void)
   memset(&ircst, 0, sizeof(ircst));
 }
 
-void tstats(struct Client *cptr, char *name)
+void tstats(struct Client *cptr, struct StatDesc *sd, int stat, char *param)
 {
   struct Client *acptr;
   int i;