]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/core/m_server.c
strip_tabs() is related to s_conf.c ONLY - moved it there
[irc/rqf/shadowircd.git] / modules / core / m_server.c
CommitLineData
212380e3 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 *
9c2f9ec9 24 * $Id: m_server.c 3291 2007-03-28 14:30:10Z jilles $
212380e3 25 */
26
27#include "stdinc.h"
212380e3 28#include "client.h" /* client struct */
29#include "common.h" /* TRUE bleah */
212380e3 30#include "hash.h" /* add_to_client_hash */
31#include "irc_string.h"
32#include "ircd.h" /* me */
33#include "numeric.h" /* ERR_xxx */
34#include "s_conf.h" /* struct ConfItem */
35#include "s_newconf.h"
d3455e2c 36#include "logger.h" /* log level defines */
212380e3 37#include "s_serv.h" /* server_estab, check_server */
38#include "s_stats.h" /* ServerStats */
994544c2 39#include "scache.h"
212380e3 40#include "send.h" /* sendto_one */
41#include "msg.h"
42#include "parse.h"
43#include "modules.h"
44
45static int mr_server(struct Client *, struct Client *, int, const char **);
46static int ms_server(struct Client *, struct Client *, int, const char **);
47static int ms_sid(struct Client *, struct Client *, int, const char **);
48
49struct 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};
53struct 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
58mapi_clist_av1 server_clist[] = { &server_msgtab, &sid_msgtab, NULL };
59
9c2f9ec9 60DECLARE_MODULE_AV1(server, NULL, NULL, server_clist, NULL, NULL, "$Revision: 3291 $");
212380e3 61
62int bogus_host(const char *host);
212380e3 63static int set_server_gecos(struct Client *, const char *);
64
65/*
66 * mr_server - SERVER message handler
67 * parv[0] = sender prefix
68 * parv[1] = servername
69 * parv[2] = serverinfo/hopcount
70 * parv[3] = serverinfo
71 */
72static int
73mr_server(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
74{
75 char info[REALLEN + 1];
76 const char *name;
77 struct Client *target_p;
78 int hop;
79
80 name = parv[1];
81 hop = atoi(parv[2]);
907468c4 82 rb_strlcpy(info, parv[3], sizeof(info));
212380e3 83
9c2f9ec9 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 get_server_name(client_p, HIDE_IP), 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
212380e3 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 get_server_name(client_p, HIDE_IP));
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 get_server_name(client_p, HIDE_IP), 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:
fd4ba65e 135 sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
212380e3 136 "Unauthorised server connection attempt from %s: "
137 "Bad password for server %s",
138 get_server_name(client_p, HIDE_IP), name);
139
140 ilog(L_SERVER, "Access denied, invalid password 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 password.");
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 get_server_name(client_p, HIDE_IP), 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, get_server_name(client_p, HIDE_IP));
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;
8db00894 176 case -5:
b717a466
JT
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");
8db00894 184 return 0;
212380e3 185 }
186
b0b7de54 187 if((target_p = find_server(NULL, name)))
212380e3 188 {
189 /*
190 * This link is trying feed me a server that I already have
191 * access through another path -- multiple paths not accepted
192 * currently, kill this link immediately!!
193 *
194 * Rather than KILL the link which introduced it, KILL the
195 * youngest of the two links. -avalon
196 *
197 * Definitely don't do that here. This is from an unregistered
198 * connect - A1kmm.
199 */
200 sendto_realops_snomask(SNO_GENERAL, L_ALL,
201 "Attempt to re-introduce server %s from %s",
202 name, get_server_name(client_p, HIDE_IP));
203 ilog(L_SERVER, "Attempt to re-introduce server %s from %s",
204 name, log_client_name(client_p, SHOW_IP));
205
206 sendto_one(client_p, "ERROR :Server already exists.");
207 exit_client(client_p, client_p, client_p, "Server Exists");
208 return 0;
209 }
210
211 if(has_id(client_p) && (target_p = find_id(client_p->id)) != NULL)
212 {
fd4ba65e 213 sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
212380e3 214 "Attempt to re-introduce SID %s from %s%s",
215 client_p->id,
216 EmptyString(client_p->name) ? name : "",
217 get_server_name(client_p, HIDE_IP));
218 ilog(L_SERVER, "Attempt to re-introduce SID %s from %s%s",
219 client_p->id,
220 EmptyString(client_p->name) ? name : "",
221 log_client_name(client_p, SHOW_IP));
222
223 sendto_one(client_p, "ERROR :SID already exists.");
224 exit_client(client_p, client_p, client_p, "SID Exists");
225 return 0;
226 }
227
228 /*
229 * if we are connecting (Handshake), we already have the name from the
230 * C:line in client_p->name
231 */
232
907468c4 233 rb_strlcpy(client_p->name, name, sizeof(client_p->name));
212380e3 234 set_server_gecos(client_p, info);
235 client_p->hopcount = hop;
236 server_estab(client_p);
237
238 return 0;
239}
240
241/*
242 * ms_server - SERVER message handler
243 * parv[0] = sender prefix
244 * parv[1] = servername
245 * parv[2] = serverinfo/hopcount
246 * parv[3] = serverinfo
247 */
248static int
249ms_server(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
250{
251 char info[REALLEN + 1];
252 /* same size as in s_misc.c */
253 const char *name;
254 struct Client *target_p;
255 struct remote_conf *hub_p;
256 hook_data_client hdata;
257 int hop;
258 int hlined = 0;
259 int llined = 0;
08d11e34 260 rb_dlink_node *ptr;
212380e3 261
262 name = parv[1];
263 hop = atoi(parv[2]);
907468c4 264 rb_strlcpy(info, parv[3], sizeof(info));
212380e3 265
b0b7de54 266 if((target_p = find_server(NULL, name)))
212380e3 267 {
268 /*
269 * This link is trying feed me a server that I already have
270 * access through another path -- multiple paths not accepted
271 * currently, kill this link immediately!!
272 *
273 * Rather than KILL the link which introduced it, KILL the
274 * youngest of the two links. -avalon
275 *
276 * I think that we should exit the link itself, not the introducer,
277 * and we should always exit the most recently received(i.e. the
278 * one we are receiving this SERVER for. -A1kmm
279 *
280 * You *cant* do this, if you link somewhere, it bursts you a server
281 * that already exists, then sends you a client burst, you squit the
282 * server, but you keep getting the burst of clients on a server that
283 * doesnt exist, although ircd can handle it, its not a realistic
284 * solution.. --fl_
285 */
286 /* It is behind a host-masked server. Completely ignore the
287 * server message(don't propagate or we will delink from whoever
288 * we propagate to). -A1kmm */
289 if(irccmp(target_p->name, name) && target_p->from == client_p)
290 return 0;
291
292 sendto_one(client_p, "ERROR :Server %s already exists", name);
293
294 sendto_realops_snomask(SNO_GENERAL, L_ALL,
295 "Link %s cancelled, server %s already exists",
296 get_server_name(client_p, SHOW_IP), name);
297 ilog(L_SERVER, "Link %s cancelled, server %s already exists",
298 client_p->name, name);
299
300 exit_client(client_p, client_p, &me, "Server Exists");
301 return 0;
302 }
303
304 /*
305 * User nicks never have '.' in them and server names
306 * must always have '.' in them.
307 */
308 if(strchr(name, '.') == NULL)
309 {
310 /*
311 * Server trying to use the same name as a person. Would
312 * cause a fair bit of confusion. Enough to make it hellish
313 * for a while and servers to send stuff to the wrong place.
314 */
315 sendto_one(client_p, "ERROR :Nickname %s already exists!", name);
316 sendto_realops_snomask(SNO_GENERAL, L_ALL,
317 "Link %s cancelled: Server/nick collision on %s",
318 get_server_name(client_p, HIDE_IP), name);
319 ilog(L_SERVER, "Link %s cancelled: Server/nick collision on %s",
320 client_p->name, name);
321
322 exit_client(client_p, client_p, client_p, "Nick as Server");
323 return 0;
324 }
325
326 /*
327 * Server is informing about a new server behind
328 * this link. Create REMOTE server structure,
329 * add it to list and propagate word to my other
330 * server links...
331 */
332 if(parc == 1 || EmptyString(info))
333 {
334 sendto_one(client_p, "ERROR :No server info specified for %s", name);
335 return 0;
336 }
337
338 /*
339 * See if the newly found server is behind a guaranteed
340 * leaf. If so, close the link.
341 *
342 */
08d11e34 343 RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head)
212380e3 344 {
345 hub_p = ptr->data;
346
347 if(match(hub_p->server, client_p->name) && match(hub_p->host, name))
348 {
349 if(hub_p->flags & CONF_HUB)
350 hlined++;
351 else
352 llined++;
353 }
354 }
355
356 /* Ok, this way this works is
357 *
358 * A server can have a CONF_HUB allowing it to introduce servers
359 * behind it.
360 *
361 * connect {
362 * name = "irc.bighub.net";
363 * hub_mask="*";
364 * ...
365 *
366 * That would allow "irc.bighub.net" to introduce anything it wanted..
367 *
368 * However
369 *
370 * connect {
371 * name = "irc.somehub.fi";
372 * hub_mask="*";
373 * leaf_mask="*.edu";
374 *...
375 * Would allow this server in finland to hub anything but
376 * .edu's
377 */
378
379 /* Ok, check client_p can hub the new server, and make sure it's not a LL */
380 if(!hlined)
381 {
382 /* OOOPs nope can't HUB */
383 sendto_realops_snomask(SNO_GENERAL, L_ALL, "Non-Hub link %s introduced %s.",
384 get_server_name(client_p, HIDE_IP), name);
385 ilog(L_SERVER, "Non-Hub link %s introduced %s.",
386 client_p->name, name);
387
388 exit_client(NULL, client_p, &me, "No matching hub_mask.");
389 return 0;
390 }
391
392 /* Check for the new server being leafed behind this HUB */
393 if(llined)
394 {
395 /* OOOPs nope can't HUB this leaf */
396 sendto_realops_snomask(SNO_GENERAL, L_ALL,
397 "Link %s introduced leafed server %s.",
398 get_server_name(client_p, HIDE_IP), name);
399 ilog(L_SERVER, "Link %s introduced leafed server %s.",
400 client_p->name, name);
401
402 exit_client(NULL, client_p, &me, "Leafed Server.");
403 return 0;
404 }
405
406
407
408 if(strlen(name) > HOSTLEN)
409 {
410 sendto_realops_snomask(SNO_GENERAL, L_ALL,
411 "Link %s introduced server with invalid servername %s",
412 get_server_name(client_p, HIDE_IP), name);
413 ilog(L_SERVER, "Link %s introduced server with invalid servername %s",
414 client_p->name, name);
415
416 exit_client(NULL, client_p, &me, "Invalid servername introduced.");
417 return 0;
418 }
419
420 target_p = make_client(client_p);
421 make_server(target_p);
422 target_p->hopcount = hop;
423
907468c4 424 rb_strlcpy(target_p->name, name, sizeof(target_p->name));
212380e3 425
426 set_server_gecos(target_p, info);
427
212380e3 428 target_p->servptr = source_p;
429
430 SetServer(target_p);
431
bfccb2c0
JT
432 rb_dlinkAddTail(target_p, &target_p->node, &global_client_list);
433 rb_dlinkAddTailAlloc(target_p, &global_serv_list);
212380e3 434 add_to_client_hash(target_p->name, target_p);
bfccb2c0 435 rb_dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->servers);
212380e3 436
994544c2
JT
437 target_p->serv->nameinfo = scache_connect(target_p->name, target_p->info, IsHidden(target_p));
438
212380e3 439 sendto_server(client_p, NULL, NOCAPS, NOCAPS,
440 ":%s SERVER %s %d :%s%s",
441 source_p->name, target_p->name, target_p->hopcount + 1,
442 IsHidden(target_p) ? "(H) " : "", target_p->info);
443
444 sendto_realops_snomask(SNO_EXTERNAL, L_ALL,
445 "Server %s being introduced by %s", target_p->name, source_p->name);
446
447 /* quick, dirty EOB. you know you love it. */
448 sendto_one(target_p, ":%s PING %s %s", get_id(&me, target_p), me.name, target_p->name);
449
450 hdata.client = source_p;
451 hdata.target = target_p;
452 call_hook(h_server_introduced, &hdata);
453
454 return 0;
455}
456
457static int
458ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
459{
460 struct Client *target_p;
461 struct remote_conf *hub_p;
462 hook_data_client hdata;
08d11e34 463 rb_dlink_node *ptr;
212380e3 464 int hop;
465 int hlined = 0;
466 int llined = 0;
467
468 hop = atoi(parv[2]);
469
470 /* collision on the name? */
b0b7de54 471 if((target_p = find_server(NULL, parv[1])) != NULL)
212380e3 472 {
473 sendto_one(client_p, "ERROR :Server %s already exists", parv[1]);
474 sendto_realops_snomask(SNO_GENERAL, L_ALL,
475 "Link %s cancelled, server %s already exists",
476 get_server_name(client_p, SHOW_IP), parv[1]);
477 ilog(L_SERVER, "Link %s cancelled, server %s already exists",
478 client_p->name, parv[1]);
479
480 exit_client(NULL, client_p, &me, "Server Exists");
481 return 0;
482 }
483
484 /* collision on the SID? */
485 if((target_p = find_id(parv[3])) != NULL)
486 {
487 sendto_one(client_p, "ERROR :SID %s already exists", parv[3]);
488 sendto_realops_snomask(SNO_GENERAL, L_ALL,
489 "Link %s cancelled, SID %s already exists",
490 get_server_name(client_p, SHOW_IP), parv[3]);
491 ilog(L_SERVER, "Link %s cancelled, SID %s already exists",
492 client_p->name, parv[3]);
493
16e0550f 494 exit_client(NULL, client_p, &me, "SID Exists");
212380e3 495 return 0;
496 }
497
498 if(bogus_host(parv[1]) || strlen(parv[1]) > HOSTLEN)
499 {
500 sendto_one(client_p, "ERROR :Invalid servername");
501 sendto_realops_snomask(SNO_GENERAL, L_ALL,
502 "Link %s cancelled, servername %s invalid",
503 get_server_name(client_p, SHOW_IP), parv[1]);
504 ilog(L_SERVER, "Link %s cancelled, servername %s invalid",
505 client_p->name, parv[1]);
506
507 exit_client(NULL, client_p, &me, "Bogus server name");
508 return 0;
509 }
510
511 if(!IsDigit(parv[3][0]) || !IsIdChar(parv[3][1]) ||
512 !IsIdChar(parv[3][2]) || parv[3][3] != '\0')
513 {
514 sendto_one(client_p, "ERROR :Invalid SID");
515 sendto_realops_snomask(SNO_GENERAL, L_ALL,
516 "Link %s cancelled, SID %s invalid",
517 get_server_name(client_p, SHOW_IP), parv[3]);
518 ilog(L_SERVER, "Link %s cancelled, SID %s invalid",
519 client_p->name, parv[3]);
520
521 exit_client(NULL, client_p, &me, "Bogus SID");
522 return 0;
523 }
524
525 /* for the directly connected server:
526 * H: allows it to introduce a server matching that mask
527 * L: disallows it introducing a server matching that mask
528 */
08d11e34 529 RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head)
212380e3 530 {
531 hub_p = ptr->data;
532
533 if(match(hub_p->server, client_p->name) && match(hub_p->host, parv[1]))
534 {
535 if(hub_p->flags & CONF_HUB)
536 hlined++;
537 else
538 llined++;
539 }
540 }
541
542 /* no matching hub_mask */
543 if(!hlined)
544 {
545 sendto_one(client_p, "ERROR :No matching hub_mask");
546 sendto_realops_snomask(SNO_GENERAL, L_ALL,
547 "Non-Hub link %s introduced %s.",
548 get_server_name(client_p, SHOW_IP), parv[1]);
549 ilog(L_SERVER, "Non-Hub link %s introduced %s.",
550 client_p->name, parv[1]);
551 exit_client(NULL, client_p, &me, "No matching hub_mask.");
552 return 0;
553 }
554
555 /* matching leaf_mask */
556 if(llined)
557 {
558 sendto_one(client_p, "ERROR :Matching leaf_mask");
559 sendto_realops_snomask(SNO_GENERAL, L_ALL,
560 "Link %s introduced leafed server %s.",
561 get_server_name(client_p, SHOW_IP), parv[1]);
562 ilog(L_SERVER, "Link %s introduced leafed server %s.",
563 client_p->name, parv[1]);
564 exit_client(NULL, client_p, &me, "Leafed Server.");
565 return 0;
566 }
567
568 /* ok, alls good */
569 target_p = make_client(client_p);
570 make_server(target_p);
571
907468c4 572 rb_strlcpy(target_p->name, parv[1], sizeof(target_p->name));
212380e3 573 target_p->hopcount = atoi(parv[2]);
574 strcpy(target_p->id, parv[3]);
575 set_server_gecos(target_p, parv[4]);
576
212380e3 577 target_p->servptr = source_p;
578 SetServer(target_p);
579
bfccb2c0
JT
580 rb_dlinkAddTail(target_p, &target_p->node, &global_client_list);
581 rb_dlinkAddTailAlloc(target_p, &global_serv_list);
212380e3 582 add_to_client_hash(target_p->name, target_p);
583 add_to_id_hash(target_p->id, target_p);
bfccb2c0 584 rb_dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->servers);
212380e3 585
994544c2
JT
586 target_p->serv->nameinfo = scache_connect(target_p->name, target_p->info, IsHidden(target_p));
587
212380e3 588 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
589 ":%s SID %s %d %s :%s%s",
590 source_p->id, target_p->name, target_p->hopcount + 1,
591 target_p->id, IsHidden(target_p) ? "(H) " : "", target_p->info);
592 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
593 ":%s SERVER %s %d :%s%s",
594 source_p->name, target_p->name, target_p->hopcount + 1,
595 IsHidden(target_p) ? "(H) " : "", target_p->info);
596
597 sendto_realops_snomask(SNO_EXTERNAL, L_ALL,
598 "Server %s being introduced by %s", target_p->name, source_p->name);
599
600 /* quick, dirty EOB. you know you love it. */
601 sendto_one(target_p, ":%s PING %s %s",
602 get_id(&me, target_p), me.name, get_id(target_p, target_p));
603
604 hdata.client = source_p;
605 hdata.target = target_p;
606 call_hook(h_server_introduced, &hdata);
607
608 return 0;
609}
610
611/* set_server_gecos()
612 *
613 * input - pointer to client
614 * output - none
615 * side effects - servers gecos field is set
616 */
617static int
618set_server_gecos(struct Client *client_p, const char *info)
619{
620 /* check the info for [IP] */
621 if(info[0])
622 {
623 char *p;
624 char *s;
625 char *t;
626
627 s = LOCAL_COPY(info);
628
629 /* we should only check the first word for an ip */
630 if((p = strchr(s, ' ')))
631 *p = '\0';
632
633 /* check for a ] which would symbolise an [IP] */
634 if((t = strchr(s, ']')))
635 {
636 /* set s to after the first space */
637 if(p)
638 s = ++p;
639 else
640 s = NULL;
641 }
642 /* no ], put the space back */
643 else if(p)
644 *p = ' ';
645
646 /* p may have been set to a trailing space, so check s exists and that
647 * it isnt \0 */
648 if(s && (*s != '\0'))
649 {
650 /* a space? if not (H) could be the last part of info.. */
651 if((p = strchr(s, ' ')))
652 *p = '\0';
653
654 /* check for (H) which is a hidden server */
655 if(!strcmp(s, "(H)"))
656 {
657 SetHidden(client_p);
658
659 /* if there was no space.. theres nothing to set info to */
660 if(p)
661 s = ++p;
662 else
663 s = NULL;
664 }
665 else if(p)
666 *p = ' ';
667
668 /* if there was a trailing space, s could point to \0, so check */
669 if(s && (*s != '\0'))
670 {
907468c4 671 rb_strlcpy(client_p->info, s, sizeof(client_p->info));
212380e3 672 return 1;
673 }
674 }
675 }
676
907468c4 677 rb_strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
212380e3 678
679 return 1;
680}
681
682/*
683 * bogus_host
684 *
685 * inputs - hostname
686 * output - 1 if a bogus hostname input, 0 if its valid
687 * side effects - none
688 */
689int
690bogus_host(const char *host)
691{
692 int bogus_server = 0;
693 const char *s;
694 int dots = 0;
695
696 for(s = host; *s; s++)
697 {
698 if(!IsServChar(*s))
699 {
700 bogus_server = 1;
701 break;
702 }
703 if('.' == *s)
704 ++dots;
705 }
706
707 if(!dots || bogus_server)
708 return 1;
709
710 return 0;
711}