]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/numeric.c
Only log "IDENT ... no result" when IDENT was looked up
[ngircd-alex.git] / src / ngircd / numeric.c
index ba6c0254f7e32b1890723a9d3a0e0ad4fa0deb6d..a43739f18bf4dec9b44183396526c157d408b84b 100644 (file)
@@ -28,6 +28,7 @@
 #include "conn.h"
 #include "conn-func.h"
 #include "channel.h"
+#include "class.h"
 #include "irc-write.h"
 #include "lists.h"
 #include "log.h"
@@ -47,12 +48,11 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan)
        CL2CHAN *cl2chan;
        CLIENT *cl;
        char str[LINE_LEN], *ptr;
-       bool njoin;
+       bool njoin, xop;
 
-       if (Conn_Options(Client_Conn(Client)) & CONN_RFC1459)
-               njoin = false;
-       else
-               njoin = true;
+       /* Check features of remote server */
+       njoin = Conn_Options(Client_Conn(Client)) & CONN_RFC1459 ? false : true;
+       xop = Client_HasFlag(Client, 'X') ? true : false;
 
        /* Get all the members of this channel */
        cl2chan = Channel_FirstMember(Chan);
@@ -62,14 +62,23 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan)
                assert(cl != NULL);
 
                if (njoin) {
-                       /* RFC 2813: send NJOIN with nick names and modes
+                       /* RFC 2813: send NJOIN with nicknames and modes
                         * (if user is channel operator or has voice) */
                        if (str[strlen(str) - 1] != ':')
                                strlcat(str, ",", sizeof(str));
-                       if (strchr(Channel_UserModes(Chan, cl), 'v'))
-                               strlcat(str, "+", sizeof(str));
-                       if (strchr(Channel_UserModes(Chan, cl), 'o'))
+
+                       /* Prepare user prefix (ChanOp, voiced, ...) */
+                       if (xop && Channel_UserHasMode(Chan, cl, 'q'))
+                               strlcat(str, "~", sizeof(str));
+                       if (xop && Channel_UserHasMode(Chan, cl, 'a'))
+                               strlcat(str, "&", sizeof(str));
+                       if (Channel_UserHasMode(Chan, cl, 'o'))
                                strlcat(str, "@", sizeof(str));
+                       if (xop && Channel_UserHasMode(Chan, cl, 'h'))
+                               strlcat(str, "%", sizeof(str));
+                       if (Channel_UserHasMode(Chan, cl, 'v'))
+                               strlcat(str, "+", sizeof(str));
+
                        strlcat(str, Client_ID(cl), sizeof(str));
 
                        /* Send the data if the buffer is "full" */
@@ -141,61 +150,13 @@ Announce_Server(CLIENT * Client, CLIENT * Server)
 } /* Announce_Server */
 
 
-/**
- * Announce existing user to a new server
- * @param Client New server
- * @param User Existing user in the network
- */
-static bool
-Announce_User(CLIENT * Client, CLIENT * User)
-{
-       CONN_ID conn;
-       char *modes;
-
-       conn = Client_Conn(Client);
-       if (Conn_Options(conn) & CONN_RFC1459) {
-               /* RFC 1459 mode: separate NICK and USER commands */
-               if (! Conn_WriteStr(conn, "NICK %s :%d",
-                                   Client_ID(User), Client_Hops(User) + 1))
-                       return DISCONNECTED;
-               if (! Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
-                                    Client_ID(User), Client_User(User),
-                                    Client_Hostname(User),
-                                    Client_ID(Client_Introducer(User)),
-                                    Client_Info(User)))
-                       return DISCONNECTED;
-               modes = Client_Modes(User);
-               if (modes[0]) {
-                       return Conn_WriteStr(conn, ":%s MODE %s +%s",
-                                    Client_ID(User), Client_ID(User),
-                                    modes);
-               }
-               return CONNECTED;
-       } else {
-               /* RFC 2813 mode: one combined NICK or SERVICE command */
-               if (Client_Type(User) == CLIENT_SERVICE
-                   && strchr(Client_Flags(Client), 'S'))
-                       return IRC_WriteStrClient(Client,
-                               "SERVICE %s %d * +%s %d :%s", Client_Mask(User),
-                               Client_MyToken(Client_Introducer(User)),
-                               Client_Modes(User), Client_Hops(User) + 1,
-                               Client_Info(User));
-               else
-                       return IRC_WriteStrClient(Client,
-                               "NICK %s %d %s %s %d +%s :%s",
-                               Client_ID(User), Client_Hops(User) + 1,
-                               Client_User(User), Client_Hostname(User),
-                               Client_MyToken(Client_Introducer(User)),
-                               Client_Modes(User), Client_Info(User));
-       }
-} /* Announce_User */
-
-
 #ifdef IRCPLUS
 
 /**
- * Synchronize invite and ban lists between servers
- * @param Client New server
+ * Synchronize invite, ban, G- and K-Line lists between servers.
+ *
+ * @param Client New server.
+ * @return CONNECTED or DISCONNECTED.
  */
 static bool
 Synchronize_Lists(CLIENT * Client)
@@ -206,6 +167,18 @@ Synchronize_Lists(CLIENT * Client)
 
        assert(Client != NULL);
 
+       /* g-lines */
+       head = Class_GetList(CLASS_GLINE);
+       elem = Lists_GetFirst(head);
+       while (elem) {
+               if (!IRC_WriteStrClient(Client, "GLINE %s %ld :%s",
+                                       Lists_GetMask(elem),
+                                       Lists_GetValidity(elem) - time(NULL),
+                                       Lists_GetReason(elem)))
+                       return DISCONNECTED;
+               elem = Lists_GetNext(elem);
+       }
+
        c = Channel_First();
        while (c) {
                /* ban list */
@@ -259,8 +232,8 @@ Send_CHANINFO(CLIENT * Client, CHANNEL * Chan)
        if (!*modes && !*topic)
                return CONNECTED;
 
-       has_k = strchr(modes, 'k') != NULL;
-       has_l = strchr(modes, 'l') != NULL;
+       has_k = Channel_HasMode(Chan, 'k');
+       has_l = Channel_HasMode(Chan, 'l');
 
        /* send CHANINFO */
        if (!has_k && !has_l) {
@@ -333,7 +306,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
        while (c) {
                if (Client_Type(c) == CLIENT_USER ||
                    Client_Type(c) == CLIENT_SERVICE) {
-                       if (!Announce_User(Client, c))
+                       if (!Client_Announce(Client, Client_ThisServer(), c))
                                return DISCONNECTED;
                }
                c = Client_Next(c);
@@ -348,7 +321,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
                }
 #ifdef IRCPLUS
                /* Send CHANINFO if the peer supports it */
-               if (strchr(Client_Flags(Client), 'C')) {
+               if (Client_HasFlag(Client, 'C')) {
                        if (!Send_CHANINFO(Client, chan))
                                return DISCONNECTED;
                }
@@ -362,13 +335,17 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
        }
 
 #ifdef IRCPLUS
-       if (strchr(Client_Flags(Client), 'L')) {
+       if (Client_HasFlag(Client, 'L')) {
                LogDebug("Synchronizing INVITE- and BAN-lists ...");
                if (!Synchronize_Lists(Client))
                        return DISCONNECTED;
        }
 #endif
 
+       if (!IRC_WriteStrClient(Client, "PING :%s",
+           Client_ID(Client_ThisServer())))
+               return DISCONNECTED;
+
        return CONNECTED;
 } /* IRC_Num_ENDOFMOTD */
 
@@ -394,12 +371,12 @@ IRC_Num_ISUPPORT(CLIENT * Client, REQUEST * Req)
                        if ((unsigned int)atol(value) == Conf_MaxNickLength - 1)
                                continue;
 
-                       /* Nick name length settings are different! */
+                       /* Nickname length settings are different! */
                        Log(LOG_ERR,
-                           "Peer uses incompatible nick name length (%d/%d)! Disconnecting ...",
+                           "Peer uses incompatible nickname length (%d/%d)! Disconnecting ...",
                            Conf_MaxNickLength - 1, atoi(value));
                        Conn_Close(Client_Conn(Client),
-                                  "Incompatible nick name length",
+                                  "Incompatible nickname length",
                                   NULL, false);
                        return DISCONNECTED;
                }