2 c23199d9 2002-02-27 alex * ngIRCd -- The Next Generation IRC Daemon
3 c23199d9 2002-02-27 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
5 c23199d9 2002-02-27 alex * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6 c23199d9 2002-02-27 alex * der GNU General Public License (GPL), wie von der Free Software Foundation
7 c23199d9 2002-02-27 alex * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8 c23199d9 2002-02-27 alex * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9 c23199d9 2002-02-27 alex * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10 c23199d9 2002-02-27 alex * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
12 bcc51385 2002-03-26 alex * $Id: irc-login.c,v 1.11 2002/03/26 23:58:34 alex Exp $
14 c23199d9 2002-02-27 alex * irc-login.c: Anmeldung und Abmeldung im IRC
18 ca33cbda 2002-03-12 alex #include "portab.h"
20 ca33cbda 2002-03-12 alex #include "imp.h"
21 c23199d9 2002-02-27 alex #include <assert.h>
22 c23199d9 2002-02-27 alex #include <stdio.h>
23 c23199d9 2002-02-27 alex #include <stdlib.h>
24 c23199d9 2002-02-27 alex #include <string.h>
26 c23199d9 2002-02-27 alex #include "ngircd.h"
27 c23199d9 2002-02-27 alex #include "conf.h"
28 c23199d9 2002-02-27 alex #include "irc.h"
29 c23199d9 2002-02-27 alex #include "irc-write.h"
30 c23199d9 2002-02-27 alex #include "log.h"
31 c23199d9 2002-02-27 alex #include "messages.h"
33 ca33cbda 2002-03-12 alex #include "exp.h"
34 c23199d9 2002-02-27 alex #include "irc-login.h"
37 c23199d9 2002-02-27 alex LOCAL BOOLEAN Hello_User( CLIENT *Client );
38 c23199d9 2002-02-27 alex LOCAL VOID Kill_Nick( CHAR *Nick, CHAR *Reason );
41 c23199d9 2002-02-27 alex GLOBAL BOOLEAN IRC_PASS( CLIENT *Client, REQUEST *Req )
43 c23199d9 2002-02-27 alex assert( Client != NULL );
44 c23199d9 2002-02-27 alex assert( Req != NULL );
46 c23199d9 2002-02-27 alex /* Fehler liefern, wenn kein lokaler Client */
47 c23199d9 2002-02-27 alex if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
49 c23199d9 2002-02-27 alex if(( Client_Type( Client ) == CLIENT_UNKNOWN ) && ( Req->argc == 1))
51 c23199d9 2002-02-27 alex /* noch nicht registrierte unbekannte Verbindung */
52 c23199d9 2002-02-27 alex Log( LOG_DEBUG, "Connection %d: got PASS command ...", Client_Conn( Client ));
54 c23199d9 2002-02-27 alex /* Passwort speichern */
55 c23199d9 2002-02-27 alex Client_SetPassword( Client, Req->argv[0] );
57 c23199d9 2002-02-27 alex Client_SetType( Client, CLIENT_GOTPASS );
58 c23199d9 2002-02-27 alex return CONNECTED;
60 c23199d9 2002-02-27 alex else if((( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER )) && (( Req->argc == 3 ) || ( Req->argc == 4 )))
62 c23199d9 2002-02-27 alex /* noch nicht registrierte Server-Verbindung */
63 c23199d9 2002-02-27 alex Log( LOG_DEBUG, "Connection %d: got PASS command (new server link) ...", Client_Conn( Client ));
65 c23199d9 2002-02-27 alex /* Passwort speichern */
66 c23199d9 2002-02-27 alex Client_SetPassword( Client, Req->argv[0] );
68 c23199d9 2002-02-27 alex Client_SetType( Client, CLIENT_GOTPASSSERVER );
69 c23199d9 2002-02-27 alex return CONNECTED;
71 c23199d9 2002-02-27 alex else if(( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER ))
73 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
74 c23199d9 2002-02-27 alex return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
76 c23199d9 2002-02-27 alex else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
77 c23199d9 2002-02-27 alex } /* IRC_PASS */
80 c23199d9 2002-02-27 alex GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
82 c23199d9 2002-02-27 alex CLIENT *intr_c, *target, *c;
83 c23199d9 2002-02-27 alex CHAR *modes;
85 c23199d9 2002-02-27 alex assert( Client != NULL );
86 c23199d9 2002-02-27 alex assert( Req != NULL );
88 c23199d9 2002-02-27 alex /* Zumindest BitchX sendet NICK-USER in der falschen Reihenfolge. */
89 c23199d9 2002-02-27 alex #ifndef STRICT_RFC
90 c23199d9 2002-02-27 alex if( Client_Type( Client ) == CLIENT_UNKNOWN || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTUSER || Client_Type( Client ) == CLIENT_USER || ( Client_Type( Client ) == CLIENT_SERVER && Req->argc == 1 ))
92 c23199d9 2002-02-27 alex if( Client_Type( Client ) == CLIENT_UNKNOWN || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_USER || ( Client_Type( Client ) == CLIENT_SERVER && Req->argc == 1 ))
95 c23199d9 2002-02-27 alex /* User-Registrierung bzw. Nick-Aenderung */
97 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
98 c23199d9 2002-02-27 alex if( Req->argc != 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
100 c23199d9 2002-02-27 alex /* "Ziel-Client" ermitteln */
101 c23199d9 2002-02-27 alex if( Client_Type( Client ) == CLIENT_SERVER )
103 bc4ed226 2002-03-25 alex target = Client_Search( Req->prefix );
104 c23199d9 2002-02-27 alex if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
108 c23199d9 2002-02-27 alex /* Ist der Client "restricted"? */
109 c23199d9 2002-02-27 alex if( Client_HasMode( Client, 'r' )) return IRC_WriteStrClient( Client, ERR_RESTRICTED_MSG, Client_ID( Client ));
110 c23199d9 2002-02-27 alex target = Client;
113 c23199d9 2002-02-27 alex #ifndef STRICT_RFC
114 c23199d9 2002-02-27 alex /* Wenn der Client zu seinem eigenen Nick wechseln will, so machen
115 c23199d9 2002-02-27 alex * wir nichts. So macht es das Original und mind. Snak hat probleme,
116 c23199d9 2002-02-27 alex * wenn wir es nicht so machen. Ob es so okay ist? Hm ... */
117 c23199d9 2002-02-27 alex if( strcmp( Client_ID( target ), Req->argv[0] ) == 0 ) return CONNECTED;
120 c23199d9 2002-02-27 alex /* pruefen, ob Nick bereits vergeben. Speziallfall: der Client
121 c23199d9 2002-02-27 alex * will nur die Gross- und Kleinschreibung aendern. Das darf
122 c23199d9 2002-02-27 alex * er natuerlich machen :-) */
123 c23199d9 2002-02-27 alex if( strcasecmp( Client_ID( target ), Req->argv[0] ) != 0 )
125 c23199d9 2002-02-27 alex if( ! Client_CheckNick( target, Req->argv[0] )) return CONNECTED;
128 c23199d9 2002-02-27 alex if(( Client_Type( target ) != CLIENT_USER ) && ( Client_Type( target ) != CLIENT_SERVER ))
130 c23199d9 2002-02-27 alex /* Neuer Client */
131 c23199d9 2002-02-27 alex Log( LOG_DEBUG, "Connection %d: got valid NICK command ...", Client_Conn( Client ));
133 c23199d9 2002-02-27 alex /* Client-Nick registrieren */
134 c23199d9 2002-02-27 alex Client_SetID( target, Req->argv[0] );
136 c23199d9 2002-02-27 alex /* schon ein USER da? Dann registrieren! */
137 c23199d9 2002-02-27 alex if( Client_Type( Client ) == CLIENT_GOTUSER ) return Hello_User( Client );
138 c23199d9 2002-02-27 alex else Client_SetType( Client, CLIENT_GOTNICK );
142 c23199d9 2002-02-27 alex /* Nick-Aenderung */
143 69f68307 2002-03-19 alex if( Client_Conn( target ) > NONE ) Log( LOG_INFO, "User \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".", Client_Mask( target ), Client_ID( target ), Req->argv[0], Client_Conn( target ));
144 69f68307 2002-03-19 alex else Log( LOG_DEBUG, "User \"%s\" changed nick: \"%s\" -> \"%s\".", Client_Mask( target ), Client_ID( target ), Req->argv[0] );
146 0370c484 2002-03-02 alex /* alle betroffenen User und Server ueber Nick-Aenderung informieren */
147 0370c484 2002-03-02 alex if( Client_Type( Client ) == CLIENT_USER ) IRC_WriteStrClientPrefix( Client, Client, "NICK :%s", Req->argv[0] );
148 0370c484 2002-03-02 alex IRC_WriteStrServersPrefix( Client, target, "NICK :%s", Req->argv[0] );
149 0370c484 2002-03-02 alex IRC_WriteStrRelatedPrefix( target, target, FALSE, "NICK :%s", Req->argv[0] );
151 c23199d9 2002-02-27 alex /* neuen Client-Nick speichern */
152 c23199d9 2002-02-27 alex Client_SetID( target, Req->argv[0] );
155 c23199d9 2002-02-27 alex return CONNECTED;
157 c23199d9 2002-02-27 alex else if( Client_Type( Client ) == CLIENT_SERVER )
159 c23199d9 2002-02-27 alex /* Server fuehrt neuen Client ein */
161 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
162 c23199d9 2002-02-27 alex if( Req->argc != 7 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
164 c23199d9 2002-02-27 alex /* Nick ueberpruefen */
165 bc4ed226 2002-03-25 alex c = Client_Search( Req->argv[0] );
168 c23199d9 2002-02-27 alex /* Der neue Nick ist auf diesem Server bereits registriert:
169 c23199d9 2002-02-27 alex * sowohl der neue, als auch der alte Client muessen nun
170 c23199d9 2002-02-27 alex * disconnectiert werden. */
171 c23199d9 2002-02-27 alex Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
172 c23199d9 2002-02-27 alex Kill_Nick( Req->argv[0], "Nick collision" );
173 c23199d9 2002-02-27 alex return CONNECTED;
176 c23199d9 2002-02-27 alex /* Server, zu dem der Client connectiert ist, suchen */
177 c23199d9 2002-02-27 alex intr_c = Client_GetFromToken( Client, atoi( Req->argv[4] ));
178 c23199d9 2002-02-27 alex if( ! intr_c )
180 c23199d9 2002-02-27 alex Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
181 c23199d9 2002-02-27 alex Kill_Nick( Req->argv[0], "Unknown server" );
182 c23199d9 2002-02-27 alex return CONNECTED;
185 c23199d9 2002-02-27 alex /* Neue Client-Struktur anlegen */
186 c23199d9 2002-02-27 alex 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 );
189 c23199d9 2002-02-27 alex /* Eine neue Client-Struktur konnte nicht angelegt werden.
190 c23199d9 2002-02-27 alex * Der Client muss disconnectiert werden, damit der Netz-
191 c23199d9 2002-02-27 alex * status konsistent bleibt. */
192 c23199d9 2002-02-27 alex Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
193 c23199d9 2002-02-27 alex Kill_Nick( Req->argv[0], "Server error" );
194 c23199d9 2002-02-27 alex return CONNECTED;
197 c23199d9 2002-02-27 alex modes = Client_Modes( c );
198 c23199d9 2002-02-27 alex 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": "" );
199 c23199d9 2002-02-27 alex 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": "" );
201 c23199d9 2002-02-27 alex /* Andere Server, ausser dem Introducer, informieren */
202 c23199d9 2002-02-27 alex 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] );
204 c23199d9 2002-02-27 alex return CONNECTED;
206 c23199d9 2002-02-27 alex else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
207 c23199d9 2002-02-27 alex } /* IRC_NICK */
210 c23199d9 2002-02-27 alex GLOBAL BOOLEAN IRC_USER( CLIENT *Client, REQUEST *Req )
212 c23199d9 2002-02-27 alex assert( Client != NULL );
213 c23199d9 2002-02-27 alex assert( Req != NULL );
215 c23199d9 2002-02-27 alex #ifndef STRICT_RFC
216 c23199d9 2002-02-27 alex if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_UNKNOWN )
218 c23199d9 2002-02-27 alex if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS )
221 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
222 c23199d9 2002-02-27 alex if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
224 c23199d9 2002-02-27 alex Client_SetUser( Client, Req->argv[0], FALSE );
225 c23199d9 2002-02-27 alex Client_SetInfo( Client, Req->argv[3] );
227 c23199d9 2002-02-27 alex Log( LOG_DEBUG, "Connection %d: got valid USER command ...", Client_Conn( Client ));
228 c23199d9 2002-02-27 alex if( Client_Type( Client ) == CLIENT_GOTNICK ) return Hello_User( Client );
229 c23199d9 2002-02-27 alex else Client_SetType( Client, CLIENT_GOTUSER );
230 c23199d9 2002-02-27 alex return CONNECTED;
232 c23199d9 2002-02-27 alex else if( Client_Type( Client ) == CLIENT_USER || Client_Type( Client ) == CLIENT_SERVER || Client_Type( Client ) == CLIENT_SERVICE )
234 c23199d9 2002-02-27 alex return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
236 c23199d9 2002-02-27 alex else return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
237 c23199d9 2002-02-27 alex } /* IRC_USER */
240 c23199d9 2002-02-27 alex GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req )
242 c23199d9 2002-02-27 alex CLIENT *target;
244 c23199d9 2002-02-27 alex assert( Client != NULL );
245 c23199d9 2002-02-27 alex assert( Req != NULL );
247 c23199d9 2002-02-27 alex if(( Client_Type( Client ) == CLIENT_USER ) || ( Client_Type( Client ) == CLIENT_SERVICE ))
249 c23199d9 2002-02-27 alex /* User / Service */
251 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
252 c23199d9 2002-02-27 alex if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
254 c23199d9 2002-02-27 alex if( Req->argc == 0 ) Conn_Close( Client_Conn( Client ), "Got QUIT command.", NULL, TRUE );
255 c23199d9 2002-02-27 alex else Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argv[0], TRUE );
257 c23199d9 2002-02-27 alex return DISCONNECTED;
259 c23199d9 2002-02-27 alex else if ( Client_Type( Client ) == CLIENT_SERVER )
261 c23199d9 2002-02-27 alex /* Server */
263 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
264 c23199d9 2002-02-27 alex if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
266 c23199d9 2002-02-27 alex target = Client_Search( Req->prefix );
267 c23199d9 2002-02-27 alex if( ! target )
269 9fc7e66f 2002-03-11 alex /* Den Client kennen wir nicht (mehr), also nichts zu tun. */
270 f7a0ff1f 2002-03-11 alex Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
271 c23199d9 2002-02-27 alex return CONNECTED;
274 50ec7a56 2002-03-11 alex if( Req->argc == 0 ) Client_Destroy( target, "Got QUIT command.", NULL, TRUE );
275 50ec7a56 2002-03-11 alex else Client_Destroy( target, "Got QUIT command.", Req->argv[0], TRUE );
277 c23199d9 2002-02-27 alex return CONNECTED;
279 c23199d9 2002-02-27 alex else return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
280 c23199d9 2002-02-27 alex } /* IRC_QUIT */
283 c23199d9 2002-02-27 alex GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req )
285 c23199d9 2002-02-27 alex CLIENT *target, *from;
287 c23199d9 2002-02-27 alex assert( Client != NULL );
288 c23199d9 2002-02-27 alex assert( Req != NULL );
290 c23199d9 2002-02-27 alex if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
292 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
293 c23199d9 2002-02-27 alex if( Req->argc < 1 ) return IRC_WriteStrClient( Client, ERR_NOORIGIN_MSG, Client_ID( Client ));
294 5fa05dce 2002-03-10 alex #ifdef STRICT_RFC
295 c23199d9 2002-02-27 alex if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
298 5fa05dce 2002-03-10 alex if( Req->argc > 1 )
300 c23199d9 2002-02-27 alex /* es wurde ein Ziel-Client angegeben */
301 bc4ed226 2002-03-25 alex target = Client_Search( Req->argv[1] );
302 c23199d9 2002-02-27 alex if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[1] );
303 c23199d9 2002-02-27 alex if( target != Client_ThisServer( ))
305 c23199d9 2002-02-27 alex /* ok, forwarden */
306 bc4ed226 2002-03-25 alex if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
307 c23199d9 2002-02-27 alex else from = Client;
308 c23199d9 2002-02-27 alex if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix );
309 c23199d9 2002-02-27 alex return IRC_WriteStrClientPrefix( target, from, "PING %s :%s", Client_ID( from ), Req->argv[1] );
313 c23199d9 2002-02-27 alex Log( LOG_DEBUG, "Connection %d: got PING, sending PONG ...", Client_Conn( Client ));
314 c23199d9 2002-02-27 alex return IRC_WriteStrClient( Client, "PONG %s :%s", Client_ID( Client_ThisServer( )), Client_ID( Client ));
315 c23199d9 2002-02-27 alex } /* IRC_PING */
318 c23199d9 2002-02-27 alex GLOBAL BOOLEAN IRC_PONG( CLIENT *Client, REQUEST *Req )
320 c23199d9 2002-02-27 alex CLIENT *target, *from;
322 c23199d9 2002-02-27 alex assert( Client != NULL );
323 c23199d9 2002-02-27 alex assert( Req != NULL );
325 c23199d9 2002-02-27 alex if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
327 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
328 c23199d9 2002-02-27 alex if( Req->argc < 1 ) return IRC_WriteStrClient( Client, ERR_NOORIGIN_MSG, Client_ID( Client ));
329 c23199d9 2002-02-27 alex if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
331 c23199d9 2002-02-27 alex /* forwarden? */
332 c23199d9 2002-02-27 alex if( Req->argc == 2 )
334 bc4ed226 2002-03-25 alex target = Client_Search( Req->argv[1] );
335 c23199d9 2002-02-27 alex if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[1] );
336 c23199d9 2002-02-27 alex if( target != Client_ThisServer( ))
338 c23199d9 2002-02-27 alex /* ok, forwarden */
339 bc4ed226 2002-03-25 alex if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
340 c23199d9 2002-02-27 alex else from = Client;
341 c23199d9 2002-02-27 alex if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix );
342 c23199d9 2002-02-27 alex return IRC_WriteStrClientPrefix( target, from, "PONG %s :%s", Client_ID( from ), Req->argv[1] );
346 c23199d9 2002-02-27 alex /* Der Connection-Timestamp wurde schon beim Lesen aus dem Socket
347 bcc51385 2002-03-26 alex * aktualisiert, daher muss das hier nicht mehr gemacht werden. */
349 c23199d9 2002-02-27 alex if( Client_Conn( Client ) > NONE ) Log( LOG_DEBUG, "Connection %d: received PONG. Lag: %ld seconds.", Client_Conn( Client ), time( NULL ) - Conn_LastPing( Client_Conn( Client )));
350 c23199d9 2002-02-27 alex else Log( LOG_DEBUG, "Connection %d: received PONG.", Client_Conn( Client ));
352 c23199d9 2002-02-27 alex return CONNECTED;
353 c23199d9 2002-02-27 alex } /* IRC_PONG */
356 c23199d9 2002-02-27 alex LOCAL BOOLEAN Hello_User( CLIENT *Client )
358 c23199d9 2002-02-27 alex assert( Client != NULL );
360 c23199d9 2002-02-27 alex /* Passwort ueberpruefen */
361 c23199d9 2002-02-27 alex if( strcmp( Client_Password( Client ), Conf_ServerPwd ) != 0 )
363 c23199d9 2002-02-27 alex /* Falsches Passwort */
364 c23199d9 2002-02-27 alex Log( LOG_ERR, "User \"%s\" rejected (connection %d): Bad password!", Client_Mask( Client ), Client_Conn( Client ));
365 c23199d9 2002-02-27 alex Conn_Close( Client_Conn( Client ), NULL, "Bad password", TRUE );
366 c23199d9 2002-02-27 alex return DISCONNECTED;
369 c23199d9 2002-02-27 alex Log( LOG_NOTICE, "User \"%s\" registered (connection %d).", Client_Mask( Client ), Client_Conn( Client ));
371 c23199d9 2002-02-27 alex /* Andere Server informieren */
372 c23199d9 2002-02-27 alex 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 ));
374 c23199d9 2002-02-27 alex if( ! IRC_WriteStrClient( Client, RPL_WELCOME_MSG, Client_ID( Client ), Client_Mask( Client ))) return FALSE;
375 c23199d9 2002-02-27 alex if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )))) return FALSE;
376 c23199d9 2002-02-27 alex if( ! IRC_WriteStrClient( Client, RPL_CREATED_MSG, Client_ID( Client ), NGIRCd_StartStr )) return FALSE;
377 c23199d9 2002-02-27 alex if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )))) return FALSE;
379 c23199d9 2002-02-27 alex Client_SetType( Client, CLIENT_USER );
381 c23199d9 2002-02-27 alex if( ! IRC_Send_LUSERS( Client )) return DISCONNECTED;
382 c23199d9 2002-02-27 alex if( ! IRC_Show_MOTD( Client )) return DISCONNECTED;
384 c23199d9 2002-02-27 alex return CONNECTED;
385 c23199d9 2002-02-27 alex } /* Hello_User */
388 c23199d9 2002-02-27 alex LOCAL VOID Kill_Nick( CHAR *Nick, CHAR *Reason )
392 c23199d9 2002-02-27 alex assert( Nick != NULL );
393 c23199d9 2002-02-27 alex assert( Reason != NULL );
395 c23199d9 2002-02-27 alex Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
397 c23199d9 2002-02-27 alex /* andere Server benachrichtigen */
398 c23199d9 2002-02-27 alex IRC_WriteStrServers( NULL, "KILL %s :%s", Nick, Reason );
400 c23199d9 2002-02-27 alex /* Ggf. einen eigenen Client toeten */
401 bc4ed226 2002-03-25 alex c = Client_Search( Nick );
402 c23199d9 2002-02-27 alex if( c && ( Client_Conn( c ) != NONE )) Conn_Close( Client_Conn( c ), NULL, Reason, TRUE );
403 c23199d9 2002-02-27 alex } /* Kill_Nick */
406 c23199d9 2002-02-27 alex /* -eof- */