1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* client.c: Controls clients. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file client.c |
23 |
> |
* \brief Controls clients. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
54 |
|
#include "userhost.h" |
55 |
|
#include "watch.h" |
56 |
|
#include "rng_mt.h" |
57 |
+ |
#include "parse.h" |
58 |
|
|
59 |
|
dlink_list listing_client_list = { NULL, NULL, 0 }; |
60 |
|
/* Pointer to beginning of Client list */ |
78 |
|
|
79 |
|
static void check_pings_list(dlink_list *); |
80 |
|
static void check_unknowns_list(void); |
78 |
– |
static void ban_them(struct Client *, struct MaskItem *); |
81 |
|
|
82 |
|
|
83 |
|
/* client_init() |
241 |
|
static void |
242 |
|
check_pings_list(dlink_list *list) |
243 |
|
{ |
244 |
< |
char scratch[32]; /* way too generous but... */ |
244 |
> |
char scratch[IRCD_BUFSIZE]; |
245 |
|
int ping = 0; /* ping time value from client */ |
246 |
|
dlink_node *ptr = NULL, *next_ptr = NULL; |
247 |
|
|
359 |
|
if (conf->type == CONF_EXEMPT) |
360 |
|
continue; |
361 |
|
|
362 |
< |
ban_them(client_p, conf); |
362 |
> |
conf_try_ban(client_p, conf); |
363 |
|
continue; /* and go examine next fd/client_p */ |
364 |
|
} |
365 |
|
|
366 |
|
if (ConfigFileEntry.glines) |
367 |
|
{ |
368 |
< |
if (!(conf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
369 |
< |
CONF_GLINE, client_p->localClient->aftype, |
370 |
< |
client_p->username, NULL, 1))) |
369 |
< |
continue; |
370 |
< |
|
371 |
< |
if (IsExemptKline(client_p) || |
372 |
< |
IsExemptGline(client_p)) |
368 |
> |
if ((conf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
369 |
> |
CONF_GLINE, client_p->localClient->aftype, |
370 |
> |
client_p->username, NULL, 1))) |
371 |
|
{ |
372 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
373 |
< |
"GLINE over-ruled for %s, client is %sline_exempt", |
376 |
< |
get_client_name(client_p, HIDE_IP), IsExemptKline(client_p) ? "k" : "g"); |
372 |
> |
conf_try_ban(client_p, conf); |
373 |
> |
/* and go examine next fd/client_p */ |
374 |
|
continue; |
375 |
|
} |
379 |
– |
|
380 |
– |
ban_them(client_p, conf); |
381 |
– |
/* and go examine next fd/client_p */ |
382 |
– |
continue; |
376 |
|
} |
377 |
|
|
378 |
|
if ((conf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
379 |
|
CONF_KLINE, client_p->localClient->aftype, |
380 |
< |
client_p->username, NULL, 1)) != NULL) |
380 |
> |
client_p->username, NULL, 1))) |
381 |
|
{ |
382 |
< |
if (IsExemptKline(client_p)) |
390 |
< |
{ |
391 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
392 |
< |
"KLINE over-ruled for %s, client is kline_exempt", |
393 |
< |
get_client_name(client_p, HIDE_IP)); |
394 |
< |
continue; |
395 |
< |
} |
396 |
< |
|
397 |
< |
ban_them(client_p, conf); |
382 |
> |
conf_try_ban(client_p, conf); |
383 |
|
continue; |
384 |
|
} |
385 |
|
|
386 |
|
if ((conf = find_matching_name_conf(CONF_XLINE, client_p->info, |
387 |
|
NULL, NULL, 0))) |
388 |
|
{ |
389 |
< |
ban_them(client_p, conf); |
389 |
> |
conf_try_ban(client_p, conf); |
390 |
|
continue; |
391 |
|
} |
392 |
|
} |
408 |
|
} |
409 |
|
|
410 |
|
/* |
411 |
< |
* ban_them |
411 |
> |
* conf_try_ban |
412 |
|
* |
413 |
|
* inputs - pointer to client to ban |
414 |
|
* - pointer to MaskItem |
415 |
|
* output - NONE |
416 |
|
* side effects - given client_p is banned |
417 |
|
*/ |
418 |
< |
static void |
419 |
< |
ban_them(struct Client *client_p, struct MaskItem *conf) |
418 |
> |
void |
419 |
> |
conf_try_ban(struct Client *client_p, struct MaskItem *conf) |
420 |
|
{ |
421 |
|
const char *user_reason = NULL; /* What is sent to user */ |
422 |
|
const char *type_string = NULL; |
428 |
|
switch (conf->type) |
429 |
|
{ |
430 |
|
case CONF_KLINE: |
431 |
+ |
if (IsExemptKline(client_p)) |
432 |
+ |
{ |
433 |
+ |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
434 |
+ |
"KLINE over-ruled for %s, client is kline_exempt", |
435 |
+ |
get_client_name(client_p, HIDE_IP)); |
436 |
+ |
return; |
437 |
+ |
} |
438 |
+ |
|
439 |
|
type_string = kline_string; |
440 |
|
break; |
441 |
|
case CONF_DLINE: |
442 |
|
type_string = dline_string; |
443 |
|
break; |
444 |
|
case CONF_GLINE: |
445 |
+ |
if (IsExemptKline(client_p) || |
446 |
+ |
IsExemptGline(client_p)) |
447 |
+ |
{ |
448 |
+ |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
449 |
+ |
"GLINE over-ruled for %s, client is %sline_exempt", |
450 |
+ |
get_client_name(client_p, HIDE_IP), IsExemptKline(client_p) ? "k" : "g"); |
451 |
+ |
return; |
452 |
+ |
} |
453 |
+ |
|
454 |
|
type_string = gline_string; |
455 |
|
break; |
456 |
|
case CONF_XLINE: |
468 |
|
type_string, get_client_name(client_p, HIDE_IP)); |
469 |
|
|
470 |
|
if (IsClient(client_p)) |
471 |
< |
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP), |
470 |
< |
me.name, client_p->name, user_reason); |
471 |
> |
sendto_one_numeric(client_p, &me, ERR_YOUREBANNEDCREEP, user_reason); |
472 |
|
|
473 |
|
exit_client(client_p, &me, user_reason); |
474 |
|
} |
507 |
|
* side effects - find person by (nick)name |
508 |
|
*/ |
509 |
|
struct Client * |
510 |
< |
find_person(const struct Client *client_p, const char *name) |
510 |
> |
find_person(const struct Client *const client_p, const char *name) |
511 |
|
{ |
512 |
|
struct Client *target_p = NULL; |
513 |
|
|
546 |
|
(time_t)ConfigFileEntry.kill_chase_time_limit)) |
547 |
|
== NULL) |
548 |
|
{ |
549 |
< |
sendto_one(source_p, form_str(ERR_NOSUCHNICK), |
549 |
< |
me.name, source_p->name, name); |
549 |
> |
sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, name); |
550 |
|
return NULL; |
551 |
|
} |
552 |
|
|
948 |
|
} |
949 |
|
} |
950 |
|
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
951 |
< |
{ |
952 |
< |
sendto_server(from->from, CAP_TS6, NOCAPS, |
953 |
< |
":%s QUIT :%s", ID(source_p), comment); |
954 |
< |
sendto_server(from->from, NOCAPS, CAP_TS6, |
955 |
< |
":%s QUIT :%s", source_p->name, comment); |
956 |
< |
} |
951 |
> |
sendto_server(from->from, NOCAPS, NOCAPS, ":%s QUIT :%s", |
952 |
> |
ID(source_p), comment); |
953 |
|
|
954 |
|
/* The client *better* be off all of the lists */ |
955 |
|
assert(dlinkFind(&unknown_list, source_p) == NULL); |
993 |
|
void |
994 |
|
dead_link_on_read(struct Client *client_p, int error) |
995 |
|
{ |
996 |
< |
char errmsg[255]; |
996 |
> |
char errmsg[IRCD_BUFSIZE]; |
997 |
|
int current_error; |
998 |
|
|
999 |
|
if (IsDefunct(client_p)) |