ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_server.c
Revision: 1239
Committed: Thu Sep 29 14:02:25 2011 UTC (14 years, 9 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/core/m_server.c
File size: 22432 byte(s)
Log Message:
- minor cleanup to m_sid and m_server: replace DLINK_FOREACH loops
 with sendto_server()

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

Properties

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