1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2015 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2017 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 |
35 |
|
#include "auth.h" |
36 |
|
#include "s_bsd.h" |
37 |
|
#include "conf.h" |
38 |
+ |
#include "conf_gecos.h" |
39 |
|
#include "log.h" |
40 |
|
#include "misc.h" |
41 |
|
#include "server.h" |
82 |
|
* 'from'). ('from' is a local client!!). |
83 |
|
*/ |
84 |
|
struct Client * |
85 |
< |
make_client(struct Client *from) |
85 |
> |
client_make(struct Client *from) |
86 |
|
{ |
87 |
|
struct Client *const client_p = mp_pool_get(client_pool); |
88 |
|
|
89 |
< |
if (!from) |
89 |
> |
if (from) |
90 |
> |
client_p->from = from; |
91 |
> |
else |
92 |
|
{ |
93 |
|
client_p->from = client_p; /* 'from' of local client is self! */ |
94 |
|
client_p->connection = mp_pool_get(connection_pool); |
100 |
|
/* as good a place as any... */ |
101 |
|
dlinkAdd(client_p, &client_p->connection->lclient_node, &unknown_list); |
102 |
|
} |
100 |
– |
else |
101 |
– |
client_p->from = from; |
103 |
|
|
104 |
|
client_p->idhnext = client_p; |
105 |
|
client_p->hnext = client_p; |
111 |
|
} |
112 |
|
|
113 |
|
/* |
114 |
< |
* free_client |
114 |
> |
* client_free |
115 |
|
* |
116 |
|
* inputs - pointer to client |
117 |
|
* output - NONE |
118 |
|
* side effects - client pointed to has its memory freed |
119 |
|
*/ |
120 |
|
static void |
121 |
< |
free_client(struct Client *client_p) |
121 |
> |
client_free(struct Client *client_p) |
122 |
|
{ |
123 |
|
assert(client_p != &me); |
124 |
|
assert(client_p->hnext == client_p); |
125 |
|
assert(client_p->idhnext == client_p); |
126 |
|
assert(client_p->channel.head == NULL); |
127 |
|
assert(dlink_list_length(&client_p->channel) == 0); |
128 |
< |
assert(dlink_list_length(&client_p->whowas) == 0); |
128 |
> |
assert(dlink_list_length(&client_p->whowas_list) == 0); |
129 |
|
assert(dlink_list_length(&client_p->svstags) == 0); |
130 |
|
|
131 |
< |
MyFree(client_p->serv); |
132 |
< |
MyFree(client_p->certfp); |
131 |
> |
xfree(client_p->serv); |
132 |
> |
xfree(client_p->certfp); |
133 |
|
|
134 |
|
if (MyConnect(client_p)) |
135 |
|
{ |
138 |
|
assert(dlink_list_length(&client_p->connection->watches) == 0); |
139 |
|
assert(HasFlag(client_p, FLAGS_CLOSING) && IsDead(client_p)); |
140 |
|
|
140 |
– |
MyFree(client_p->connection->challenge_response); |
141 |
– |
client_p->connection->challenge_response = NULL; |
142 |
– |
MyFree(client_p->connection->challenge_operator); |
143 |
– |
client_p->connection->challenge_operator = NULL; |
144 |
– |
|
141 |
|
/* |
142 |
|
* Clean up extra sockets from listen {} blocks which have been discarded. |
143 |
|
*/ |
158 |
|
|
159 |
|
void |
160 |
|
client_attach_svstag(struct Client *client_p, unsigned int numeric, |
161 |
< |
const char *umodes, const char *const tag) |
161 |
> |
const char *umodes, const char *tag) |
162 |
|
{ |
167 |
– |
struct ServicesTag *svstag = NULL; |
163 |
|
const struct user_modes *tab = NULL; |
164 |
|
|
165 |
|
if (numeric >= ERR_LAST_ERR_MSG || *umodes != '+') |
166 |
|
return; |
167 |
|
|
168 |
< |
svstag = MyCalloc(sizeof(*svstag)); |
168 |
> |
struct ServicesTag *svstag = xcalloc(sizeof(*svstag)); |
169 |
|
svstag->numeric = numeric; |
170 |
|
svstag->tag = xstrdup(tag); |
171 |
|
|
182 |
|
void |
183 |
|
client_clear_svstags(struct Client *client_p) |
184 |
|
{ |
185 |
< |
dlink_node *node = NULL, *node_next = NULL; |
191 |
< |
|
192 |
< |
DLINK_FOREACH_SAFE(node, node_next, client_p->svstags.head) |
185 |
> |
while (client_p->svstags.head) |
186 |
|
{ |
187 |
< |
struct ServicesTag *svstag = node->data; |
187 |
> |
struct ServicesTag *svstag = client_p->svstags.head->data; |
188 |
|
|
189 |
|
dlinkDelete(&svstag->node, &client_p->svstags); |
190 |
< |
MyFree(svstag->tag); |
191 |
< |
MyFree(svstag); |
190 |
> |
xfree(svstag->tag); |
191 |
> |
xfree(svstag); |
192 |
|
} |
193 |
|
} |
194 |
|
|
201 |
|
static void |
202 |
|
check_pings_list(dlink_list *list) |
203 |
|
{ |
204 |
< |
char buf[IRCD_BUFSIZE] = ""; |
205 |
< |
int ping = 0; /* ping time value from client */ |
204 |
> |
char buf[32] = ""; /* 32 = sizeof("Ping timeout: 999999999 seconds") */ |
205 |
> |
unsigned int ping = 0; /* ping time value from client */ |
206 |
|
dlink_node *node = NULL, *node_next = NULL; |
207 |
|
|
208 |
|
DLINK_FOREACH_SAFE(node, node_next, list->head) |
242 |
|
{ |
243 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
244 |
|
"No response from %s, closing link", |
245 |
< |
get_client_name(client_p, SHOW_IP)); |
245 |
> |
client_get_name(client_p, SHOW_IP)); |
246 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
247 |
|
"No response from %s, closing link", |
248 |
< |
get_client_name(client_p, MASK_IP)); |
248 |
> |
client_get_name(client_p, MASK_IP)); |
249 |
|
ilog(LOG_TYPE_IRCD, "No response from %s, closing link", |
250 |
< |
get_client_name(client_p, SHOW_IP)); |
250 |
> |
client_get_name(client_p, SHOW_IP)); |
251 |
|
} |
252 |
|
|
253 |
< |
snprintf(buf, sizeof(buf), "Ping timeout: %d seconds", |
254 |
< |
(int)(CurrentTime - client_p->connection->lasttime)); |
253 |
> |
snprintf(buf, sizeof(buf), "Ping timeout: %ji seconds", |
254 |
> |
(CurrentTime - client_p->connection->lasttime)); |
255 |
|
exit_client(client_p, buf); |
256 |
|
} |
257 |
|
} |
288 |
|
* kill off stuff that should die |
289 |
|
* |
290 |
|
* inputs - NOT USED (from event) |
298 |
– |
* output - next time_t when check_pings() should be called again |
291 |
|
* side effects - |
292 |
|
* |
293 |
|
* |
326 |
|
void |
327 |
|
check_conf_klines(void) |
328 |
|
{ |
337 |
– |
struct MaskItem *conf = NULL; |
329 |
|
dlink_node *node = NULL, *node_next = NULL; |
330 |
+ |
const void *ptr; |
331 |
|
|
332 |
|
DLINK_FOREACH_SAFE(node, node_next, local_client_list.head) |
333 |
|
{ |
337 |
|
if (IsDead(client_p)) |
338 |
|
continue; |
339 |
|
|
340 |
< |
if ((conf = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE, |
341 |
< |
client_p->connection->aftype, NULL, NULL, 1))) |
340 |
> |
if ((ptr = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE, |
341 |
> |
client_p->connection->aftype, NULL, NULL, 1))) |
342 |
|
{ |
343 |
< |
conf_try_ban(client_p, conf); |
343 |
> |
const struct MaskItem *conf = ptr; |
344 |
> |
conf_try_ban(client_p, CLIENT_BAN_DLINE, conf->reason); |
345 |
|
continue; /* and go examine next Client */ |
346 |
|
} |
347 |
|
|
348 |
< |
if ((conf = find_conf_by_address(client_p->host, &client_p->connection->ip, |
349 |
< |
CONF_KLINE, client_p->connection->aftype, |
350 |
< |
client_p->username, NULL, 1))) |
348 |
> |
if ((ptr = find_conf_by_address(client_p->host, &client_p->connection->ip, |
349 |
> |
CONF_KLINE, client_p->connection->aftype, |
350 |
> |
client_p->username, NULL, 1))) |
351 |
|
{ |
352 |
< |
conf_try_ban(client_p, conf); |
352 |
> |
const struct MaskItem *conf = ptr; |
353 |
> |
conf_try_ban(client_p, CLIENT_BAN_KLINE, conf->reason); |
354 |
|
continue; /* and go examine next Client */ |
355 |
|
} |
356 |
|
|
357 |
< |
if ((conf = find_matching_name_conf(CONF_XLINE, client_p->info, |
364 |
< |
NULL, NULL, 0))) |
357 |
> |
if ((ptr = gecos_find(client_p->info, match))) |
358 |
|
{ |
359 |
< |
conf_try_ban(client_p, conf); |
359 |
> |
const struct GecosItem *conf = ptr; |
360 |
> |
conf_try_ban(client_p, CLIENT_BAN_XLINE, conf->reason); |
361 |
|
continue; /* and go examine next Client */ |
362 |
|
} |
363 |
|
} |
367 |
|
{ |
368 |
|
struct Client *client_p = node->data; |
369 |
|
|
370 |
< |
if ((conf = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE, |
371 |
< |
client_p->connection->aftype, NULL, NULL, 1))) |
370 |
> |
if ((ptr = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE, |
371 |
> |
client_p->connection->aftype, NULL, NULL, 1))) |
372 |
|
{ |
373 |
< |
conf_try_ban(client_p, conf); |
373 |
> |
const struct MaskItem *conf = ptr; |
374 |
> |
conf_try_ban(client_p, CLIENT_BAN_DLINE, conf->reason); |
375 |
|
continue; /* and go examine next Client */ |
376 |
|
} |
377 |
|
} |
386 |
|
* side effects - given client_p is banned |
387 |
|
*/ |
388 |
|
void |
389 |
< |
conf_try_ban(struct Client *client_p, struct MaskItem *conf) |
389 |
> |
conf_try_ban(struct Client *client_p, int type, const char *reason) |
390 |
|
{ |
391 |
< |
char ban_type = '\0'; |
391 |
> |
char ban_type = '?'; |
392 |
|
|
393 |
< |
switch (conf->type) |
393 |
> |
switch (type) |
394 |
|
{ |
395 |
< |
case CONF_KLINE: |
395 |
> |
case CLIENT_BAN_KLINE: |
396 |
|
if (HasFlag(client_p, FLAGS_EXEMPTKLINE)) |
397 |
|
{ |
398 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
399 |
|
"KLINE over-ruled for %s, client is kline_exempt", |
400 |
< |
get_client_name(client_p, HIDE_IP)); |
400 |
> |
client_get_name(client_p, HIDE_IP)); |
401 |
|
return; |
402 |
|
} |
403 |
|
|
404 |
|
ban_type = 'K'; |
405 |
|
break; |
406 |
< |
case CONF_DLINE: |
406 |
> |
case CLIENT_BAN_DLINE: |
407 |
|
if (find_conf_by_address(NULL, &client_p->connection->ip, CONF_EXEMPT, |
408 |
|
client_p->connection->aftype, NULL, NULL, 1)) |
409 |
|
return; |
410 |
|
ban_type = 'D'; |
411 |
|
break; |
412 |
< |
case CONF_XLINE: |
412 |
> |
case CLIENT_BAN_XLINE: |
413 |
|
if (HasFlag(client_p, FLAGS_EXEMPTXLINE)) |
414 |
|
{ |
415 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
416 |
|
"XLINE over-ruled for %s, client is xline_exempt", |
417 |
< |
get_client_name(client_p, HIDE_IP)); |
417 |
> |
client_get_name(client_p, HIDE_IP)); |
418 |
|
return; |
419 |
|
} |
420 |
|
|
421 |
|
ban_type = 'X'; |
427 |
– |
++conf->count; |
422 |
|
break; |
423 |
|
default: |
424 |
|
assert(0); |
426 |
|
} |
427 |
|
|
428 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%c-line active for %s", |
429 |
< |
ban_type, get_client_name(client_p, HIDE_IP)); |
429 |
> |
ban_type, client_get_name(client_p, HIDE_IP)); |
430 |
|
|
431 |
|
if (IsClient(client_p)) |
432 |
< |
sendto_one_numeric(client_p, &me, ERR_YOUREBANNEDCREEP, conf->reason); |
432 |
> |
sendto_one_numeric(client_p, &me, ERR_YOUREBANNEDCREEP, reason); |
433 |
|
|
434 |
< |
exit_client(client_p, conf->reason); |
441 |
< |
} |
442 |
< |
|
443 |
< |
/* update_client_exit_stats() |
444 |
< |
* |
445 |
< |
* input - pointer to client |
446 |
< |
* output - NONE |
447 |
< |
* side effects - |
448 |
< |
*/ |
449 |
< |
static void |
450 |
< |
update_client_exit_stats(struct Client *client_p) |
451 |
< |
{ |
452 |
< |
if (IsClient(client_p)) |
453 |
< |
{ |
454 |
< |
assert(Count.total > 0); |
455 |
< |
|
456 |
< |
--Count.total; |
457 |
< |
if (HasUMode(client_p, UMODE_OPER)) |
458 |
< |
--Count.oper; |
459 |
< |
if (HasUMode(client_p, UMODE_INVISIBLE)) |
460 |
< |
--Count.invisi; |
461 |
< |
} |
462 |
< |
else if (IsServer(client_p)) |
463 |
< |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE, |
464 |
< |
"Server %s split from %s", |
465 |
< |
client_p->name, client_p->servptr->name); |
434 |
> |
exit_client(client_p, reason); |
435 |
|
} |
436 |
|
|
437 |
|
/* find_person() |
441 |
|
* side effects - find person by (nick)name |
442 |
|
*/ |
443 |
|
struct Client * |
444 |
< |
find_person(const struct Client *const source_p, const char *name) |
444 |
> |
find_person(const struct Client *source_p, const char *name) |
445 |
|
{ |
446 |
|
struct Client *target_p = NULL; |
447 |
|
|
472 |
|
if (IsDigit(*name)) |
473 |
|
return NULL; |
474 |
|
|
475 |
< |
target_p = whowas_get_history(name, (time_t)ConfigGeneral.kill_chase_time_limit); |
507 |
< |
|
475 |
> |
target_p = whowas_get_history(name, ConfigGeneral.kill_chase_time_limit); |
476 |
|
if (!target_p) |
509 |
– |
{ |
477 |
|
sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, name); |
511 |
– |
return NULL; |
512 |
– |
} |
478 |
|
|
479 |
|
return target_p; |
480 |
|
} |
481 |
|
|
482 |
|
/* |
483 |
< |
* get_client_name - Return the name of the client |
483 |
> |
* client_get_name - Return the name of the client |
484 |
|
* for various tracking and |
485 |
|
* admin purposes. The main purpose of this function is to |
486 |
|
* return the "socket host" name of the client, if that |
498 |
|
* to modify what it points!!! |
499 |
|
*/ |
500 |
|
const char * |
501 |
< |
get_client_name(const struct Client *client_p, enum addr_mask_type type) |
501 |
> |
client_get_name(const struct Client *client_p, enum addr_mask_type type) |
502 |
|
{ |
503 |
< |
static char buf[HOSTLEN * 2 + USERLEN + 5]; |
503 |
> |
static char buf[HOSTLEN * 2 + USERLEN + 4]; /* +4 for [,@,],\0 */ |
504 |
|
|
505 |
|
if (!MyConnect(client_p)) |
506 |
|
return client_p->name; |
541 |
|
void |
542 |
|
free_exited_clients(void) |
543 |
|
{ |
544 |
< |
dlink_node *node = NULL, *node_next = NULL; |
544 |
> |
dlink_node *node, *node_next; |
545 |
|
|
546 |
|
DLINK_FOREACH_SAFE(node, node_next, dead_list.head) |
547 |
|
{ |
548 |
< |
free_client(node->data); |
548 |
> |
client_free(node->data); |
549 |
|
dlinkDelete(node, &dead_list); |
550 |
|
free_dlink_node(node); |
551 |
|
} |
560 |
|
static void |
561 |
|
exit_one_client(struct Client *source_p, const char *comment) |
562 |
|
{ |
563 |
< |
dlink_node *node = NULL, *node_next = NULL; |
563 |
> |
dlink_node *node, *node_next; |
564 |
|
|
565 |
|
assert(!IsMe(source_p)); |
566 |
|
assert(source_p != &me); |
567 |
|
|
568 |
|
if (IsClient(source_p)) |
569 |
|
{ |
570 |
+ |
if (HasUMode(source_p, UMODE_OPER)) |
571 |
+ |
--Count.oper; |
572 |
+ |
if (HasUMode(source_p, UMODE_INVISIBLE)) |
573 |
+ |
--Count.invisi; |
574 |
+ |
|
575 |
|
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list); |
576 |
|
dlinkDelete(&source_p->node, &global_client_list); |
577 |
|
|
581 |
|
* that the client can show the "**signoff" message). |
582 |
|
* (Note: The notice is to the local clients *only*) |
583 |
|
*/ |
584 |
< |
sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s", |
584 |
> |
sendto_common_channels_local(source_p, 0, 0, 0, ":%s!%s@%s QUIT :%s", |
585 |
|
source_p->name, source_p->username, |
586 |
|
source_p->host, comment); |
587 |
|
|
588 |
|
DLINK_FOREACH_SAFE(node, node_next, source_p->channel.head) |
589 |
|
remove_user_from_channel(node->data); |
590 |
|
|
591 |
+ |
client_clear_svstags(source_p); |
592 |
+ |
|
593 |
|
whowas_add_history(source_p, 0); |
594 |
|
whowas_off_history(source_p); |
595 |
|
|
597 |
|
|
598 |
|
if (MyConnect(source_p)) |
599 |
|
{ |
600 |
< |
clear_invites_client(source_p); |
600 |
> |
clear_invite_list(&source_p->connection->invited); |
601 |
|
del_all_accepts(source_p); |
602 |
|
} |
603 |
|
} |
604 |
|
else if (IsServer(source_p)) |
605 |
|
{ |
606 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
607 |
< |
dlinkDelete(&source_p->node, &global_client_list); |
606 |
> |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE, |
607 |
> |
"Server %s split from %s", |
608 |
> |
source_p->name, source_p->servptr->name); |
609 |
|
|
610 |
< |
if ((node = dlinkFindDelete(&global_server_list, source_p))) |
611 |
< |
free_dlink_node(node); |
610 |
> |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
611 |
> |
dlinkDelete(&source_p->node, &global_server_list); |
612 |
|
} |
613 |
|
|
614 |
|
/* Remove source_p from the client lists */ |
619 |
|
hash_del_client(source_p); |
620 |
|
|
621 |
|
if (HasFlag(source_p, FLAGS_USERHOST)) |
622 |
< |
userhost_del(source_p->username, source_p->host, !MyConnect(source_p)); |
650 |
< |
|
651 |
< |
update_client_exit_stats(source_p); |
622 |
> |
userhost_del(source_p->sockhost, !MyConnect(source_p)); |
623 |
|
|
624 |
|
/* Check to see if the client isn't already on the dead list */ |
625 |
|
assert(dlinkFind(&dead_list, source_p) == NULL); |
638 |
|
static void |
639 |
|
recurse_remove_clients(struct Client *source_p, const char *comment) |
640 |
|
{ |
641 |
< |
dlink_node *node = NULL, *node_next = NULL; |
641 |
> |
dlink_node *node, *node_next; |
642 |
|
|
643 |
|
DLINK_FOREACH_SAFE(node, node_next, source_p->serv->client_list.head) |
644 |
|
exit_one_client(node->data, comment); |
670 |
|
void |
671 |
|
exit_client(struct Client *source_p, const char *comment) |
672 |
|
{ |
673 |
< |
dlink_node *node = NULL; |
673 |
> |
dlink_node *node; |
674 |
|
|
675 |
|
assert(!IsMe(source_p)); |
676 |
|
assert(source_p != &me); |
677 |
|
|
678 |
|
if (MyConnect(source_p)) |
679 |
|
{ |
680 |
< |
/* DO NOT REMOVE. exit_client can be called twice after a failed |
681 |
< |
* read/write. |
680 |
> |
/* |
681 |
> |
* DO NOT REMOVE. exit_client can be called twice after a failed read/write. |
682 |
|
*/ |
683 |
|
if (HasFlag(source_p, FLAGS_CLOSING)) |
684 |
|
return; |
691 |
|
ipcache_remove_address(&source_p->connection->ip); |
692 |
|
} |
693 |
|
|
694 |
< |
delete_auth(&source_p->connection->auth); |
694 |
> |
auth_delete(&source_p->connection->auth); |
695 |
|
|
696 |
|
if (IsClient(source_p)) |
697 |
|
{ |
727 |
– |
time_t on_for = CurrentTime - source_p->connection->firsttime; |
728 |
– |
|
729 |
– |
assert(Count.local > 0); |
730 |
– |
|
731 |
– |
--Count.local; |
732 |
– |
|
698 |
|
if (HasUMode(source_p, UMODE_OPER)) |
699 |
|
if ((node = dlinkFindDelete(&oper_list, source_p))) |
700 |
|
free_dlink_node(node); |
706 |
|
free_list_task(source_p); |
707 |
|
|
708 |
|
watch_del_watch_list(source_p); |
744 |
– |
client_clear_svstags(source_p); |
709 |
|
|
710 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
711 |
|
"Client exiting: %s (%s@%s) [%s] [%s]", |
712 |
< |
source_p->name, source_p->username, source_p->host, comment, |
713 |
< |
source_p->sockhost); |
712 |
> |
source_p->name, source_p->username, source_p->realhost, |
713 |
> |
source_p->sockhost, comment); |
714 |
|
|
715 |
< |
ilog(LOG_TYPE_USER, "%s (%3u:%02u:%02u): %s!%s@%s %llu/%llu", |
716 |
< |
date_ctime(source_p->connection->firsttime), (unsigned int)(on_for / 3600), |
717 |
< |
(unsigned int)((on_for % 3600)/60), (unsigned int)(on_for % 60), |
715 |
> |
ilog(LOG_TYPE_USER, "%s (%ju): %s!%s@%s %s %s %ju/%ju :%s", |
716 |
> |
date_ctime(source_p->connection->firsttime), |
717 |
> |
CurrentTime - source_p->connection->firsttime, |
718 |
|
source_p->name, source_p->username, source_p->host, |
719 |
< |
source_p->connection->send.bytes>>10, |
720 |
< |
source_p->connection->recv.bytes>>10); |
719 |
> |
source_p->sockhost, source_p->account, |
720 |
> |
source_p->connection->send.bytes >> 10, |
721 |
> |
source_p->connection->recv.bytes >> 10, source_p->info); |
722 |
|
} |
723 |
|
else if (IsServer(source_p)) |
724 |
|
{ |
760 |
– |
assert(Count.myserver > 0); |
761 |
– |
|
762 |
– |
--Count.myserver; |
763 |
– |
|
725 |
|
assert(dlinkFind(&local_server_list, source_p)); |
726 |
|
dlinkDelete(&source_p->connection->lclient_node, &local_server_list); |
727 |
|
} |
751 |
|
} |
752 |
|
else if (IsClient(source_p) && HasFlag(source_p->servptr, FLAGS_EOB)) |
753 |
|
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
754 |
< |
"Client exiting at %s: %s (%s@%s) [%s]", |
754 |
> |
"Client exiting at %s: %s (%s@%s) [%s] [%s]", |
755 |
|
source_p->servptr->name, source_p->name, |
756 |
< |
source_p->username, source_p->host, comment); |
756 |
> |
source_p->username, source_p->realhost, source_p->sockhost, comment); |
757 |
|
|
758 |
|
if (IsServer(source_p)) |
759 |
|
{ |
781 |
|
|
782 |
|
if (MyConnect(source_p)) |
783 |
|
{ |
823 |
– |
int connected = CurrentTime - source_p->connection->firsttime; |
784 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
785 |
< |
"%s was connected for %d day%s, %2d:%02d:%02d. %llu/%llu sendK/recvK.", |
786 |
< |
source_p->name, connected/86400, (connected/86400 == 1) ? "" : "s", |
827 |
< |
(connected % 86400) / 3600, (connected % 3600) / 60, connected % 60, |
785 |
> |
"%s was connected for %s. %ju/%ju sendK/recvK.", |
786 |
> |
source_p->name, time_dissect(CurrentTime - source_p->connection->firsttime), |
787 |
|
source_p->connection->send.bytes >> 10, |
788 |
|
source_p->connection->recv.bytes >> 10); |
789 |
< |
ilog(LOG_TYPE_IRCD, "%s was connected for %d day%s, %2d:%02d:%02d. %llu/%llu sendK/recvK.", |
790 |
< |
source_p->name, connected/86400, (connected/86400 == 1) ? "" : "s", |
832 |
< |
(connected % 86400) / 3600, (connected % 3600) / 60, connected % 60, |
789 |
> |
ilog(LOG_TYPE_IRCD, "%s was connected for %s. %ju/%ju sendK/recvK.", |
790 |
> |
source_p->name, time_dissect(CurrentTime - source_p->connection->firsttime), |
791 |
|
source_p->connection->send.bytes >> 10, |
792 |
|
source_p->connection->recv.bytes >> 10); |
793 |
|
} |
794 |
|
} |
795 |
|
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
796 |
< |
sendto_server(source_p->from, 0, 0, ":%s QUIT :%s", |
839 |
< |
source_p->id, comment); |
796 |
> |
sendto_server(source_p->from, 0, 0, ":%s QUIT :%s", source_p->id, comment); |
797 |
|
|
798 |
|
/* The client *better* be off all of the lists */ |
799 |
|
assert(dlinkFind(&unknown_list, source_p) == NULL); |
850 |
|
|
851 |
|
if (IsServer(client_p) || IsHandshake(client_p)) |
852 |
|
{ |
896 |
– |
int connected = CurrentTime - client_p->connection->firsttime; |
897 |
– |
|
853 |
|
if (error == 0) |
854 |
|
{ |
855 |
|
/* Admins get the real IP */ |
856 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
857 |
|
"Server %s closed the connection", |
858 |
< |
get_client_name(client_p, SHOW_IP)); |
858 |
> |
client_get_name(client_p, SHOW_IP)); |
859 |
|
|
860 |
|
/* Opers get a masked IP */ |
861 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
862 |
|
"Server %s closed the connection", |
863 |
< |
get_client_name(client_p, MASK_IP)); |
863 |
> |
client_get_name(client_p, MASK_IP)); |
864 |
|
|
865 |
|
ilog(LOG_TYPE_IRCD, "Server %s closed the connection", |
866 |
< |
get_client_name(client_p, SHOW_IP)); |
866 |
> |
client_get_name(client_p, SHOW_IP)); |
867 |
|
} |
868 |
|
else |
869 |
|
{ |
870 |
|
report_error(L_ADMIN, "Lost connection to %s: %s", |
871 |
< |
get_client_name(client_p, SHOW_IP), current_error); |
871 |
> |
client_get_name(client_p, SHOW_IP), current_error); |
872 |
|
report_error(L_OPER, "Lost connection to %s: %s", |
873 |
< |
get_client_name(client_p, MASK_IP), current_error); |
873 |
> |
client_get_name(client_p, MASK_IP), current_error); |
874 |
|
} |
875 |
|
|
876 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
877 |
< |
"%s was connected for %d day%s, %2d:%02d:%02d", |
878 |
< |
client_p->name, connected/86400, |
924 |
< |
(connected/86400 == 1) ? "" : "s", |
925 |
< |
(connected % 86400) / 3600, (connected % 3600) / 60, |
926 |
< |
connected % 60); |
877 |
> |
"%s was connected for %s", |
878 |
> |
client_p->name, time_dissect(CurrentTime - client_p->connection->firsttime)); |
879 |
|
} |
880 |
|
|
881 |
|
if (error == 0) |
936 |
|
{ |
937 |
|
dlinkDelete(&accept_p->node, &client_p->connection->acceptlist); |
938 |
|
|
939 |
< |
MyFree(accept_p->nickptr); |
940 |
< |
MyFree(accept_p->userptr); |
941 |
< |
MyFree(accept_p->hostptr); |
942 |
< |
MyFree(accept_p); |
939 |
> |
xfree(accept_p->nickptr); |
940 |
> |
xfree(accept_p->userptr); |
941 |
> |
xfree(accept_p->hostptr); |
942 |
> |
xfree(accept_p); |
943 |
|
} |
944 |
|
|
945 |
|
struct split_nuh_item * |
947 |
|
const char *host, struct Client *client_p, |
948 |
|
int (*cmpfunc)(const char *, const char *)) |
949 |
|
{ |
950 |
< |
dlink_node *node = NULL; |
950 |
> |
dlink_node *node; |
951 |
|
|
952 |
|
DLINK_FOREACH(node, client_p->connection->acceptlist.head) |
953 |
|
{ |
973 |
|
accept_message(struct Client *source, |
974 |
|
struct Client *target) |
975 |
|
{ |
976 |
< |
dlink_node *node = NULL; |
976 |
> |
dlink_node *node; |
977 |
|
|
978 |
|
if (HasFlag(source, FLAGS_SERVICE) || |
979 |
|
(HasUMode(source, UMODE_OPER) && ConfigGeneral.opers_bypass_callerid)) |
1000 |
|
void |
1001 |
|
del_all_accepts(struct Client *client_p) |
1002 |
|
{ |
1003 |
< |
dlink_node *node = NULL, *node_next = NULL; |
1003 |
> |
dlink_node *node, *node_next; |
1004 |
|
|
1005 |
|
DLINK_FOREACH_SAFE(node, node_next, client_p->connection->acceptlist.head) |
1006 |
|
del_accept(node->data, client_p); |
1011 |
|
const struct Client *target_p) |
1012 |
|
{ |
1013 |
|
unsigned int idle = 0; |
1062 |
– |
unsigned int min_idle = 0; |
1063 |
– |
unsigned int max_idle = 0; |
1014 |
|
const struct ClassItem *const class = get_class_ptr(&target_p->connection->confs); |
1015 |
|
|
1016 |
|
if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p) |
1020 |
|
!(class->flags & CLASS_FLAGS_HIDE_IDLE_FROM_OPERS)) |
1021 |
|
return CurrentTime - target_p->connection->last_privmsg; |
1022 |
|
|
1023 |
< |
min_idle = class->min_idle; |
1024 |
< |
max_idle = class->max_idle; |
1023 |
> |
const unsigned int min_idle = class->min_idle; |
1024 |
> |
const unsigned int max_idle = class->max_idle; |
1025 |
|
|
1026 |
|
if (min_idle == max_idle) |
1027 |
|
return min_idle; |
1031 |
|
else |
1032 |
|
idle = CurrentTime - target_p->connection->last_privmsg; |
1033 |
|
|
1034 |
< |
if (!max_idle) |
1085 |
< |
idle = 0; |
1086 |
< |
else |
1034 |
> |
if (max_idle) |
1035 |
|
idle %= max_idle; |
1036 |
+ |
else |
1037 |
+ |
idle = 0; |
1038 |
|
|
1039 |
|
if (idle < min_idle) |
1040 |
|
idle = min_idle + (idle % (max_idle - min_idle)); |