]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/irc-login.c
Enhanced the handler for PING and PONG commands: fix forwarding and enable
[ngircd-alex.git] / src / ngircd / irc-login.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  *
11  * Login and logout
12  */
13
14
15 #include "portab.h"
16
17 static char UNUSED id[] = "$Id: irc-login.c,v 1.48 2005/08/28 11:40:13 alex Exp $";
18
19 #include "imp.h"
20 #include <assert.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <strings.h>
25
26 #include "ngircd.h"
27 #include "resolve.h"
28 #include "conn-func.h"
29 #include "conf.h"
30 #include "client.h"
31 #include "channel.h"
32 #include "log.h"
33 #include "messages.h"
34 #include "parse.h"
35 #include "irc.h"
36 #include "irc-info.h"
37 #include "irc-write.h"
38 #include "cvs-version.h"
39
40 #include "exp.h"
41 #include "irc-login.h"
42
43
44 static bool Hello_User PARAMS(( CLIENT *Client ));
45 static void Kill_Nick PARAMS(( char *Nick, char *Reason ));
46
47
48 GLOBAL bool
49 IRC_PASS( CLIENT *Client, REQUEST *Req )
50 {
51         assert( Client != NULL );
52         assert( Req != NULL );
53
54         /* Fehler liefern, wenn kein lokaler Client */
55         if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
56         
57         if(( Client_Type( Client ) == CLIENT_UNKNOWN ) && ( Req->argc == 1))
58         {
59                 /* noch nicht registrierte unbekannte Verbindung */
60                 Log( LOG_DEBUG, "Connection %d: got PASS command ...", Client_Conn( Client ));
61
62                 /* Passwort speichern */
63                 Client_SetPassword( Client, Req->argv[0] );
64
65                 Client_SetType( Client, CLIENT_GOTPASS );
66                 return CONNECTED;
67         }
68         else if((( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER )) && (( Req->argc == 3 ) || ( Req->argc == 4 )))
69         {
70                 char c2, c4, *type, *impl, *serverver, *flags, *ptr, *ircflags;
71                 int protohigh, protolow;
72
73                 /* noch nicht registrierte Server-Verbindung */
74                 Log( LOG_DEBUG, "Connection %d: got PASS command (new server link) ...", Client_Conn( Client ));
75
76                 /* Passwort speichern */
77                 Client_SetPassword( Client, Req->argv[0] );
78
79                 /* Protokollversion ermitteln */
80                 if( strlen( Req->argv[1] ) >= 4 )
81                 {
82                         c2 = Req->argv[1][2];
83                         c4 = Req->argv[1][4];
84
85                         Req->argv[1][4] = '\0';
86                         protolow = atoi( &Req->argv[1][2] );
87                         Req->argv[1][2] = '\0';
88                         protohigh = atoi( Req->argv[1] );
89                         
90                         Req->argv[1][2] = c2;
91                         Req->argv[1][4] = c4;
92                 }                       
93                 else protohigh = protolow = 0;
94
95                 /* Protokoll-Typ */
96                 if( strlen( Req->argv[1] ) > 4 ) type = &Req->argv[1][4];
97                 else type = NULL;
98
99                 /* IRC-Flags (nach RFC 2813) */
100                 if( Req->argc >= 4 ) ircflags = Req->argv[3];
101                 else ircflags = "";
102
103                 /* Implementation, Version und ngIRCd-Flags */
104                 impl = Req->argv[2];
105                 ptr = strchr( impl, '|' );
106                 if( ptr ) *ptr = '\0';
107
108                 if( type && ( strcmp( type, PROTOIRCPLUS ) == 0 ))
109                 {
110                         /* auf der anderen Seite laeuft ein Server, der
111                          * ebenfalls das IRC+-Protokoll versteht */
112                         serverver = ptr + 1;
113                         flags = strchr( serverver, ':' );
114                         if( flags )
115                         {
116                                 *flags = '\0';
117                                 flags++;
118                         }
119                         else flags = "";
120                         Log( LOG_INFO, "Peer announces itself as %s-%s using protocol %d.%d/IRC+ (flags: \"%s\").", impl, serverver, protohigh, protolow, flags );
121                 }
122                 else
123                 {
124                         /* auf der anderen Seite laeuft ein Server, der
125                          * nur das Originalprotokoll unterstuetzt */
126                         serverver = "";
127                         if( strchr( ircflags, 'Z' )) flags = "Z";
128                         else flags = "";
129                         Log( LOG_INFO, "Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").", impl, protohigh, protolow, flags );
130                 }
131
132                 Client_SetType( Client, CLIENT_GOTPASSSERVER );
133                 Client_SetFlags( Client, flags );
134
135                 return CONNECTED;
136         }
137         else if(( Client_Type( Client ) == CLIENT_UNKNOWN  ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER ))
138         {
139                 /* Falsche Anzahl Parameter? */
140                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
141         }
142         else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
143 } /* IRC_PASS */
144
145
146 /**
147  * IRC "NICK" command.
148  * This function implements the IRC command "NICK" which is used to register
149  * with the server, to change already registered nicknames and to introduce
150  * new users which are connected to other servers.
151  */
152 GLOBAL bool
153 IRC_NICK( CLIENT *Client, REQUEST *Req )
154 {
155         CLIENT *intr_c, *target, *c;
156         char *modes;
157
158         assert( Client != NULL );
159         assert( Req != NULL );
160
161 #ifndef STRICT_RFC
162         /* Some IRC clients, for example BitchX, send the NICK and USER
163          * commands in the wrong order ... */
164         if( Client_Type( Client ) == CLIENT_UNKNOWN
165             || Client_Type( Client ) == CLIENT_GOTPASS
166             || Client_Type( Client ) == CLIENT_GOTNICK
167             || Client_Type( Client ) == CLIENT_GOTUSER
168             || Client_Type( Client ) == CLIENT_USER
169             || ( Client_Type( Client ) == CLIENT_SERVER && Req->argc == 1 ))
170 #else
171         if( Client_Type( Client ) == CLIENT_UNKNOWN
172             || Client_Type( Client ) == CLIENT_GOTPASS
173             || Client_Type( Client ) == CLIENT_GOTNICK
174             || Client_Type( Client ) == CLIENT_USER
175             || ( Client_Type( Client ) == CLIENT_SERVER && Req->argc == 1 ))
176 #endif
177         {
178                 /* User registration or change of nickname */
179
180                 /* Wrong number of arguments? */
181                 if( Req->argc != 1 )
182                         return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG,
183                                                    Client_ID( Client ),
184                                                    Req->command );
185
186                 /* Search "target" client */
187                 if( Client_Type( Client ) == CLIENT_SERVER )
188                 {
189                         target = Client_Search( Req->prefix );
190                         if( ! target )
191                                 return IRC_WriteStrClient( Client,
192                                                            ERR_NOSUCHNICK_MSG,
193                                                            Client_ID( Client ),
194                                                            Req->argv[0] );
195                 }
196                 else
197                 {
198                         /* Is this a restricted client? */
199                         if( Client_HasMode( Client, 'r' ))
200                                 return IRC_WriteStrClient( Client,
201                                                            ERR_RESTRICTED_MSG,
202                                                            Client_ID( Client ));
203
204                         target = Client;
205                 }
206
207 #ifndef STRICT_RFC
208                 /* If the clients tries to change to its own nickname we won't
209                  * do anything. This is how the original ircd behaves and some
210                  * clients (for example Snak) expect it to be like this.
211                  * But I doubt that this is "really the right thing" ... */
212                 if( strcmp( Client_ID( target ), Req->argv[0] ) == 0 )
213                         return CONNECTED;
214 #endif
215
216                 /* Check that the new nickname is available. Special case:
217                  * the client only changes from/to upper to lower case. */
218                 if( strcasecmp( Client_ID( target ), Req->argv[0] ) != 0 )
219                 {
220                         if( ! Client_CheckNick( target, Req->argv[0] ))
221                                 return CONNECTED;
222                 }
223
224                 if(( Client_Type( target ) != CLIENT_USER )
225                    && ( Client_Type( target ) != CLIENT_SERVER ))
226                 {
227                         /* New client */
228                         Log( LOG_DEBUG, "Connection %d: got valid NICK command ...", 
229                              Client_Conn( Client ));
230
231                         /* Register new nickname of this client */
232                         Client_SetID( target, Req->argv[0] );
233
234                         /* If we received a valid USER command already then
235                          * register the new client! */
236                         if( Client_Type( Client ) == CLIENT_GOTUSER )
237                                 return Hello_User( Client );
238                         else
239                                 Client_SetType( Client, CLIENT_GOTNICK );
240                 }
241                 else
242                 {
243                         /* Nickname change */
244                         if( Client_Conn( target ) > NONE )
245                         {
246                                 /* Local client */
247                                 Log( LOG_INFO,
248                                      "User \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".",
249                                      Client_Mask( target ), Client_Conn( target ),
250                                      Client_ID( target ), Req->argv[0] );
251                         }
252                         else
253                         {
254                                 /* Remote client */
255                                 Log( LOG_DEBUG,
256                                      "User \"%s\" changed nick: \"%s\" -> \"%s\".",
257                                      Client_Mask( target ), Client_ID( target ),
258                                      Req->argv[0] );
259                         }
260
261                         /* Inform all users and servers (which have to know)
262                          * of this nickname change */
263                         if( Client_Type( Client ) == CLIENT_USER )
264                                 IRC_WriteStrClientPrefix( Client, Client,
265                                                           "NICK :%s",
266                                                           Req->argv[0] );
267                         IRC_WriteStrServersPrefix( Client, target,
268                                                    "NICK :%s", Req->argv[0] );
269                         IRC_WriteStrRelatedPrefix( target, target, false,
270                                                    "NICK :%s", Req->argv[0] );
271                         
272                         /* Register old nickname for WHOWAS queries */
273                         Client_RegisterWhowas( target );
274                                 
275                         /* Save new nickname */
276                         Client_SetID( target, Req->argv[0] );
277                         
278                         IRC_SetPenalty( target, 2 );
279                 }
280
281                 return CONNECTED;
282         }
283         else if( Client_Type( Client ) == CLIENT_SERVER )
284         {
285                 /* Server introduces new client */
286
287                 /* Falsche Anzahl Parameter? */
288                 if( Req->argc != 7 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
289
290                 /* Nick ueberpruefen */
291                 c = Client_Search( Req->argv[0] );
292                 if( c )
293                 {
294                         /* Der neue Nick ist auf diesem Server bereits registriert:
295                          * sowohl der neue, als auch der alte Client muessen nun
296                          * disconnectiert werden. */
297                         Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
298                         Kill_Nick( Req->argv[0], "Nick collision" );
299                         return CONNECTED;
300                 }
301
302                 /* Server, zu dem der Client connectiert ist, suchen */
303                 intr_c = Client_GetFromToken( Client, atoi( Req->argv[4] ));
304                 if( ! intr_c )
305                 {
306                         Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
307                         Kill_Nick( Req->argv[0], "Unknown server" );
308                         return CONNECTED;
309                 }
310
311                 /* Neue Client-Struktur anlegen */
312                 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);
313                 if( ! c )
314                 {
315                         /* Eine neue Client-Struktur konnte nicht angelegt werden.
316                          * Der Client muss disconnectiert werden, damit der Netz-
317                          * status konsistent bleibt. */
318                         Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
319                         Kill_Nick( Req->argv[0], "Server error" );
320                         return CONNECTED;
321                 }
322
323                 modes = Client_Modes( c );
324                 if( *modes ) Log( LOG_DEBUG, "User \"%s\" (+%s) registered (via %s, on %s, %d hop%s).", Client_Mask( c ), modes, Client_ID( Client ), Client_ID( intr_c ), Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
325                 else Log( LOG_DEBUG, "User \"%s\" registered (via %s, on %s, %d hop%s).", Client_Mask( c ), Client_ID( Client ), Client_ID( intr_c ), Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
326
327                 /* Andere Server, ausser dem Introducer, informieren */
328                 IRC_WriteStrServersPrefix( Client, Client, "NICK %s %d %s %s %d %s :%s", Req->argv[0], atoi( Req->argv[1] ) + 1, Req->argv[2], Req->argv[3], Client_MyToken( intr_c ), Req->argv[5], Req->argv[6] );
329
330                 return CONNECTED;
331         }
332         else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
333 } /* IRC_NICK */
334
335
336 GLOBAL bool
337 IRC_USER( CLIENT *Client, REQUEST *Req )
338 {
339 #ifdef IDENTAUTH
340         char *ptr;
341 #endif
342
343         assert( Client != NULL );
344         assert( Req != NULL );
345
346 #ifndef STRICT_RFC
347         if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_UNKNOWN )
348 #else
349         if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS )
350 #endif
351         {
352                 /* Wrong number of parameters? */
353                 if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
354
355                 /* User name */
356 #ifdef IDENTAUTH
357                 ptr = Client_User( Client );
358                 if( ! ptr || ! *ptr || *ptr == '~' ) Client_SetUser( Client, Req->argv[0], false );
359 #else
360                 Client_SetUser( Client, Req->argv[0], false );
361 #endif
362
363                 /* "Real name" or user info text: Don't set it to the empty string, the original ircd
364                  * can't deal with such "real names" (e. g. "USER user * * :") ... */
365                 if( *Req->argv[3] ) Client_SetInfo( Client, Req->argv[3] );
366                 else Client_SetInfo( Client, "-" );
367
368                 Log( LOG_DEBUG, "Connection %d: got valid USER command ...", Client_Conn( Client ));
369                 if( Client_Type( Client ) == CLIENT_GOTNICK ) return Hello_User( Client );
370                 else Client_SetType( Client, CLIENT_GOTUSER );
371                 return CONNECTED;
372         }
373         else if( Client_Type( Client ) == CLIENT_USER || Client_Type( Client ) == CLIENT_SERVER || Client_Type( Client ) == CLIENT_SERVICE )
374         {
375                 return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
376         }
377         else return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
378 } /* IRC_USER */
379
380
381 GLOBAL bool
382 IRC_QUIT( CLIENT *Client, REQUEST *Req )
383 {
384         CLIENT *target;
385         char quitmsg[LINE_LEN];
386         
387         assert( Client != NULL );
388         assert( Req != NULL );
389                 
390         /* Wrong number of arguments? */
391         if( Req->argc > 1 )
392                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
393
394         if (Req->argc == 1)
395                 strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
396
397         if ( Client_Type( Client ) == CLIENT_SERVER )
398         {
399                 /* Server */
400                 target = Client_Search( Req->prefix );
401                 if( ! target )
402                 {
403                         /* Den Client kennen wir nicht (mehr), also nichts zu tun. */
404                         Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
405                         return CONNECTED;
406                 }
407
408                 Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
409
410                 return CONNECTED;
411         }
412         else
413         {
414                 if (Req->argc == 1 && quitmsg[0] != '\"') {
415                         /* " " to avoid confusion */
416                         strlcpy(quitmsg, "\"", sizeof quitmsg);
417                         strlcat(quitmsg, Req->argv[0], sizeof quitmsg-1);
418                         strlcat(quitmsg, "\"", sizeof quitmsg );
419                 }
420
421                 /* User, Service, oder noch nicht registriert */
422                 Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
423                 
424                 return DISCONNECTED;
425         }
426 } /* IRC_QUIT */
427
428
429 GLOBAL bool
430 IRC_PING(CLIENT *Client, REQUEST *Req)
431 {
432         CLIENT *target, *from;
433
434         assert(Client != NULL);
435         assert(Req != NULL);
436
437         /* Wrong number of arguments? */
438         if (Req->argc < 1)
439                 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
440                                           Client_ID(Client));
441 #ifdef STRICT_RFC
442         /* Don't ignore additional arguments when in "strict" mode */
443         if (Req->argc > 2)
444                  return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
445                                            Client_ID(Client), Req->command);
446 #endif
447
448         if (Req->argc > 1) {
449                 /* A target has been specified ... */
450                 target = Client_Search(Req->argv[1]);
451
452                 if (!target || Client_Type(target) != CLIENT_SERVER)
453                         return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
454                                         Client_ID(Client), Req->argv[1]);
455
456                 if (target != Client_ThisServer()) {
457                         /* Ok, we have to forward the PING */
458                         if (Client_Type(Client) == CLIENT_SERVER)
459                                 from = Client_Search(Req->prefix);
460                         else
461                                 from = Client;
462                         if (!from)
463                                 return IRC_WriteStrClient(Client,
464                                                 ERR_NOSUCHSERVER_MSG,
465                                                 Client_ID(Client), Req->prefix);
466
467                         return IRC_WriteStrClientPrefix(target, from,
468                                         "PING %s :%s", Req->argv[0],
469                                         Req->argv[1] );
470                 }
471         }
472
473         if (Client_Type(Client) == CLIENT_SERVER) {
474                 if (Req->prefix)
475                         from = Client_Search(Req->prefix);
476                 else
477                         from = Client;
478         } else
479                 from = Client_ThisServer();
480         if (!from)
481                 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
482                                         Client_ID(Client), Req->prefix);
483
484         Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...",
485             Client_Conn(Client));
486
487 #ifdef STRICT_RFC
488         return IRC_WriteStrClient(Client, "PONG %s :%s",
489                 Client_ID(from), Client_ID(Client));
490 #else
491         /* Some clients depend on the argument being returned in the PONG
492          * reply (not mentioned in any RFC, though) */
493         return IRC_WriteStrClient(Client, "PONG %s :%s",
494                 Client_ID(from), Req->argv[0]);
495 #endif
496 } /* IRC_PING */
497
498
499 GLOBAL bool
500 IRC_PONG(CLIENT *Client, REQUEST *Req)
501 {
502         CLIENT *target, *from;
503         char *s;
504
505         assert(Client != NULL);
506         assert(Req != NULL);
507
508         /* Wrong number of arguments? */
509         if (Req->argc < 1)
510                 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
511                                           Client_ID(Client));
512         if (Req->argc > 2)
513                 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
514                                           Client_ID(Client), Req->command);
515
516         /* Forward? */
517         if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) {
518                 target = Client_Search(Req->argv[0]);
519                 if (!target)
520                         return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
521                                         Client_ID(Client), Req->argv[0]);
522
523                 if (target != Client_ThisServer()) {
524                         /* Ok, we have to forward the message. */
525                         from = Client_Search(Req->prefix);
526                         if (!from)
527                                 return IRC_WriteStrClient(Client,
528                                                 ERR_NOSUCHSERVER_MSG,
529                                                 Client_ID(Client), Req->prefix);
530
531                         if (Client_Type(Client_NextHop(target)) != CLIENT_SERVER)
532                                 s = Client_ID(from);
533                         else
534                                 s = Req->argv[0];
535                         return IRC_WriteStrClientPrefix(target, from,
536                                  "PONG %s :%s", s, Req->argv[1]);
537                 }
538         }
539
540         /* The connection timestamp has already been updated when the data has
541          * been read from so socket, so we don't need to update it here. */
542
543         if (Client_Conn(Client) > NONE)
544                 Log(LOG_DEBUG,
545                         "Connection %d: received PONG. Lag: %ld seconds.",
546                         Client_Conn(Client),
547                         time(NULL) - Conn_LastPing(Client_Conn(Client)));
548         else
549                  Log(LOG_DEBUG,
550                         "Connection %d: received PONG.", Client_Conn(Client));
551
552         return CONNECTED;
553 } /* IRC_PONG */
554
555
556 static bool
557 Hello_User( CLIENT *Client )
558 {
559 #ifdef CVSDATE
560         char ver[12], vertxt[30];
561 #endif
562
563         assert( Client != NULL );
564
565         /* Check password ... */
566         if( strcmp( Client_Password( Client ), Conf_ServerPwd ) != 0 )
567         {
568                 /* Bad password! */
569                 Log( LOG_ERR, "User \"%s\" rejected (connection %d): Bad password!", Client_Mask( Client ), Client_Conn( Client ));
570                 Conn_Close( Client_Conn( Client ), NULL, "Bad password", true);
571                 return DISCONNECTED;
572         }
573
574         Log( LOG_NOTICE, "User \"%s\" registered (connection %d).", Client_Mask( Client ), Client_Conn( Client ));
575
576         /* Inform other servers */
577         IRC_WriteStrServers( NULL, "NICK %s 1 %s %s 1 +%s :%s", Client_ID( Client ), Client_User( Client ), Client_Hostname( Client ), Client_Modes( Client ), Client_Info( Client ));
578
579         /* Welcome :-) */
580         if( ! IRC_WriteStrClient( Client, RPL_WELCOME_MSG, Client_ID( Client ), Client_Mask( Client ))) return false;
581
582         /* Version and system type */
583 #ifdef CVSDATE
584         strlcpy( ver, CVSDATE, sizeof( ver ));
585         strncpy( ver + 4, ver + 5, 2 );
586         strncpy( ver + 6, ver + 8, 3 );
587         snprintf( vertxt, sizeof( vertxt ), "%s(%s)", PACKAGE_VERSION, ver );
588         if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return false;
589 #else
590         if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return false;
591 #endif
592
593         if( ! IRC_WriteStrClient( Client, RPL_CREATED_MSG, Client_ID( Client ), NGIRCd_StartStr )) return false;
594 #ifdef CVSDATE
595         if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, USERMODES, CHANMODES )) return false;  
596 #else
597         if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, USERMODES, CHANMODES )) return false;
598 #endif
599
600         /* Features */
601         if( ! IRC_WriteStrClient( Client, RPL_ISUPPORT_MSG, Client_ID( Client ), CLIENT_NICK_LEN - 1,
602                         COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1, Conf_MaxJoins )) return DISCONNECTED;
603
604         Client_SetType( Client, CLIENT_USER );
605
606         if( ! IRC_Send_LUSERS( Client )) return DISCONNECTED;
607         if( ! IRC_Show_MOTD( Client )) return DISCONNECTED;
608
609         /* Suspend the client for a second ... */
610         IRC_SetPenalty( Client, 1 );
611
612         return CONNECTED;
613 } /* Hello_User */
614
615
616 static void
617 Kill_Nick( char *Nick, char *Reason )
618 {
619         REQUEST r;
620
621         assert( Nick != NULL );
622         assert( Reason != NULL );
623
624         r.prefix = (char *)Client_ThisServer( );
625         r.argv[0] = Nick;
626         r.argv[1] = Reason;
627         r.argc = 2;
628
629         Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
630         IRC_KILL( Client_ThisServer( ), &r );
631 } /* Kill_Nick */
632
633
634 /* -eof- */