ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_server.c
Revision: 1219
Committed: Sun Sep 18 09:02:38 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/core/m_server.c
File size: 22978 byte(s)
Log Message:
- Start cleaning up macros in client.h. Replace several ClientHasSomeCoolFlag()
with simple HasFlag/HasUMode macros.

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

Properties

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