Blame


1 2ee05c9a 2002-03-03 alex /*
2 2ee05c9a 2002-03-03 alex * ngIRCd -- The Next Generation IRC Daemon
3 53b98fd7 2007-11-20 alex * Copyright (c)2001-2007 Alexander Barton (alex@barton.de)
4 2ee05c9a 2002-03-03 alex *
5 490f28ff 2002-12-12 alex * This program is free software; you can redistribute it and/or modify
6 490f28ff 2002-12-12 alex * it under the terms of the GNU General Public License as published by
7 490f28ff 2002-12-12 alex * the Free Software Foundation; either version 2 of the License, or
8 490f28ff 2002-12-12 alex * (at your option) any later version.
9 490f28ff 2002-12-12 alex * Please read the file COPYING, README and AUTHORS for more information.
10 2ee05c9a 2002-03-03 alex *
11 490f28ff 2002-12-12 alex * IRC commands for server links
12 2ee05c9a 2002-03-03 alex */
13 2ee05c9a 2002-03-03 alex
14 2ee05c9a 2002-03-03 alex
15 ca33cbda 2002-03-12 alex #include "portab.h"
16 490f28ff 2002-12-12 alex
17 ca33cbda 2002-03-12 alex #include "imp.h"
18 2ee05c9a 2002-03-03 alex #include <assert.h>
19 2ee05c9a 2002-03-03 alex #include <stdio.h>
20 2ee05c9a 2002-03-03 alex #include <stdlib.h>
21 2ee05c9a 2002-03-03 alex #include <string.h>
22 57c7e236 2004-01-17 alex #include <strings.h>
23 2ee05c9a 2002-03-03 alex
24 3012c232 2004-05-11 alex #include "defines.h"
25 c2f60abe 2002-05-27 alex #include "resolve.h"
26 c2f60abe 2002-05-27 alex #include "conn.h"
27 a60465be 2008-09-23 alex #include "conn-func.h"
28 437f2c33 2003-12-30 alex #include "conn-zip.h"
29 a2544e49 2003-12-30 alex #include "conf.h"
30 c2f60abe 2002-05-27 alex #include "client.h"
31 c2f60abe 2002-05-27 alex #include "channel.h"
32 2ee05c9a 2002-03-03 alex #include "irc-write.h"
33 dd598200 2004-04-25 alex #include "lists.h"
34 2ee05c9a 2002-03-03 alex #include "log.h"
35 2ee05c9a 2002-03-03 alex #include "messages.h"
36 c2f60abe 2002-05-27 alex #include "parse.h"
37 47ca178a 2007-11-21 alex #include "numeric.h"
38 d58431a0 2002-09-02 alex #include "ngircd.h"
39 47ca178a 2007-11-21 alex #include "irc-info.h"
40 2ee05c9a 2002-03-03 alex
41 ca33cbda 2002-03-12 alex #include "exp.h"
42 2ee05c9a 2002-03-03 alex #include "irc-server.h"
43 fa7bb279 2006-12-07 fw
44 fa7bb279 2006-12-07 fw
45 27d947fb 2006-10-01 alex /**
46 27d947fb 2006-10-01 alex * Handler for the IRC command "SERVER".
47 27d947fb 2006-10-01 alex * See RFC 2813 section 4.1.2.
48 27d947fb 2006-10-01 alex */
49 8adff592 2005-03-19 fw GLOBAL bool
50 c2f60abe 2002-05-27 alex IRC_SERVER( CLIENT *Client, REQUEST *Req )
51 2ee05c9a 2002-03-03 alex {
52 47ca178a 2007-11-21 alex char str[LINE_LEN], *ptr;
53 47ca178a 2007-11-21 alex CLIENT *from, *c;
54 8adff592 2005-03-19 fw bool ok;
55 47ca178a 2007-11-21 alex int i;
56 65f3adca 2002-11-26 alex CONN_ID con;
57 2ee05c9a 2002-03-03 alex
58 2ee05c9a 2002-03-03 alex assert( Client != NULL );
59 2ee05c9a 2002-03-03 alex assert( Req != NULL );
60 2ee05c9a 2002-03-03 alex
61 27d947fb 2006-10-01 alex /* Return an error if this is not a local client */
62 27d947fb 2006-10-01 alex if (Client_Conn(Client) <= NONE)
63 27d947fb 2006-10-01 alex return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
64 27d947fb 2006-10-01 alex Client_ID(Client), Req->command);
65 2ee05c9a 2002-03-03 alex
66 a60465be 2008-09-23 alex if (Client_Type(Client) == CLIENT_GOTPASS ||
67 a60465be 2008-09-23 alex Client_Type(Client) == CLIENT_GOTPASS_2813) {
68 27d947fb 2006-10-01 alex /* We got a PASS command from the peer, and now a SERVER
69 27d947fb 2006-10-01 alex * command: the peer tries to register itself as a server. */
70 37602d15 2006-12-02 fw LogDebug("Connection %d: got SERVER command (new server link) ...",
71 37602d15 2006-12-02 fw Client_Conn(Client));
72 2ee05c9a 2002-03-03 alex
73 2ee05c9a 2002-03-03 alex /* Falsche Anzahl Parameter? */
74 2ee05c9a 2002-03-03 alex if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
75 2ee05c9a 2002-03-03 alex
76 2ee05c9a 2002-03-03 alex /* Ist dieser Server bei uns konfiguriert? */
77 a2544e49 2003-12-30 alex for( i = 0; i < MAX_SERVERS; i++ ) if( strcasecmp( Req->argv[0], Conf_Server[i].name ) == 0 ) break;
78 a2544e49 2003-12-30 alex if( i >= MAX_SERVERS )
79 2ee05c9a 2002-03-03 alex {
80 2ee05c9a 2002-03-03 alex /* Server ist nicht konfiguriert! */
81 2ee05c9a 2002-03-03 alex Log( LOG_ERR, "Connection %d: Server \"%s\" not configured here!", Client_Conn( Client ), Req->argv[0] );
82 8adff592 2005-03-19 fw Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", true);
83 2ee05c9a 2002-03-03 alex return DISCONNECTED;
84 2ee05c9a 2002-03-03 alex }
85 b2615bcc 2002-11-19 alex if( strcmp( Client_Password( Client ), Conf_Server[i].pwd_in ) != 0 )
86 2ee05c9a 2002-03-03 alex {
87 2ee05c9a 2002-03-03 alex /* Falsches Passwort */
88 b2615bcc 2002-11-19 alex Log( LOG_ERR, "Connection %d: Got bad password from server \"%s\"!", Client_Conn( Client ), Req->argv[0] );
89 8adff592 2005-03-19 fw Conn_Close( Client_Conn( Client ), NULL, "Bad password", true);
90 2ee05c9a 2002-03-03 alex return DISCONNECTED;
91 2ee05c9a 2002-03-03 alex }
92 2ee05c9a 2002-03-03 alex
93 2ee05c9a 2002-03-03 alex /* Ist ein Server mit dieser ID bereits registriert? */
94 2ee05c9a 2002-03-03 alex if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
95 2ee05c9a 2002-03-03 alex
96 2ee05c9a 2002-03-03 alex /* Server-Strukturen fuellen ;-) */
97 2ee05c9a 2002-03-03 alex Client_SetID( Client, Req->argv[0] );
98 2ee05c9a 2002-03-03 alex Client_SetHops( Client, 1 );
99 2ee05c9a 2002-03-03 alex Client_SetInfo( Client, Req->argv[Req->argc - 1] );
100 65f3adca 2002-11-26 alex
101 2310ac2c 2002-04-08 alex /* Meldet sich der Server bei uns an (d.h., bauen nicht wir
102 2310ac2c 2002-04-08 alex * selber die Verbindung zu einem anderen Server auf)? */
103 65f3adca 2002-11-26 alex con = Client_Conn( Client );
104 2310ac2c 2002-04-08 alex if( Client_Token( Client ) != TOKEN_OUTBOUND )
105 2ee05c9a 2002-03-03 alex {
106 2310ac2c 2002-04-08 alex /* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */
107 8adff592 2005-03-19 fw ok = true;
108 8adff592 2005-03-19 fw if( ! IRC_WriteStrClient( Client, "PASS %s %s", Conf_Server[i].pwd_out, NGIRCd_ProtoID )) ok = false;
109 2ee05c9a 2002-03-03 alex else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
110 2ee05c9a 2002-03-03 alex if( ! ok )
111 2ee05c9a 2002-03-03 alex {
112 8adff592 2005-03-19 fw Conn_Close( con, "Unexpected server behavior!", NULL, false );
113 2ee05c9a 2002-03-03 alex return DISCONNECTED;
114 2ee05c9a 2002-03-03 alex }
115 2ee05c9a 2002-03-03 alex Client_SetIntroducer( Client, Client );
116 2ee05c9a 2002-03-03 alex Client_SetToken( Client, 1 );
117 2ee05c9a 2002-03-03 alex }
118 2310ac2c 2002-04-08 alex else
119 2310ac2c 2002-04-08 alex {
120 2310ac2c 2002-04-08 alex /* Ausgehende verbindung, SERVER und PASS wurden von uns bereits
121 2310ac2c 2002-04-08 alex * an die Gegenseite uerbermittelt */
122 2310ac2c 2002-04-08 alex Client_SetToken( Client, atoi( Req->argv[1] ));
123 2310ac2c 2002-04-08 alex }
124 2ee05c9a 2002-03-03 alex
125 47ca178a 2007-11-21 alex /* Mark this connection as belonging to an configured server */
126 47ca178a 2007-11-21 alex Conf_SetServer(i, con);
127 a60465be 2008-09-23 alex
128 a60465be 2008-09-23 alex /* Check protocol level */
129 a60465be 2008-09-23 alex if (Client_Type(Client) == CLIENT_GOTPASS) {
130 a60465be 2008-09-23 alex /* We got a "simple" PASS command, so the peer is
131 a60465be 2008-09-23 alex * using the protocol as defined in RFC 1459. */
132 a60465be 2008-09-23 alex if (! (Conn_Options(con) & CONN_RFC1459))
133 a60465be 2008-09-23 alex Log(LOG_INFO,
134 a60465be 2008-09-23 alex "Switching connection %d (\"%s\") to RFC 1459 compatibility mode.",
135 a60465be 2008-09-23 alex con, Client_ID(Client));
136 a60465be 2008-09-23 alex Conn_SetOption(con, CONN_RFC1459);
137 a60465be 2008-09-23 alex }
138 a60465be 2008-09-23 alex
139 47ca178a 2007-11-21 alex Client_SetType(Client, CLIENT_UNKNOWNSERVER);
140 2ee05c9a 2002-03-03 alex
141 c40592d2 2003-12-26 alex #ifdef ZLIB
142 65f3adca 2002-11-26 alex /* Kompression initialisieren, wenn erforderlich */
143 65f3adca 2002-11-26 alex if( strchr( Client_Flags( Client ), 'Z' ))
144 65f3adca 2002-11-26 alex {
145 437f2c33 2003-12-30 alex if( ! Zip_InitConn( con ))
146 65f3adca 2002-11-26 alex {
147 65f3adca 2002-11-26 alex /* Fehler! */
148 8adff592 2005-03-19 fw Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, false );
149 65f3adca 2002-11-26 alex return DISCONNECTED;
150 65f3adca 2002-11-26 alex }
151 65f3adca 2002-11-26 alex }
152 65f3adca 2002-11-26 alex #endif
153 65f3adca 2002-11-26 alex
154 3dc16212 2002-09-07 alex #ifdef IRCPLUS
155 47ca178a 2007-11-21 alex if (strchr(Client_Flags(Client), 'H')) {
156 47ca178a 2007-11-21 alex LogDebug("Peer supports IRC+ extended server handshake ...");
157 47ca178a 2007-11-21 alex if (!IRC_Send_ISUPPORT(Client))
158 47ca178a 2007-11-21 alex return DISCONNECTED;
159 47ca178a 2007-11-21 alex return IRC_WriteStrClient(Client, RPL_ENDOFMOTD_MSG,
160 47ca178a 2007-11-21 alex Client_ID(Client));
161 47ca178a 2007-11-21 alex } else {
162 dd598200 2004-04-25 alex #endif
163 47ca178a 2007-11-21 alex if (Conf_MaxNickLength != CLIENT_NICK_LEN_DEFAULT)
164 47ca178a 2007-11-21 alex Log(LOG_CRIT,
165 47ca178a 2007-11-21 alex "Attention: this server uses a non-standard nick length, but the peer doesn't support the IRC+ extended server handshake!");
166 dd598200 2004-04-25 alex #ifdef IRCPLUS
167 6d3686e7 2006-04-30 alex }
168 dd598200 2004-04-25 alex #endif
169 2ee05c9a 2002-03-03 alex
170 47ca178a 2007-11-21 alex return IRC_Num_ENDOFMOTD(Client, Req);
171 2ee05c9a 2002-03-03 alex }
172 2ee05c9a 2002-03-03 alex else if( Client_Type( Client ) == CLIENT_SERVER )
173 2ee05c9a 2002-03-03 alex {
174 2ee05c9a 2002-03-03 alex /* Neuer Server wird im Netz angekuendigt */
175 2ee05c9a 2002-03-03 alex
176 2ee05c9a 2002-03-03 alex /* Falsche Anzahl Parameter? */
177 2ee05c9a 2002-03-03 alex if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
178 2ee05c9a 2002-03-03 alex
179 2ee05c9a 2002-03-03 alex /* Ist ein Server mit dieser ID bereits registriert? */
180 2ee05c9a 2002-03-03 alex if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
181 2ee05c9a 2002-03-03 alex
182 2ee05c9a 2002-03-03 alex /* Ueberfluessige Hostnamen aus Info-Text entfernen */
183 2ee05c9a 2002-03-03 alex ptr = strchr( Req->argv[3] + 2, '[' );
184 2ee05c9a 2002-03-03 alex if( ! ptr ) ptr = Req->argv[3];
185 2ee05c9a 2002-03-03 alex
186 bc4ed226 2002-03-25 alex from = Client_Search( Req->prefix );
187 2ee05c9a 2002-03-03 alex if( ! from )
188 2ee05c9a 2002-03-03 alex {
189 2ee05c9a 2002-03-03 alex /* Hm, Server, der diesen einfuehrt, ist nicht bekannt!? */
190 2ee05c9a 2002-03-03 alex Log( LOG_ALERT, "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)", Req->prefix, Client_Conn( Client ));
191 8adff592 2005-03-19 fw Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", true);
192 2ee05c9a 2002-03-03 alex return DISCONNECTED;
193 2ee05c9a 2002-03-03 alex }
194 2ee05c9a 2002-03-03 alex
195 2ee05c9a 2002-03-03 alex /* Neue Client-Struktur anlegen */
196 8adff592 2005-03-19 fw c = Client_NewRemoteServer( Client, Req->argv[0], from, atoi( Req->argv[1] ), atoi( Req->argv[2] ), ptr, true);
197 2ee05c9a 2002-03-03 alex if( ! c )
198 2ee05c9a 2002-03-03 alex {
199 2ee05c9a 2002-03-03 alex /* Neue Client-Struktur konnte nicht angelegt werden */
200 2ee05c9a 2002-03-03 alex Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client ));
201 8adff592 2005-03-19 fw Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", true);
202 2ee05c9a 2002-03-03 alex return DISCONNECTED;
203 2ee05c9a 2002-03-03 alex }
204 2ee05c9a 2002-03-03 alex
205 2ee05c9a 2002-03-03 alex /* Log-Meldung zusammenbauen und ausgeben */
206 b316c380 2002-12-26 alex if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) snprintf( str, sizeof( str ), "connected to %s, ", Client_ID( from ));
207 2ee05c9a 2002-03-03 alex else strcpy( str, "" );
208 6b58ab84 2002-03-27 alex Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
209 2ee05c9a 2002-03-03 alex
210 2ee05c9a 2002-03-03 alex /* Andere Server informieren */
211 2ee05c9a 2002-03-03 alex IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ));
212 2ee05c9a 2002-03-03 alex
213 2ee05c9a 2002-03-03 alex return CONNECTED;
214 47ca178a 2007-11-21 alex } else
215 47ca178a 2007-11-21 alex return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
216 47ca178a 2007-11-21 alex Client_ID(Client), Req->command);
217 2ee05c9a 2002-03-03 alex } /* IRC_SERVER */
218 2ee05c9a 2002-03-03 alex
219 2ee05c9a 2002-03-03 alex
220 8adff592 2005-03-19 fw GLOBAL bool
221 c2f60abe 2002-05-27 alex IRC_NJOIN( CLIENT *Client, REQUEST *Req )
222 2ee05c9a 2002-03-03 alex {
223 8adff592 2005-03-19 fw char nick_in[COMMAND_LEN], nick_out[COMMAND_LEN], *channame, *ptr, modes[8];
224 8adff592 2005-03-19 fw bool is_op, is_voiced;
225 2ee05c9a 2002-03-03 alex CHANNEL *chan;
226 2ee05c9a 2002-03-03 alex CLIENT *c;
227 2ee05c9a 2002-03-03 alex
228 2ee05c9a 2002-03-03 alex assert( Client != NULL );
229 2ee05c9a 2002-03-03 alex assert( Req != NULL );
230 2ee05c9a 2002-03-03 alex
231 2ee05c9a 2002-03-03 alex /* Falsche Anzahl Parameter? */
232 2ee05c9a 2002-03-03 alex if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
233 2ee05c9a 2002-03-03 alex
234 feafb6cb 2003-04-20 alex strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
235 feafb6cb 2003-04-20 alex strcpy( nick_out, "" );
236 e07fab17 2002-07-25 alex
237 2ee05c9a 2002-03-03 alex channame = Req->argv[0];
238 feafb6cb 2003-04-20 alex ptr = strtok( nick_in, "," );
239 2ee05c9a 2002-03-03 alex while( ptr )
240 2ee05c9a 2002-03-03 alex {
241 8adff592 2005-03-19 fw is_op = is_voiced = false;
242 2ee05c9a 2002-03-03 alex
243 2ee05c9a 2002-03-03 alex /* Prefixe abschneiden */
244 2ee05c9a 2002-03-03 alex while(( *ptr == '@' ) || ( *ptr == '+' ))
245 2ee05c9a 2002-03-03 alex {
246 8adff592 2005-03-19 fw if( *ptr == '@' ) is_op = true;
247 8adff592 2005-03-19 fw if( *ptr == '+' ) is_voiced = true;
248 2ee05c9a 2002-03-03 alex ptr++;
249 2ee05c9a 2002-03-03 alex }
250 2ee05c9a 2002-03-03 alex
251 bc4ed226 2002-03-25 alex c = Client_Search( ptr );
252 2ee05c9a 2002-03-03 alex if( c )
253 2ee05c9a 2002-03-03 alex {
254 2ee05c9a 2002-03-03 alex Channel_Join( c, channame );
255 2ee05c9a 2002-03-03 alex chan = Channel_Search( channame );
256 2ee05c9a 2002-03-03 alex assert( chan != NULL );
257 2ee05c9a 2002-03-03 alex
258 2ee05c9a 2002-03-03 alex if( is_op ) Channel_UserModeAdd( chan, c, 'o' );
259 2ee05c9a 2002-03-03 alex if( is_voiced ) Channel_UserModeAdd( chan, c, 'v' );
260 2ee05c9a 2002-03-03 alex
261 2ee05c9a 2002-03-03 alex /* im Channel bekannt machen */
262 8adff592 2005-03-19 fw IRC_WriteStrChannelPrefix( Client, chan, c, false, "JOIN :%s", channame );
263 2ee05c9a 2002-03-03 alex
264 2ee05c9a 2002-03-03 alex /* Channel-User-Modes setzen */
265 695631b2 2002-12-26 alex strlcpy( modes, Channel_UserModes( chan, c ), sizeof( modes ));
266 2ee05c9a 2002-03-03 alex if( modes[0] )
267 2ee05c9a 2002-03-03 alex {
268 2ee05c9a 2002-03-03 alex /* Modes im Channel bekannt machen */
269 8adff592 2005-03-19 fw IRC_WriteStrChannelPrefix( Client, chan, Client, false, "MODE %s +%s %s", channame, modes, Client_ID( c ));
270 2ee05c9a 2002-03-03 alex }
271 feafb6cb 2003-04-20 alex
272 feafb6cb 2003-04-20 alex if( nick_out[0] != '\0' ) strlcat( nick_out, ",", sizeof( nick_out ));
273 6647da58 2003-07-09 alex if( is_op ) strlcat( nick_out, "@", sizeof( nick_out ));
274 6647da58 2003-07-09 alex if( is_voiced ) strlcat( nick_out, "+", sizeof( nick_out ));
275 feafb6cb 2003-04-20 alex strlcat( nick_out, ptr, sizeof( nick_out ));
276 2ee05c9a 2002-03-03 alex }
277 7d30c8ce 2002-08-26 alex else Log( LOG_ERR, "Got NJOIN for unknown nick \"%s\" for channel \"%s\"!", ptr, channame );
278 2ee05c9a 2002-03-03 alex
279 2ee05c9a 2002-03-03 alex /* naechsten Nick suchen */
280 2ee05c9a 2002-03-03 alex ptr = strtok( NULL, "," );
281 2ee05c9a 2002-03-03 alex }
282 2ee05c9a 2002-03-03 alex
283 2ee05c9a 2002-03-03 alex /* an andere Server weiterleiten */
284 feafb6cb 2003-04-20 alex if( nick_out[0] != '\0' ) IRC_WriteStrServersPrefix( Client, Client_ThisServer( ), "NJOIN %s :%s", Req->argv[0], nick_out );
285 2ee05c9a 2002-03-03 alex
286 2ee05c9a 2002-03-03 alex return CONNECTED;
287 2ee05c9a 2002-03-03 alex } /* IRC_NJOIN */
288 2ee05c9a 2002-03-03 alex
289 2ee05c9a 2002-03-03 alex
290 8adff592 2005-03-19 fw GLOBAL bool
291 c2f60abe 2002-05-27 alex IRC_SQUIT( CLIENT *Client, REQUEST *Req )
292 2ee05c9a 2002-03-03 alex {
293 2ee05c9a 2002-03-03 alex CLIENT *target;
294 8adff592 2005-03-19 fw char msg[LINE_LEN + 64];
295 2ee05c9a 2002-03-03 alex
296 2ee05c9a 2002-03-03 alex assert( Client != NULL );
297 2ee05c9a 2002-03-03 alex assert( Req != NULL );
298 2ee05c9a 2002-03-03 alex
299 2ee05c9a 2002-03-03 alex /* Falsche Anzahl Parameter? */
300 2ee05c9a 2002-03-03 alex if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
301 2ee05c9a 2002-03-03 alex
302 2ee05c9a 2002-03-03 alex Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] );
303 2ee05c9a 2002-03-03 alex
304 bc4ed226 2002-03-25 alex target = Client_Search( Req->argv[0] );
305 2ee05c9a 2002-03-03 alex if( ! target )
306 2ee05c9a 2002-03-03 alex {
307 9fc7e66f 2002-03-11 alex /* Den Server kennen wir nicht (mehr), also nichts zu tun. */
308 f7a0ff1f 2002-03-11 alex Log( LOG_WARNING, "Got SQUIT from %s for unknown server \"%s\"!?", Client_ID( Client ), Req->argv[0] );
309 2ee05c9a 2002-03-03 alex return CONNECTED;
310 2ee05c9a 2002-03-03 alex }
311 2ee05c9a 2002-03-03 alex
312 2ee05c9a 2002-03-03 alex if( Req->argv[1][0] )
313 2ee05c9a 2002-03-03 alex {
314 2ee05c9a 2002-03-03 alex if( strlen( Req->argv[1] ) > LINE_LEN ) Req->argv[1][LINE_LEN] = '\0';
315 b316c380 2002-12-26 alex snprintf( msg, sizeof( msg ), "%s (SQUIT from %s).", Req->argv[1], Client_ID( Client ));
316 2ee05c9a 2002-03-03 alex }
317 b316c380 2002-12-26 alex else snprintf( msg, sizeof( msg ), "Got SQUIT from %s.", Client_ID( Client ));
318 2ee05c9a 2002-03-03 alex
319 2ee05c9a 2002-03-03 alex if( Client_Conn( target ) > NONE )
320 2ee05c9a 2002-03-03 alex {
321 2ee05c9a 2002-03-03 alex /* dieser Server hat die Connection */
322 8adff592 2005-03-19 fw if( Req->argv[1][0] ) Conn_Close( Client_Conn( target ), msg, Req->argv[1], true);
323 8adff592 2005-03-19 fw else Conn_Close( Client_Conn( target ), msg, NULL, true);
324 2ee05c9a 2002-03-03 alex return DISCONNECTED;
325 2ee05c9a 2002-03-03 alex }
326 2ee05c9a 2002-03-03 alex else
327 2ee05c9a 2002-03-03 alex {
328 2ee05c9a 2002-03-03 alex /* Verbindung hielt anderer Server */
329 8adff592 2005-03-19 fw Client_Destroy( target, msg, Req->argv[1], false );
330 2ee05c9a 2002-03-03 alex return CONNECTED;
331 2ee05c9a 2002-03-03 alex }
332 2ee05c9a 2002-03-03 alex } /* IRC_SQUIT */
333 2ee05c9a 2002-03-03 alex
334 2ee05c9a 2002-03-03 alex
335 2ee05c9a 2002-03-03 alex /* -eof- */