ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_server.c
Revision: 1118
Committed: Thu Jan 6 13:39:10 2011 UTC (15 years, 9 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/core/m_server.c
File size: 22715 byte(s)
Log Message:
- cleanup and sanitize m_server.c. remove hostmasking. Improve TS6 suppport

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

Properties

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