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