ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_server.c
Revision: 1385
Committed: Tue May 1 11:31:35 2012 UTC (14 years, 5 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/core/m_server.c
File size: 21855 byte(s)
Log Message:
- ms_server(), ms_sid(): it's client_p which has an attached
  CONF_SERVER, not source_p. Stupid me.

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_server.c: Introduces a server.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "client.h" /* client struct */
28     #include "event.h"
29     #include "hash.h" /* add_to_client_hash_table */
30     #include "irc_string.h"
31     #include "ircd.h" /* me */
32     #include "numeric.h" /* ERR_xxx */
33 michael 1309 #include "conf.h" /* struct AccessItem */
34     #include "log.h" /* log level defines */
35 michael 1118 #include "s_serv.h" /* server_estab, check_server */
36     #include "s_user.h"
37 adx 30 #include "send.h" /* sendto_one */
38     #include "parse.h"
39     #include "modules.h"
40    
41    
42     static void set_server_gecos(struct Client *, char *);
43    
44     /* mr_server()
45     * parv[0] = sender prefix
46     * parv[1] = servername
47     * parv[2] = serverinfo/hopcount
48     * parv[3] = serverinfo
49     */
50     static void
51     mr_server(struct Client *client_p, struct Client *source_p,
52     int parc, char *parv[])
53     {
54     char info[REALLEN + 1];
55     char *name;
56     struct Client *target_p;
57     int hop;
58    
59 michael 1178 if (EmptyString(parv[3]))
60 adx 30 {
61     sendto_one(client_p, "ERROR :No servername");
62     exit_client(client_p, client_p, "Wrong number of args");
63     return;
64     }
65    
66     name = parv[1];
67     hop = atoi(parv[2]);
68     strlcpy(info, parv[3], sizeof(info));
69    
70 michael 1118 /*
71     * Reject a direct nonTS server connection if we're TS_ONLY -orabidoo
72 adx 30 */
73     if (!DoesTS(client_p))
74     {
75 michael 1118 sendto_realops_flags(UMODE_ALL, L_ADMIN,
76     "Unauthorized server connection attempt from %s: Non-TS server "
77     "for server %s", get_client_name(client_p, HIDE_IP), name);
78     sendto_realops_flags(UMODE_ALL, L_OPER,
79     "Unauthorized server connection attempt from %s: Non-TS server "
80     "for server %s", get_client_name(client_p, MASK_IP), name);
81 adx 30 exit_client(client_p, client_p, "Non-TS server");
82     return;
83     }
84    
85 michael 1118 if (!valid_servname(name))
86 adx 30 {
87 michael 1118 sendto_realops_flags(UMODE_ALL, L_ADMIN,
88     "Unauthorized server connection attempt from %s: Bogus server name "
89     "for server %s", get_client_name(client_p, HIDE_IP), name);
90     sendto_realops_flags(UMODE_ALL, L_OPER,
91     "Unauthorized server connection attempt from %s: Bogus server name "
92     "for server %s", get_client_name(client_p, MASK_IP), name);
93 adx 30 exit_client(client_p, client_p, "Bogus server name");
94     return;
95     }
96    
97     /* Now we just have to call check_server and everything should
98     * be check for us... -A1kmm.
99     */
100 michael 1302 switch (check_server(name, client_p))
101 adx 30 {
102     case -1:
103     if (ConfigFileEntry.warn_no_nline)
104     {
105     sendto_realops_flags(UMODE_ALL, L_ADMIN,
106     "Unauthorized server connection attempt from %s: No entry for "
107     "servername %s", get_client_name(client_p, HIDE_IP), name);
108    
109     sendto_realops_flags(UMODE_ALL, L_OPER,
110     "Unauthorized server connection attempt from %s: No entry for "
111     "servername %s", get_client_name(client_p, MASK_IP), name);
112     }
113    
114     exit_client(client_p, client_p, "Invalid servername.");
115     return;
116     /* NOT REACHED */
117     break;
118    
119     case -2:
120     sendto_realops_flags(UMODE_ALL, L_ADMIN,
121     "Unauthorized server connection attempt from %s: Bad password "
122     "for server %s", get_client_name(client_p, HIDE_IP), name);
123    
124     sendto_realops_flags(UMODE_ALL, L_OPER,
125     "Unauthorized server connection attempt from %s: Bad password "
126     "for server %s", get_client_name(client_p, MASK_IP), name);
127    
128     exit_client(client_p, client_p, "Invalid password.");
129     return;
130     /* NOT REACHED */
131     break;
132    
133     case -3:
134     sendto_realops_flags(UMODE_ALL, L_ADMIN,
135     "Unauthorized server connection attempt from %s: Invalid host "
136     "for server %s", get_client_name(client_p, HIDE_IP), name);
137    
138     sendto_realops_flags(UMODE_ALL, L_OPER,
139     "Unauthorized server connection attempt from %s: Invalid host "
140     "for server %s", get_client_name(client_p, MASK_IP), name);
141    
142     exit_client(client_p, client_p, "Invalid host.");
143     return;
144     /* NOT REACHED */
145     break;
146    
147     /* servername is > HOSTLEN */
148     case -4:
149     sendto_realops_flags(UMODE_ALL, L_ADMIN,
150     "Invalid servername %s from %s",
151     name, get_client_name(client_p, HIDE_IP));
152     sendto_realops_flags(UMODE_ALL, L_OPER,
153     "Invalid servername %s from %s",
154     name, get_client_name(client_p, MASK_IP));
155    
156     exit_client(client_p, client_p, "Invalid servername.");
157     return;
158     /* NOT REACHED */
159     break;
160     }
161    
162 michael 1115 if ((client_p->id[0] && (target_p = hash_find_id(client_p->id)))
163 michael 1169 || (target_p = hash_find_server(name)))
164 adx 30 {
165     /* This link is trying feed me a server that I already have
166     * access through another path -- multiple paths not accepted
167     * currently, kill this link immediately!!
168     *
169     * Rather than KILL the link which introduced it, KILL the
170     * youngest of the two links. -avalon
171     *
172     * Definitely don't do that here. This is from an unregistered
173     * connect - A1kmm.
174     */
175     sendto_realops_flags(UMODE_ALL, L_ADMIN,
176     "Attempt to re-introduce server %s SID %s from %s",
177     name, client_p->id,
178     get_client_name(client_p, HIDE_IP));
179     sendto_realops_flags(UMODE_ALL, L_OPER,
180     "Attempt to re-introduce server %s SID %s from %s",
181     name, client_p->id,
182     get_client_name(client_p, MASK_IP));
183     sendto_one(client_p, "ERROR :Server ID already exists.");
184     exit_client(client_p, client_p, "Server ID Exists");
185     return;
186     }
187    
188     /* XXX If somehow there is a connect in progress and
189     * a connect comes in with same name toss the pending one,
190     * but only if it's not the same client! - Dianora
191     */
192     if ((target_p = find_servconn_in_progress(name)))
193     if (target_p != client_p)
194     exit_client(target_p, &me, "Overridden");
195    
196     /* if we are connecting (Handshake), we already have the name from the
197     * connect{} block in client_p->name
198     */
199     strlcpy(client_p->name, name, sizeof(client_p->name));
200     set_server_gecos(client_p, info);
201     client_p->hopcount = hop;
202     server_estab(client_p);
203     }
204    
205     /* ms_server()
206     * parv[0] = sender prefix
207     * parv[1] = servername
208     * parv[2] = serverinfo/hopcount
209     * parv[3] = serverinfo
210     */
211     static void
212     ms_server(struct Client *client_p, struct Client *source_p,
213     int parc, char *parv[])
214     {
215     char info[REALLEN + 1];
216     char *name;
217     struct Client *target_p;
218 michael 1383 struct AccessItem *aconf;
219 adx 30 int hop;
220     int hlined = 0;
221     int llined = 0;
222 michael 1321 dlink_node *ptr = NULL;
223 adx 30
224     /* Just to be sure -A1kmm. */
225     if (!IsServer(source_p))
226     return;
227    
228 michael 1178 if (EmptyString(parv[3]))
229 adx 30 {
230     sendto_one(client_p, "ERROR :No servername");
231     return;
232     }
233    
234     name = parv[1];
235     hop = atoi(parv[2]);
236     strlcpy(info, parv[3], sizeof(info));
237    
238 michael 1118 if (!valid_servname(name))
239 adx 30 {
240 michael 1118 sendto_realops_flags(UMODE_ALL, L_ADMIN,
241     "Link %s introduced server with bogus server name %s",
242     get_client_name(client_p, SHOW_IP), name);
243     sendto_realops_flags(UMODE_ALL, L_OPER,
244     "Link %s introduced server with bogus server name %s",
245     get_client_name(client_p, MASK_IP), name);
246     sendto_one(client_p, "ERROR :Bogus server name introduced");
247     exit_client(client_p, &me, "Bogus server name intoduced");
248     return;
249     }
250    
251 michael 1169 if ((target_p = hash_find_server(name)))
252 michael 1118 {
253 adx 30 /* This link is trying feed me a server that I already have
254     * access through another path -- multiple paths not accepted
255     * currently, kill this link immediately!!
256     *
257     * Rather than KILL the link which introduced it, KILL the
258     * youngest of the two links. -avalon
259     *
260     * I think that we should exit the link itself, not the introducer,
261     * and we should always exit the most recently received(i.e. the
262     * one we are receiving this SERVER for. -A1kmm
263     *
264     * You *cant* do this, if you link somewhere, it bursts you a server
265     * that already exists, then sends you a client burst, you squit the
266     * server, but you keep getting the burst of clients on a server that
267     * doesnt exist, although ircd can handle it, its not a realistic
268     * solution.. --fl_
269     */
270     /* It is behind a host-masked server. Completely ignore the
271     * server message(don't propagate or we will delink from whoever
272     * we propagate to). -A1kmm
273     */
274     if (irccmp(target_p->name, name) && target_p->from == client_p)
275     return;
276    
277     sendto_one(client_p, "ERROR :Server %s already exists", name);
278     sendto_realops_flags(UMODE_ALL, L_ADMIN,
279     "Link %s cancelled, server %s already exists",
280     get_client_name(client_p, SHOW_IP), name);
281     sendto_realops_flags(UMODE_ALL, L_OPER,
282     "Link %s cancelled, server %s already exists",
283     client_p->name, name);
284     exit_client(client_p, &me, "Server Exists");
285     return;
286     }
287    
288     /* XXX If somehow there is a connect in progress and
289     * a connect comes in with same name toss the pending one,
290     * but only if it's not the same client! - Dianora
291     */
292     if ((target_p = find_servconn_in_progress(name)))
293     if (target_p != client_p)
294     exit_client(target_p, &me, "Overridden");
295    
296 michael 1385 aconf = map_to_conf(client_p->localClient->confs.head->data);
297 michael 1383
298 adx 30 /* See if the newly found server is behind a guaranteed
299     * leaf. If so, close the link.
300     */
301 michael 1383 DLINK_FOREACH(ptr, aconf->leaf_list.head)
302     if (match(ptr->data, name))
303     ++llined;
304 adx 30
305 michael 1383 DLINK_FOREACH(ptr, aconf->hub_list.head)
306     if (match(ptr->data, name))
307     ++hlined;
308 michael 1118
309 adx 30 /* Ok, this way this works is
310     *
311     * A server can have a CONF_HUB allowing it to introduce servers
312     * behind it.
313     *
314     * connect {
315     * name = "irc.bighub.net";
316     * hub_mask="*";
317     * ...
318     *
319     * That would allow "irc.bighub.net" to introduce anything it wanted..
320     *
321     * However
322     *
323     * connect {
324     * name = "irc.somehub.fi";
325     * hub_mask="*";
326     * leaf_mask="*.edu";
327     *...
328     * Would allow this server in finland to hub anything but
329     * .edu's
330     */
331    
332 michael 885 /* Ok, check client_p can hub the new server */
333     if (!hlined)
334 adx 30 {
335     /* OOOPs nope can't HUB */
336     sendto_realops_flags(UMODE_ALL, L_ADMIN, "Non-Hub link %s introduced %s.",
337     get_client_name(client_p, HIDE_IP), name);
338     sendto_realops_flags(UMODE_ALL, L_OPER, "Non-Hub link %s introduced %s.",
339     get_client_name(client_p, MASK_IP), name);
340     exit_client(source_p, &me, "No matching hub_mask.");
341     return;
342     }
343    
344     /* Check for the new server being leafed behind this HUB */
345     if (llined)
346     {
347     /* OOOPs nope can't HUB this leaf */
348     sendto_realops_flags(UMODE_ALL, L_ADMIN,
349     "Link %s introduced leafed server %s.",
350     get_client_name(client_p, HIDE_IP), name);
351     sendto_realops_flags(UMODE_ALL, L_OPER,
352     "Link %s introduced leafed server %s.",
353 michael 1118 get_client_name(client_p, MASK_IP), name);
354     /* If it is new, we are probably misconfigured, so split the
355     * non-hub server introducing this. Otherwise, split the new
356     * server. -A1kmm.
357     */
358     /* wastes too much bandwidth, generates too many errors on
359     * larger networks, dont bother. --fl_
360     */
361     exit_client(client_p, &me, "Leafed Server.");
362     return;
363 adx 30 }
364    
365     target_p = make_client(client_p);
366     make_server(target_p);
367     target_p->hopcount = hop;
368 michael 1118 target_p->servptr = source_p;
369 adx 30
370     strlcpy(target_p->name, name, sizeof(target_p->name));
371    
372     set_server_gecos(target_p, info);
373     SetServer(target_p);
374    
375 michael 1219 if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(SERVICE_TYPE, target_p->name, NULL, NULL, 0))
376     AddFlag(target_p, FLAGS_SERVICE);
377 michael 1157
378 michael 1118 dlinkAdd(target_p, &target_p->node, &global_client_list);
379     dlinkAdd(target_p, make_dlink_node(), &global_serv_list);
380     dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->server_list);
381 adx 30
382     hash_add_client(target_p);
383    
384 michael 1239 sendto_server(client_p, NULL, NOCAPS, NOCAPS, ":%s SERVER %s %d :%s%s",
385     source_p->name, target_p->name, hop + 1,
386     IsHidden(target_p) ? "(H) " : "", target_p->info);
387 adx 30
388     sendto_realops_flags(UMODE_EXTERNAL, L_ALL,
389 michael 1118 "Server %s being introduced by %s",
390 adx 30 target_p->name, source_p->name);
391     }
392    
393     /* ms_sid()
394     * parv[0] = sender prefix
395     * parv[1] = servername
396     * parv[2] = serverinfo/hopcount
397     * parv[3] = sid of new server
398     * parv[4] = serverinfo
399     */
400     static void
401     ms_sid(struct Client *client_p, struct Client *source_p,
402     int parc, char *parv[])
403     {
404     char info[REALLEN + 1];
405     struct Client *target_p;
406 michael 1383 struct AccessItem *aconf = NULL;
407 adx 30 int hlined = 0;
408     int llined = 0;
409 michael 1321 dlink_node *ptr = NULL;
410 adx 30 int hop;
411    
412     /* Just to be sure -A1kmm. */
413     if (!IsServer(source_p))
414     return;
415    
416 michael 1178 if (EmptyString(parv[4]))
417 michael 1118 {
418     sendto_one(client_p, "ERROR :No servername");
419     return;
420     }
421 adx 30
422 michael 1118 hop = atoi(parv[2]);
423     strlcpy(info, parv[4], sizeof(info));
424    
425     if (!valid_servname(parv[1]))
426     {
427     sendto_realops_flags(UMODE_ALL, L_ADMIN,
428     "Link %s introduced server with bogus server name %s",
429     get_client_name(client_p, SHOW_IP), parv[1]);
430     sendto_realops_flags(UMODE_ALL, L_OPER,
431     "Link %s introduced server with bogus server name %s",
432     get_client_name(client_p, MASK_IP), parv[1]);
433     sendto_one(client_p, "ERROR :Bogus server name introduced");
434     exit_client(client_p, &me, "Bogus server name intoduced");
435     return;
436     }
437    
438     if (!valid_sid(parv[3]))
439     {
440     sendto_realops_flags(UMODE_ALL, L_ADMIN,
441     "Link %s introduced server with bogus server ID %s",
442     get_client_name(client_p, SHOW_IP), parv[3]);
443     sendto_realops_flags(UMODE_ALL, L_OPER,
444     "Link %s introduced server with bogus server ID %s",
445     get_client_name(client_p, MASK_IP), parv[3]);
446     sendto_one(client_p, "ERROR :Bogus server ID introduced");
447     exit_client(client_p, &me, "Bogus server ID intoduced");
448     return;
449     }
450    
451 adx 30 /* collision on SID? */
452 michael 1118 if ((target_p = hash_find_id(parv[3])))
453 adx 30 {
454 michael 1118 sendto_one(client_p, "ERROR :SID %s already exists", parv[3]);
455 adx 30 sendto_realops_flags(UMODE_ALL, L_ADMIN,
456     "Link %s cancelled, SID %s already exists",
457 michael 1118 get_client_name(client_p, SHOW_IP), parv[3]);
458 adx 30 sendto_realops_flags(UMODE_ALL, L_OPER,
459     "Link %s cancelled, SID %s already exists",
460 michael 1118 client_p->name, parv[3]);
461 adx 30 exit_client(client_p, &me, "Server Exists");
462     return;
463     }
464    
465     /* collision on name? */
466 michael 1169 if ((target_p = hash_find_server(parv[1])))
467 adx 30 {
468 michael 1118 sendto_one(client_p, "ERROR :Server %s already exists", parv[1]);
469 adx 30 sendto_realops_flags(UMODE_ALL, L_ADMIN,
470     "Link %s cancelled, server %s already exists",
471 michael 1118 get_client_name(client_p, SHOW_IP), parv[1]);
472 adx 30 sendto_realops_flags(UMODE_ALL, L_OPER,
473     "Link %s cancelled, server %s already exists",
474 michael 1118 client_p->name, parv[1]);
475 adx 30 exit_client(client_p, &me, "Server Exists");
476     return;
477     }
478    
479     /* XXX If somehow there is a connect in progress and
480     * a connect comes in with same name toss the pending one,
481     * but only if it's not the same client! - Dianora
482     */
483 michael 1118 if ((target_p = find_servconn_in_progress(parv[1])))
484 adx 30 if (target_p != client_p)
485     exit_client(target_p, &me, "Overridden");
486    
487 michael 1385 aconf = map_to_conf(client_p->localClient->confs.head->data);
488 michael 1384
489 adx 30 /* See if the newly found server is behind a guaranteed
490     * leaf. If so, close the link.
491     */
492 michael 1383 DLINK_FOREACH(ptr, aconf->leaf_list.head)
493     if (match(ptr->data, parv[1]))
494     ++llined;
495 adx 30
496 michael 1383 DLINK_FOREACH(ptr, aconf->hub_list.head)
497     if (match(ptr->data, parv[1]))
498     ++hlined;
499 michael 1118
500 adx 30
501     /* Ok, this way this works is
502     *
503     * A server can have a CONF_HUB allowing it to introduce servers
504     * behind it.
505     *
506     * connect {
507     * name = "irc.bighub.net";
508     * hub_mask="*";
509     * ...
510     *
511     * That would allow "irc.bighub.net" to introduce anything it wanted..
512     *
513     * However
514     *
515     * connect {
516     * name = "irc.somehub.fi";
517     * hub_mask="*";
518     * leaf_mask="*.edu";
519     *...
520     * Would allow this server in finland to hub anything but
521     * .edu's
522     */
523    
524     /* Ok, check client_p can hub the new server, and make sure it's not a LL */
525 michael 885 if (!hlined)
526 adx 30 {
527     /* OOOPs nope can't HUB */
528     sendto_realops_flags(UMODE_ALL, L_ADMIN, "Non-Hub link %s introduced %s.",
529 michael 1118 get_client_name(client_p, SHOW_IP), parv[1]);
530 adx 30 sendto_realops_flags(UMODE_ALL, L_OPER, "Non-Hub link %s introduced %s.",
531 michael 1118 get_client_name(client_p, MASK_IP), parv[1]);
532 adx 30 exit_client(source_p, &me, "No matching hub_mask.");
533     return;
534     }
535    
536     /* Check for the new server being leafed behind this HUB */
537     if (llined)
538     {
539     /* OOOPs nope can't HUB this leaf */
540     sendto_realops_flags(UMODE_ALL, L_ADMIN,
541     "Link %s introduced leafed server %s.",
542 michael 1118 get_client_name(client_p, SHOW_IP), parv[1]);
543 adx 30 sendto_realops_flags(UMODE_ALL, L_OPER,
544     "Link %s introduced leafed server %s.",
545 michael 1118 get_client_name(client_p, MASK_IP), parv[1]);
546 adx 30 exit_client(client_p, &me, "Leafed Server.");
547     return;
548     }
549    
550     target_p = make_client(client_p);
551     make_server(target_p);
552     target_p->hopcount = hop;
553 michael 1118 target_p->servptr = source_p;
554 adx 30
555 michael 1118 strlcpy(target_p->name, parv[1], sizeof(target_p->name));
556     strlcpy(target_p->id, parv[3], sizeof(target_p->id));
557 adx 30
558     set_server_gecos(target_p, info);
559     SetServer(target_p);
560    
561 michael 1219 if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(SERVICE_TYPE, target_p->name, NULL, NULL, 0))
562     AddFlag(target_p, FLAGS_SERVICE);
563 michael 1157
564 michael 1118 dlinkAdd(target_p, &target_p->node, &global_client_list);
565     dlinkAdd(target_p, make_dlink_node(), &global_serv_list);
566     dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->server_list);
567 adx 30
568     hash_add_client(target_p);
569     hash_add_id(target_p);
570    
571 michael 1239 sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s SID %s %d %s :%s%s",
572     ID_or_name(source_p, client_p), target_p->name, hop + 1,
573     IsHidden(target_p) ? "(H) " : "", target_p->info);
574     sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s SERVER %s %d :%s%s",
575     source_p->name, target_p->name, hop + 1,
576     IsHidden(target_p) ? "(H) " : "", target_p->info);
577 adx 30
578     sendto_realops_flags(UMODE_EXTERNAL, L_ALL,
579 michael 1118 "Server %s being introduced by %s",
580 adx 30 target_p->name, source_p->name);
581     }
582    
583     /* set_server_gecos()
584     *
585     * input - pointer to client
586     * output - NONE
587     * side effects - servers gecos field is set
588     */
589     static void
590     set_server_gecos(struct Client *client_p, char *info)
591     {
592     /* check the info for [IP] */
593     if (info[0])
594     {
595     char *p;
596     char *s;
597     char *t;
598    
599     s = info;
600    
601     /* we should only check the first word for an ip */
602     if ((p = strchr(s, ' ')) != NULL)
603     *p = '\0';
604    
605     /* check for a ] which would symbolise an [IP] */
606     if ((t = strchr(s, ']')) != NULL)
607     {
608     /* set s to after the first space */
609     if (p)
610     s = ++p;
611     else
612     s = NULL;
613     }
614     /* no ], put the space back */
615     else if (p)
616     *p = ' ';
617    
618     /* p may have been set to a trailing space, so check s exists and that
619     * it isnt \0 */
620     if (s && (*s != '\0'))
621     {
622     /* a space? if not (H) could be the last part of info.. */
623     if ((p = strchr(s, ' ')))
624     *p = '\0';
625    
626     /* check for (H) which is a hidden server */
627     if (!strcmp(s, "(H)"))
628     {
629     SetHidden(client_p);
630    
631     /* if there was no space.. theres nothing to set info to */
632     if (p)
633     s = ++p;
634     else
635     s = NULL;
636     }
637     else if (p)
638     *p = ' ';
639    
640     /* if there was a trailing space, s could point to \0, so check */
641     if (s && (*s != '\0'))
642     strlcpy(client_p->info, s, sizeof(client_p->info));
643     else
644     strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
645     }
646     else
647     strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
648     }
649     else
650     strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
651     }
652 michael 1230
653     static struct Message server_msgtab = {
654     "SERVER", 0, 0, 4, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0,
655     {mr_server, m_registered, ms_server, m_ignore, m_registered, m_ignore}
656     };
657    
658     static struct Message sid_msgtab = {
659     "SID", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
660     {rfc1459_command_send_error, m_ignore, ms_sid, m_ignore, m_ignore, m_ignore}
661     };
662    
663     static void
664     module_init(void)
665     {
666     mod_add_cmd(&sid_msgtab);
667     mod_add_cmd(&server_msgtab);
668     }
669    
670     static void
671     module_exit(void)
672     {
673     mod_del_cmd(&sid_msgtab);
674     mod_del_cmd(&server_msgtab);
675     }
676    
677     struct module module_entry = {
678     .node = { NULL, NULL, NULL },
679     .name = NULL,
680     .version = "$Revision$",
681     .handle = NULL,
682     .modinit = module_init,
683     .modexit = module_exit,
684     .flags = MODULE_FLAG_CORE
685     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision