IPv6 support (hopefully with fewer future transition pains)
[ircu2.10.12-pk.git] / ircd / s_user.c
index ed641eb27f1ea32daa063c1aae4cb60c54202b8a..02571b0fb5933c1f7eff34e7e5c9ed269438850a 100644 (file)
@@ -32,6 +32,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_auth.h"
 #include "ircd_chattr.h"
 #include "ircd_features.h"
 #include "ircd_log.h"
@@ -363,7 +364,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
   short            digitgroups = 0;
   struct User*     user = cli_user(sptr);
   int              killreason;
-  char             ip_base64[8];
+  char             ip_base64[25];
 
   user->last = CurrentTime;
   parv[0] = cli_name(sptr);
@@ -375,6 +376,12 @@ int register_user(struct Client *cptr, struct Client *sptr,
     static time_t last_too_many2;
 
     assert(cptr == sptr);
+    if (!IsIAuthed(sptr)) {
+      if (iauth_active)
+        return iauth_start_client(iauth_active, sptr);
+      else
+        SetIAuthed(sptr);
+    }
     switch (conf_check_client(sptr))
     {
       case ACR_OK:
@@ -394,7 +401,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
                                get_client_name(sptr, SHOW_IP));
         }
         ++ServerStats->is_ref;
-        IPcheck_connect_fail(cli_ip(sptr));
+        IPcheck_connect_fail(&cli_ip(sptr));
         return exit_client(cptr, sptr, &me,
                            "Sorry, your connection class is full - try "
                            "again later or try another server");
@@ -413,7 +420,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
         /* Can this ever happen? */
       case ACR_BAD_SOCKET:
         ++ServerStats->is_ref;
-        IPcheck_connect_fail(cli_ip(sptr));
+        IPcheck_connect_fail(&cli_ip(sptr));
         return exit_client(cptr, sptr, &me, "Unknown error -- Try again");
     }
     ircd_strncpy(user->host, cli_sockhost(sptr), HOSTLEN);
@@ -540,7 +547,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
   if (MyConnect(sptr)) {
     cli_handler(sptr) = CLIENT_HANDLER;
     release_dns_reply(sptr);
-
+    SetLocalNumNick(sptr);
     send_reply(sptr,
                RPL_WELCOME,
                feature_str(FEAT_NETWORK),
@@ -563,7 +570,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
       set_snomask(sptr, cli_snomask(sptr) & SNO_NOISY, SNO_ADD);
     if (feature_bool(FEAT_CONNEXIT_NOTICES))
       sendto_opmask_butone(0, SNO_CONNEXIT,
-                           "Client connecting: %s (%s@%s) [%s] {%d} [%s] <%s%s>",
+                           "Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s%s>",
                            cli_name(sptr), user->username, user->host,
                            cli_sock_ip(sptr), get_client_class(sptr),
                            cli_info(sptr), NumNick(cptr) /* two %s's */);
@@ -623,9 +630,9 @@ int register_user(struct Client *cptr, struct Client *sptr,
                        nick, cli_hopcount(sptr) + 1, cli_lastnick(sptr),
                        user->username, user->realhost,
                        *tmpstr ? "+" : "", tmpstr, *tmpstr ? " " : "",
-                       inttobase64(ip_base64, ntohl(cli_ip(sptr).s_addr), 6),
+                       iptobase64(ip_base64, &cli_ip(sptr), sizeof(ip_base64)),
                        NumNick(sptr), cli_info(sptr));
-  
+
   /* Send server notice mask to client */
   if (MyUser(sptr) && (cli_snomask(sptr) != SNO_DEFAULT) && HasFlag(sptr, FLAG_SERVNOTICE))
     send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
@@ -700,7 +707,7 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
     /*
      * IP# of remote client
      */
-    cli_ip(new_client).s_addr = htonl(base64toint(parv[parc - 3]));
+    base64toip(parv[parc - 3], &cli_ip(new_client));
 
     add_client_to_list(new_client);
     hAddClient(new_client);
@@ -804,7 +811,6 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
       cli_user(sptr) = make_user(sptr);
       cli_user(sptr)->server = &me;
     }
-    SetLocalNumNick(sptr);
     hAddClient(sptr);
 
     /*
@@ -1107,14 +1113,14 @@ hide_hostmask(struct Client *cptr, unsigned int flag)
         && (chan->channel->mode.mode & MODE_DELJOINS))
       SetDelayedJoin(chan);
     else
-      sendcmdto_channel_butserv_butone(cptr, CMD_JOIN, chan->channel, cptr,
+      sendcmdto_channel_butserv_butone(cptr, CMD_JOIN, chan->channel, cptr, 0,
                                          "%H", chan->channel);
     if (IsChanOp(chan) && HasVoice(chan))
-      sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr,
+      sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr, 0,
                                        "%H +ov %C %C", chan->channel, cptr,
                                        cptr);
     else if (IsChanOp(chan) || HasVoice(chan))
-      sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr,
+      sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr, 0,
         "%H +%c %C", chan->channel, IsChanOp(chan) ? 'o' : 'v', cptr);
   }
   return 0;
@@ -1613,7 +1619,7 @@ int is_silenced(struct Client *sptr, struct Client *acptr)
   ircd_snprintf(0, sender, sizeof(sender), "%s!%s@%s", cli_name(sptr),
                user->username, user->host);
   ircd_snprintf(0, senderip, sizeof(senderip), "%s!%s@%s", cli_name(sptr),
-               user->username, ircd_ntoa((const char*) &(cli_ip(sptr))));
+               user->username, ircd_ntoa(&cli_ip(sptr)));
   if (HasHiddenHost(sptr))
     ircd_snprintf(0, senderh, sizeof(senderh), "%s!%s@%s", cli_name(sptr),
                  user->username, user->realhost);