]> jfr.im git - solanum.git/blob - modules/core/m_server.c
server: Move required CAPAB check after authentication and add snote and log.
[solanum.git] / modules / core / m_server.c
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_server.c: Introduces a server.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
24 * $Id: m_server.c 3291 2007-03-28 14:30:10Z jilles $
25 */
26
27 #include "stdinc.h"
28 #include "client.h" /* client struct */
29 #include "common.h" /* TRUE bleah */
30 #include "hash.h" /* add_to_client_hash */
31 #include "match.h"
32 #include "ircd.h" /* me */
33 #include "numeric.h" /* ERR_xxx */
34 #include "s_conf.h" /* struct ConfItem */
35 #include "s_newconf.h"
36 #include "logger.h" /* log level defines */
37 #include "s_serv.h" /* server_estab, check_server */
38 #include "s_stats.h" /* ServerStats */
39 #include "scache.h"
40 #include "send.h" /* sendto_one */
41 #include "msg.h"
42 #include "parse.h"
43 #include "modules.h"
44
45 static int mr_server(struct Client *, struct Client *, int, const char **);
46 static int ms_server(struct Client *, struct Client *, int, const char **);
47 static int ms_sid(struct Client *, struct Client *, int, const char **);
48
49 struct Message server_msgtab = {
50 "SERVER", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
51 {{mr_server, 4}, mg_reg, mg_ignore, {ms_server, 4}, mg_ignore, mg_reg}
52 };
53 struct Message sid_msgtab = {
54 "SID", 0, 0, 0, MFLG_SLOW,
55 {mg_ignore, mg_reg, mg_ignore, {ms_sid, 5}, mg_ignore, mg_reg}
56 };
57
58 mapi_clist_av1 server_clist[] = { &server_msgtab, &sid_msgtab, NULL };
59
60 DECLARE_MODULE_AV1(server, NULL, NULL, server_clist, NULL, NULL, "$Revision: 3291 $");
61
62 int bogus_host(const char *host);
63 static int set_server_gecos(struct Client *, const char *);
64
65 /*
66 * mr_server - SERVER message handler
67 * parv[1] = servername
68 * parv[2] = serverinfo/hopcount
69 * parv[3] = serverinfo
70 */
71 static int
72 mr_server(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
73 {
74 char info[REALLEN + 1];
75 const char *name;
76 struct Client *target_p;
77 int hop;
78 unsigned int required_mask;
79
80 name = parv[1];
81 hop = atoi(parv[2]);
82 rb_strlcpy(info, parv[3], sizeof(info));
83
84 if (IsHandshake(client_p) && irccmp(client_p->name, name))
85 {
86 sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
87 "Server %s has unexpected name %s",
88 client_p->name, name);
89 ilog(L_SERVER, "Server %s has unexpected name %s",
90 log_client_name(client_p, SHOW_IP), name);
91 exit_client(client_p, client_p, client_p, "Server name mismatch");
92 return 0;
93 }
94
95 /*
96 * Reject a direct nonTS server connection if we're TS_ONLY -orabidoo
97 */
98 if(!DoesTS(client_p))
99 {
100 sendto_realops_snomask(SNO_GENERAL, L_ALL, "Link %s dropped, non-TS server",
101 client_p->name);
102 exit_client(client_p, client_p, client_p, "Non-TS server");
103 return 0;
104 }
105
106 if(bogus_host(name))
107 {
108 exit_client(client_p, client_p, client_p, "Bogus server name");
109 return 0;
110 }
111
112 /* Now we just have to call check_server and everything should be
113 * check for us... -A1kmm. */
114 switch (check_server(name, client_p))
115 {
116 case -1:
117 if(ConfigFileEntry.warn_no_nline)
118 {
119 sendto_realops_snomask(SNO_GENERAL, L_ALL,
120 "Unauthorised server connection attempt from %s: "
121 "No entry for servername %s",
122 "[@255.255.255.255]", name);
123
124 ilog(L_SERVER, "Access denied, no connect block for server %s%s",
125 EmptyString(client_p->name) ? name : "",
126 log_client_name(client_p, SHOW_IP));
127 }
128
129 exit_client(client_p, client_p, client_p, "Invalid servername.");
130 return 0;
131 /* NOT REACHED */
132 break;
133
134 case -2:
135 sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
136 "Unauthorised server connection attempt from %s: "
137 "Bad credentials for server %s",
138 "[@255.255.255.255]", name);
139
140 ilog(L_SERVER, "Access denied, invalid credentials for server %s%s",
141 EmptyString(client_p->name) ? name : "",
142 log_client_name(client_p, SHOW_IP));
143
144 exit_client(client_p, client_p, client_p, "Invalid credentials.");
145 return 0;
146 /* NOT REACHED */
147 break;
148
149 case -3:
150 sendto_realops_snomask(SNO_GENERAL, L_ALL,
151 "Unauthorised server connection attempt from %s: "
152 "Invalid host for server %s",
153 "[@255.255.255.255]", name);
154
155 ilog(L_SERVER, "Access denied, invalid host for server %s%s",
156 EmptyString(client_p->name) ? name : "",
157 log_client_name(client_p, SHOW_IP));
158
159 exit_client(client_p, client_p, client_p, "Invalid host.");
160 return 0;
161 /* NOT REACHED */
162 break;
163
164 /* servername is > HOSTLEN */
165 case -4:
166 sendto_realops_snomask(SNO_GENERAL, L_ALL,
167 "Invalid servername %s from %s",
168 name, "[@255.255.255.255]");
169 ilog(L_SERVER, "Access denied, invalid servername from %s",
170 log_client_name(client_p, SHOW_IP));
171
172 exit_client(client_p, client_p, client_p, "Invalid servername.");
173 return 0;
174 /* NOT REACHED */
175 break;
176 case -5:
177 sendto_realops_snomask(SNO_GENERAL, L_ALL,
178 "Connection from servername %s requires SSL/TLS but is plaintext",
179 name);
180 ilog(L_SERVER, "Access denied, requires SSL/TLS but is plaintext from %s",
181 log_client_name(client_p, SHOW_IP));
182
183 exit_client(client_p, client_p, client_p, "Access denied, requires SSL/TLS but is plaintext");
184 return 0;
185 }
186
187 /* require TS6 for direct links */
188 if(!IsCapable(client_p, CAP_TS6))
189 {
190 sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
191 "Link %s dropped, TS6 protocol is required", name);
192 exit_client(client_p, client_p, client_p, "Incompatible TS version");
193 return 0;
194 }
195
196 /* check to ensure any "required" caps are set. --nenolod */
197 /* XXX: show required CAPABs. */
198 required_mask = capability_index_get_required(serv_capindex);
199 if (!IsCapable(client_p, required_mask))
200 {
201 sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
202 "Link %s dropped, required CAPABs are missing", name);
203 ilog(L_SERVER, "Link %s%s dropped, required CAPABs are missing",
204 EmptyString(client_p->name) ? name : "",
205 log_client_name(client_p, SHOW_IP));
206 exit_client(client_p, client_p, client_p, "Missing required CAPABs");
207
208 return 0;
209 }
210
211 if((target_p = find_server(NULL, name)))
212 {
213 /*
214 * This link is trying feed me a server that I already have
215 * access through another path -- multiple paths not accepted
216 * currently, kill this link immediately!!
217 *
218 * Rather than KILL the link which introduced it, KILL the
219 * youngest of the two links. -avalon
220 *
221 * Definitely don't do that here. This is from an unregistered
222 * connect - A1kmm.
223 */
224 if (target_p->servptr->flags & FLAGS_SERVICE)
225 {
226 /* Assume any servers introduced by services
227 * are jupes.
228 * -- jilles
229 */
230 sendto_one(client_p, "ERROR :Server juped.");
231 }
232 else
233 {
234 sendto_realops_snomask(SNO_GENERAL, L_ALL,
235 "Attempt to re-introduce server %s from %s",
236 name, "[@255.255.255.255]");
237 ilog(L_SERVER, "Attempt to re-introduce server %s from %s",
238 name, log_client_name(client_p, SHOW_IP));
239
240 sendto_one(client_p, "ERROR :Server already exists.");
241 }
242 exit_client(client_p, client_p, client_p, "Server Exists");
243 return 0;
244 }
245
246 if(has_id(client_p) && (target_p = find_id(client_p->id)) != NULL)
247 {
248 sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
249 "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
250 client_p->id,
251 EmptyString(client_p->name) ? name : "",
252 client_p->name, target_p->name);
253 ilog(L_SERVER, "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
254 client_p->id,
255 EmptyString(client_p->name) ? name : "",
256 log_client_name(client_p, SHOW_IP),
257 target_p->name);
258
259 sendto_one(client_p, "ERROR :SID already exists.");
260 exit_client(client_p, client_p, client_p, "SID Exists");
261 return 0;
262 }
263
264 /*
265 * if we are connecting (Handshake), we already have the name from the
266 * C:line in client_p->name
267 */
268
269 rb_strlcpy(client_p->name, name, sizeof(client_p->name));
270 set_server_gecos(client_p, info);
271 client_p->hopcount = hop;
272 server_estab(client_p);
273
274 return 0;
275 }
276
277 /*
278 * ms_server - SERVER message handler
279 * parv[1] = servername
280 * parv[2] = serverinfo/hopcount
281 * parv[3] = serverinfo
282 */
283 static int
284 ms_server(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
285 {
286 char info[REALLEN + 1];
287 /* same size as in s_misc.c */
288 const char *name;
289 struct Client *target_p;
290 struct remote_conf *hub_p;
291 hook_data_client hdata;
292 int hop;
293 int hlined = 0;
294 int llined = 0;
295 rb_dlink_node *ptr;
296 char squitreason[160];
297
298 name = parv[1];
299 hop = atoi(parv[2]);
300 rb_strlcpy(info, parv[3], sizeof(info));
301
302 if((target_p = find_server(NULL, name)))
303 {
304 /*
305 * This link is trying feed me a server that I already have
306 * access through another path -- multiple paths not accepted
307 * currently, kill this link immediately!!
308 *
309 * Rather than KILL the link which introduced it, KILL the
310 * youngest of the two links. -avalon
311 *
312 * I think that we should exit the link itself, not the introducer,
313 * and we should always exit the most recently received(i.e. the
314 * one we are receiving this SERVER for. -A1kmm
315 *
316 * You *cant* do this, if you link somewhere, it bursts you a server
317 * that already exists, then sends you a client burst, you squit the
318 * server, but you keep getting the burst of clients on a server that
319 * doesnt exist, although ircd can handle it, its not a realistic
320 * solution.. --fl_
321 */
322 ilog(L_SERVER, "Link %s cancelled, server %s already exists",
323 client_p->name, name);
324
325 rb_snprintf(squitreason, sizeof squitreason,
326 "Server %s already exists",
327 name);
328 exit_client(client_p, client_p, &me, squitreason);
329 return 0;
330 }
331
332 /*
333 * User nicks never have '.' in them and server names
334 * must always have '.' in them.
335 */
336 if(strchr(name, '.') == NULL)
337 {
338 /*
339 * Server trying to use the same name as a person. Would
340 * cause a fair bit of confusion. Enough to make it hellish
341 * for a while and servers to send stuff to the wrong place.
342 */
343 sendto_one(client_p, "ERROR :Nickname %s already exists!", name);
344 sendto_realops_snomask(SNO_GENERAL, L_ALL,
345 "Link %s cancelled: Server/nick collision on %s",
346 client_p->name, name);
347 ilog(L_SERVER, "Link %s cancelled: Server/nick collision on %s",
348 client_p->name, name);
349
350 exit_client(client_p, client_p, client_p, "Nick as Server");
351 return 0;
352 }
353
354 /*
355 * Server is informing about a new server behind
356 * this link. Create REMOTE server structure,
357 * add it to list and propagate word to my other
358 * server links...
359 */
360
361 /*
362 * See if the newly found server is behind a guaranteed
363 * leaf. If so, close the link.
364 *
365 */
366 RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head)
367 {
368 hub_p = ptr->data;
369
370 if(match(hub_p->server, client_p->name) && match(hub_p->host, name))
371 {
372 if(hub_p->flags & CONF_HUB)
373 hlined++;
374 else
375 llined++;
376 }
377 }
378
379 /* Ok, this way this works is
380 *
381 * A server can have a CONF_HUB allowing it to introduce servers
382 * behind it.
383 *
384 * connect {
385 * name = "irc.bighub.net";
386 * hub_mask="*";
387 * ...
388 *
389 * That would allow "irc.bighub.net" to introduce anything it wanted..
390 *
391 * However
392 *
393 * connect {
394 * name = "irc.somehub.fi";
395 * hub_mask="*";
396 * leaf_mask="*.edu";
397 *...
398 * Would allow this server in finland to hub anything but
399 * .edu's
400 */
401
402 /* Ok, check client_p can hub the new server */
403 if(!hlined)
404 {
405 /* OOOPs nope can't HUB */
406 sendto_realops_snomask(SNO_GENERAL, L_ALL, "Non-Hub link %s introduced %s.",
407 client_p->name, name);
408 ilog(L_SERVER, "Non-Hub link %s introduced %s.",
409 client_p->name, name);
410
411 rb_snprintf(squitreason, sizeof squitreason,
412 "No matching hub_mask for %s",
413 name);
414 exit_client(NULL, client_p, &me, squitreason);
415 return 0;
416 }
417
418 /* Check for the new server being leafed behind this HUB */
419 if(llined)
420 {
421 /* OOOPs nope can't HUB this leaf */
422 sendto_realops_snomask(SNO_GENERAL, L_ALL,
423 "Link %s introduced leafed server %s.",
424 client_p->name, name);
425 ilog(L_SERVER, "Link %s introduced leafed server %s.",
426 client_p->name, name);
427
428 rb_snprintf(squitreason, sizeof squitreason,
429 "Matching leaf_mask for %s",
430 name);
431 exit_client(NULL, client_p, &me, squitreason);
432 return 0;
433 }
434
435
436
437 if(strlen(name) > HOSTLEN)
438 {
439 sendto_realops_snomask(SNO_GENERAL, L_ALL,
440 "Link %s introduced server with invalid servername %s",
441 client_p->name, name);
442 ilog(L_SERVER, "Link %s introduced server with invalid servername %s",
443 client_p->name, name);
444
445 exit_client(NULL, client_p, &me, "Invalid servername introduced.");
446 return 0;
447 }
448
449 target_p = make_client(client_p);
450 make_server(target_p);
451 target_p->hopcount = hop;
452
453 rb_strlcpy(target_p->name, name, sizeof(target_p->name));
454
455 set_server_gecos(target_p, info);
456
457 target_p->servptr = source_p;
458
459 SetServer(target_p);
460
461 rb_dlinkAddTail(target_p, &target_p->node, &global_client_list);
462 rb_dlinkAddTailAlloc(target_p, &global_serv_list);
463 add_to_client_hash(target_p->name, target_p);
464 rb_dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->servers);
465
466 target_p->serv->nameinfo = scache_connect(target_p->name, target_p->info, IsHidden(target_p));
467
468 sendto_server(client_p, NULL, NOCAPS, NOCAPS,
469 ":%s SERVER %s %d :%s%s",
470 source_p->name, target_p->name, target_p->hopcount + 1,
471 IsHidden(target_p) ? "(H) " : "", target_p->info);
472
473 sendto_realops_snomask(SNO_EXTERNAL, L_ALL,
474 "Server %s being introduced by %s", target_p->name, source_p->name);
475
476 /* quick, dirty EOB. you know you love it. */
477 sendto_one(target_p, ":%s PING %s %s", get_id(&me, target_p), me.name, target_p->name);
478
479 hdata.client = source_p;
480 hdata.target = target_p;
481 call_hook(h_server_introduced, &hdata);
482
483 return 0;
484 }
485
486 static int
487 ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
488 {
489 struct Client *target_p;
490 struct remote_conf *hub_p;
491 hook_data_client hdata;
492 rb_dlink_node *ptr;
493 int hlined = 0;
494 int llined = 0;
495 char squitreason[160];
496
497 /* collision on the name? */
498 if((target_p = find_server(NULL, parv[1])) != NULL)
499 {
500 ilog(L_SERVER, "Link %s cancelled, server %s already exists",
501 client_p->name, parv[1]);
502
503 rb_snprintf(squitreason, sizeof squitreason,
504 "Server %s already exists",
505 parv[1]);
506 exit_client(NULL, client_p, &me, squitreason);
507 return 0;
508 }
509
510 /* collision on the SID? */
511 if((target_p = find_id(parv[3])) != NULL)
512 {
513 sendto_wallops_flags(UMODE_WALLOP, &me,
514 "Link %s cancelled, SID %s for server %s already in use by %s",
515 client_p->name, parv[3], parv[1], target_p->name);
516 sendto_server(NULL, NULL, CAP_TS6, NOCAPS,
517 ":%s WALLOPS :Link %s cancelled, SID %s for server %s already in use by %s",
518 me.id, client_p->name, parv[3], parv[1], target_p->name);
519 ilog(L_SERVER, "Link %s cancelled, SID %s for server %s already in use by %s",
520 client_p->name, parv[3], parv[1], target_p->name);
521
522 rb_snprintf(squitreason, sizeof squitreason,
523 "SID %s for %s already in use by %s",
524 parv[3], parv[1], target_p->name);
525 exit_client(NULL, client_p, &me, squitreason);
526 return 0;
527 }
528
529 if(bogus_host(parv[1]) || strlen(parv[1]) > HOSTLEN)
530 {
531 sendto_one(client_p, "ERROR :Invalid servername");
532 sendto_realops_snomask(SNO_GENERAL, L_ALL,
533 "Link %s cancelled, servername %s invalid",
534 client_p->name, parv[1]);
535 ilog(L_SERVER, "Link %s cancelled, servername %s invalid",
536 client_p->name, parv[1]);
537
538 exit_client(NULL, client_p, &me, "Bogus server name");
539 return 0;
540 }
541
542 if(!IsDigit(parv[3][0]) || !IsIdChar(parv[3][1]) ||
543 !IsIdChar(parv[3][2]) || parv[3][3] != '\0')
544 {
545 sendto_one(client_p, "ERROR :Invalid SID");
546 sendto_realops_snomask(SNO_GENERAL, L_ALL,
547 "Link %s cancelled, SID %s invalid",
548 client_p->name, parv[3]);
549 ilog(L_SERVER, "Link %s cancelled, SID %s invalid",
550 client_p->name, parv[3]);
551
552 exit_client(NULL, client_p, &me, "Bogus SID");
553 return 0;
554 }
555
556 /* for the directly connected server:
557 * H: allows it to introduce a server matching that mask
558 * L: disallows it introducing a server matching that mask
559 */
560 RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head)
561 {
562 hub_p = ptr->data;
563
564 if(match(hub_p->server, client_p->name) && match(hub_p->host, parv[1]))
565 {
566 if(hub_p->flags & CONF_HUB)
567 hlined++;
568 else
569 llined++;
570 }
571 }
572
573 /* no matching hub_mask */
574 if(!hlined)
575 {
576 sendto_realops_snomask(SNO_GENERAL, L_ALL,
577 "Non-Hub link %s introduced %s.",
578 client_p->name, parv[1]);
579 ilog(L_SERVER, "Non-Hub link %s introduced %s.",
580 client_p->name, parv[1]);
581
582 rb_snprintf(squitreason, sizeof squitreason,
583 "No matching hub_mask for %s",
584 parv[1]);
585 exit_client(NULL, client_p, &me, squitreason);
586 return 0;
587 }
588
589 /* matching leaf_mask */
590 if(llined)
591 {
592 sendto_realops_snomask(SNO_GENERAL, L_ALL,
593 "Link %s introduced leafed server %s.",
594 client_p->name, parv[1]);
595 ilog(L_SERVER, "Link %s introduced leafed server %s.",
596 client_p->name, parv[1]);
597
598 rb_snprintf(squitreason, sizeof squitreason,
599 "Matching leaf_mask for %s",
600 parv[1]);
601 exit_client(NULL, client_p, &me, squitreason);
602 return 0;
603 }
604
605 /* ok, alls good */
606 target_p = make_client(client_p);
607 make_server(target_p);
608
609 rb_strlcpy(target_p->name, parv[1], sizeof(target_p->name));
610 target_p->hopcount = atoi(parv[2]);
611 strcpy(target_p->id, parv[3]);
612 set_server_gecos(target_p, parv[4]);
613
614 target_p->servptr = source_p;
615 SetServer(target_p);
616
617 rb_dlinkAddTail(target_p, &target_p->node, &global_client_list);
618 rb_dlinkAddTailAlloc(target_p, &global_serv_list);
619 add_to_client_hash(target_p->name, target_p);
620 add_to_id_hash(target_p->id, target_p);
621 rb_dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->servers);
622
623 target_p->serv->nameinfo = scache_connect(target_p->name, target_p->info, IsHidden(target_p));
624
625 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
626 ":%s SID %s %d %s :%s%s",
627 source_p->id, target_p->name, target_p->hopcount + 1,
628 target_p->id, IsHidden(target_p) ? "(H) " : "", target_p->info);
629
630 sendto_realops_snomask(SNO_EXTERNAL, L_ALL,
631 "Server %s being introduced by %s", target_p->name, source_p->name);
632
633 /* quick, dirty EOB. you know you love it. */
634 sendto_one(target_p, ":%s PING %s %s",
635 get_id(&me, target_p), me.name, get_id(target_p, target_p));
636
637 hdata.client = source_p;
638 hdata.target = target_p;
639 call_hook(h_server_introduced, &hdata);
640
641 return 0;
642 }
643
644 /* set_server_gecos()
645 *
646 * input - pointer to client
647 * output - none
648 * side effects - servers gecos field is set
649 */
650 static int
651 set_server_gecos(struct Client *client_p, const char *info)
652 {
653 /* check the info for [IP] */
654 if(info[0])
655 {
656 char *p;
657 char *s;
658
659 s = LOCAL_COPY(info);
660
661 /* we should only check the first word for an ip */
662 if((p = strchr(s, ' ')))
663 *p = '\0';
664
665 /* check for a ] which would symbolise an [IP] */
666 if(strchr(s, ']'))
667 {
668 /* set s to after the first space */
669 if(p)
670 s = ++p;
671 else
672 s = NULL;
673 }
674 /* no ], put the space back */
675 else if(p)
676 *p = ' ';
677
678 /* p may have been set to a trailing space, so check s exists and that
679 * it isnt \0 */
680 if(s && (*s != '\0'))
681 {
682 /* a space? if not (H) could be the last part of info.. */
683 if((p = strchr(s, ' ')))
684 *p = '\0';
685
686 /* check for (H) which is a hidden server */
687 if(!strcmp(s, "(H)"))
688 {
689 SetHidden(client_p);
690
691 /* if there was no space.. theres nothing to set info to */
692 if(p)
693 s = ++p;
694 else
695 s = NULL;
696 }
697 else if(p)
698 *p = ' ';
699
700 /* if there was a trailing space, s could point to \0, so check */
701 if(s && (*s != '\0'))
702 {
703 rb_strlcpy(client_p->info, s, sizeof(client_p->info));
704 return 1;
705 }
706 }
707 }
708
709 rb_strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
710
711 return 1;
712 }
713
714 /*
715 * bogus_host
716 *
717 * inputs - hostname
718 * output - 1 if a bogus hostname input, 0 if its valid
719 * side effects - none
720 */
721 int
722 bogus_host(const char *host)
723 {
724 int bogus_server = 0;
725 const char *s;
726 int dots = 0;
727
728 for(s = host; *s; s++)
729 {
730 if(!IsServChar(*s))
731 {
732 bogus_server = 1;
733 break;
734 }
735 if('.' == *s)
736 ++dots;
737 }
738
739 if(!dots || bogus_server)
740 return 1;
741
742 return 0;
743 }