]> arthur.barton.de Git - ngircd-alex.git/commitdiff
NICK: allow servers and services to use RFC 1459 syntax (2 parameters).
authorAlexander Barton <alex@barton.de>
Wed, 13 Aug 2008 00:00:54 +0000 (02:00 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 23 Sep 2008 09:47:16 +0000 (11:47 +0200)
This patch allows servers and services to call the NICK command using the
syntax defined in RFC 1459 to register new users, with only two parameters.
See section 4.1.2.

Useful for some services packages, which emulate this protocol.

src/ngircd/irc-login.c

index 62e339769fcf2382293bc1dac59f643dcc11f4f9..2fdc5d44d8c9996f6e377a920985766f5e1ca692 100644 (file)
@@ -168,7 +168,8 @@ GLOBAL bool
 IRC_NICK( CLIENT *Client, REQUEST *Req )
 {
        CLIENT *intr_c, *target, *c;
-       char *modes;
+       char *nick, *user, *hostname, *modes, *info;
+       int token, hops;
 
        assert( Client != NULL );
        assert( Req != NULL );
@@ -294,18 +295,36 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
                }
 
                return CONNECTED;
-       }
-       else if( Client_Type( Client ) == CLIENT_SERVER )
-       {
-               /* Server introduces new client */
-
-               /* Falsche Anzahl Parameter? */
-               if( Req->argc != 7 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+       } else if(Client_Type(Client) == CLIENT_SERVER ||
+                 Client_Type(Client) == CLIENT_SERVICE) {
+               /* Server or service introduces new client */
+
+               /* Bad number of parameters? */
+               if (Req->argc != 2 && Req->argc != 7)
+                       return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+                                                 Client_ID(Client), Req->command);
+
+               if (Req->argc >= 7) {
+                       nick = Req->argv[0];
+                       hops = atoi(Req->argv[1]);
+                       user = Req->argv[2];
+                       hostname = Req->argv[3];
+                       token = atoi(Req->argv[4]);
+                       modes = Req->argv[5] + 1;
+                       info = Req->argv[6];
+               } else {
+                       nick = Req->argv[0];
+                       hops = 1;
+                       user = Req->argv[0];
+                       hostname = Client_ID(Client);
+                       token = atoi(Req->argv[1]);
+                       modes = "";
+                       info = Req->argv[0];
+               }
 
                /* Nick ueberpruefen */
-               c = Client_Search( Req->argv[0] );
-               if( c )
-               {
+               c = Client_Search(nick);
+               if(c) {
                        /* Der neue Nick ist auf diesem Server bereits registriert:
                         * sowohl der neue, als auch der alte Client muessen nun
                         * disconnectiert werden. */
@@ -315,7 +334,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
                }
 
                /* Server, zu dem der Client connectiert ist, suchen */
-               intr_c = Client_GetFromToken( Client, atoi( Req->argv[4] ));
+               intr_c = Client_GetFromToken(Client, token);
                if( ! intr_c )
                {
                        Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
@@ -324,7 +343,8 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
                }
 
                /* Neue Client-Struktur anlegen */
-               c = Client_NewRemoteUser( intr_c, Req->argv[0], atoi( Req->argv[1] ), Req->argv[2], Req->argv[3], atoi( Req->argv[4] ), Req->argv[5] + 1, Req->argv[6], true);
+               c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname,
+                                        token, modes, info, true);
                if( ! c )
                {
                        /* Eine neue Client-Struktur konnte nicht angelegt werden.