1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2016 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2018 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 |
43 |
|
#include "whowas.h" |
44 |
|
#include "user.h" |
45 |
|
#include "memory.h" |
46 |
– |
#include "mempool.h" |
46 |
|
#include "hostmask.h" |
47 |
|
#include "listener.h" |
48 |
|
#include "userhost.h" |
60 |
|
dlink_list global_server_list; |
61 |
|
dlink_list oper_list; |
62 |
|
|
64 |
– |
static mp_pool_t *client_pool, *connection_pool; |
63 |
|
static dlink_list dead_list, abort_list; |
64 |
|
static dlink_node *eac_next; /* next aborted client to exit */ |
65 |
|
|
80 |
|
* 'from'). ('from' is a local client!!). |
81 |
|
*/ |
82 |
|
struct Client * |
83 |
< |
make_client(struct Client *from) |
83 |
> |
client_make(struct Client *from) |
84 |
|
{ |
85 |
< |
struct Client *const client_p = mp_pool_get(client_pool); |
85 |
> |
struct Client *const client_p = xcalloc(sizeof(*client_p)); |
86 |
|
|
87 |
< |
if (!from) |
87 |
> |
if (from) |
88 |
> |
client_p->from = from; |
89 |
> |
else |
90 |
|
{ |
91 |
|
client_p->from = client_p; /* 'from' of local client is self! */ |
92 |
< |
client_p->connection = mp_pool_get(connection_pool); |
92 |
> |
client_p->connection = xcalloc(sizeof(*client_p->connection)); |
93 |
|
client_p->connection->since = CurrentTime; |
94 |
|
client_p->connection->lasttime = CurrentTime; |
95 |
|
client_p->connection->firsttime = CurrentTime; |
98 |
|
/* as good a place as any... */ |
99 |
|
dlinkAdd(client_p, &client_p->connection->lclient_node, &unknown_list); |
100 |
|
} |
101 |
– |
else |
102 |
– |
client_p->from = from; |
101 |
|
|
102 |
|
client_p->idhnext = client_p; |
103 |
|
client_p->hnext = client_p; |
109 |
|
} |
110 |
|
|
111 |
|
/* |
112 |
< |
* free_client |
112 |
> |
* client_free |
113 |
|
* |
114 |
|
* inputs - pointer to client |
115 |
|
* output - NONE |
116 |
|
* side effects - client pointed to has its memory freed |
117 |
|
*/ |
118 |
|
static void |
119 |
< |
free_client(struct Client *client_p) |
119 |
> |
client_free(struct Client *client_p) |
120 |
|
{ |
121 |
+ |
assert(!IsMe(client_p)); |
122 |
|
assert(client_p != &me); |
123 |
|
assert(client_p->hnext == client_p); |
124 |
|
assert(client_p->idhnext == client_p); |
125 |
< |
assert(client_p->channel.head == NULL); |
126 |
< |
assert(dlink_list_length(&client_p->channel) == 0); |
125 |
> |
|
126 |
> |
assert(client_p->node.data == NULL); |
127 |
> |
assert(client_p->node.prev == NULL); |
128 |
> |
assert(client_p->node.next == NULL); |
129 |
> |
|
130 |
> |
assert(client_p->lnode.data == NULL); |
131 |
> |
assert(client_p->lnode.prev == NULL); |
132 |
> |
assert(client_p->lnode.next == NULL); |
133 |
> |
|
134 |
|
assert(dlink_list_length(&client_p->whowas_list) == 0); |
135 |
+ |
assert(client_p->whowas_list.head == NULL); |
136 |
+ |
assert(client_p->whowas_list.tail == NULL); |
137 |
+ |
|
138 |
+ |
assert(dlink_list_length(&client_p->channel) == 0); |
139 |
+ |
assert(client_p->channel.head == NULL); |
140 |
+ |
assert(client_p->channel.tail == NULL); |
141 |
+ |
|
142 |
|
assert(dlink_list_length(&client_p->svstags) == 0); |
143 |
+ |
assert(client_p->svstags.head == NULL); |
144 |
+ |
assert(client_p->svstags.tail == NULL); |
145 |
+ |
|
146 |
|
|
147 |
|
xfree(client_p->serv); |
148 |
|
xfree(client_p->certfp); |
149 |
|
|
150 |
|
if (MyConnect(client_p)) |
151 |
|
{ |
152 |
< |
assert(client_p->connection->invited.head == NULL); |
153 |
< |
assert(dlink_list_length(&client_p->connection->invited) == 0); |
152 |
> |
assert(client_p->connection->lclient_node.data == NULL); |
153 |
> |
assert(client_p->connection->lclient_node.prev == NULL); |
154 |
> |
assert(client_p->connection->lclient_node.next == NULL); |
155 |
> |
|
156 |
> |
assert(client_p->connection->list_task == NULL); |
157 |
> |
assert(client_p->connection->auth == NULL); |
158 |
> |
|
159 |
> |
assert(dlink_list_length(&client_p->connection->acceptlist) == 0); |
160 |
> |
assert(client_p->connection->acceptlist.head == NULL); |
161 |
> |
assert(client_p->connection->acceptlist.tail == NULL); |
162 |
> |
|
163 |
> |
|
164 |
|
assert(dlink_list_length(&client_p->connection->watches) == 0); |
165 |
+ |
assert(client_p->connection->watches.head == NULL); |
166 |
+ |
assert(client_p->connection->watches.tail == NULL); |
167 |
+ |
|
168 |
+ |
assert(dlink_list_length(&client_p->connection->confs) == 0); |
169 |
+ |
assert(client_p->connection->confs.head == NULL); |
170 |
+ |
assert(client_p->connection->confs.tail == NULL); |
171 |
+ |
|
172 |
+ |
assert(dlink_list_length(&client_p->connection->invited) == 0); |
173 |
+ |
assert(client_p->connection->invited.head == NULL); |
174 |
+ |
assert(client_p->connection->invited.tail == NULL); |
175 |
+ |
|
176 |
+ |
assert(client_p->connection->fd == NULL); |
177 |
+ |
|
178 |
|
assert(HasFlag(client_p, FLAGS_CLOSING) && IsDead(client_p)); |
179 |
|
|
180 |
|
/* |
189 |
|
dbuf_clear(&client_p->connection->buf_recvq); |
190 |
|
dbuf_clear(&client_p->connection->buf_sendq); |
191 |
|
|
192 |
< |
mp_pool_release(client_p->connection); |
192 |
> |
xfree(client_p->connection); |
193 |
> |
client_p->connection = NULL; |
194 |
|
} |
195 |
|
|
196 |
< |
mp_pool_release(client_p); |
196 |
> |
xfree(client_p); |
197 |
> |
} |
198 |
> |
|
199 |
> |
static void |
200 |
> |
svstag_free(struct ServicesTag *svstag, dlink_list *list) |
201 |
> |
{ |
202 |
> |
dlinkDelete(&svstag->node, list); |
203 |
> |
xfree(svstag->tag); |
204 |
> |
xfree(svstag); |
205 |
|
} |
206 |
|
|
207 |
|
void |
208 |
< |
client_attach_svstag(struct Client *client_p, unsigned int numeric, |
208 |
> |
client_detach_svstag(dlink_list *list, unsigned int numeric) |
209 |
> |
{ |
210 |
> |
dlink_node *node, *node_next; |
211 |
> |
|
212 |
> |
DLINK_FOREACH_SAFE(node, node_next, list->head) |
213 |
> |
{ |
214 |
> |
struct ServicesTag *svstag = node->data; |
215 |
> |
|
216 |
> |
if (svstag->numeric == numeric) |
217 |
> |
svstag_free(svstag, list); |
218 |
> |
} |
219 |
> |
} |
220 |
> |
|
221 |
> |
void |
222 |
> |
client_attach_svstag(dlink_list *list, unsigned int numeric, |
223 |
|
const char *umodes, const char *tag) |
224 |
|
{ |
225 |
|
const struct user_modes *tab = NULL; |
236 |
|
svstag->umodes |= tab->flag; |
237 |
|
|
238 |
|
if (numeric != RPL_WHOISOPERATOR) |
239 |
< |
dlinkAddTail(svstag, &svstag->node, &client_p->svstags); |
239 |
> |
dlinkAddTail(svstag, &svstag->node, list); |
240 |
|
else |
241 |
< |
dlinkAdd(svstag, &svstag->node, &client_p->svstags); |
241 |
> |
dlinkAdd(svstag, &svstag->node, list); |
242 |
|
} |
243 |
|
|
244 |
|
void |
245 |
< |
client_clear_svstags(struct Client *client_p) |
245 |
> |
client_clear_svstags(dlink_list *list) |
246 |
|
{ |
247 |
< |
while (client_p->svstags.head) |
248 |
< |
{ |
187 |
< |
struct ServicesTag *svstag = client_p->svstags.head->data; |
188 |
< |
|
189 |
< |
dlinkDelete(&svstag->node, &client_p->svstags); |
190 |
< |
xfree(svstag->tag); |
191 |
< |
xfree(svstag); |
192 |
< |
} |
247 |
> |
while (list->head) |
248 |
> |
svstag_free(list->head->data, list); |
249 |
|
} |
250 |
|
|
251 |
|
/* check_pings_list() |
298 |
|
{ |
299 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
300 |
|
"No response from %s, closing link", |
301 |
< |
get_client_name(client_p, SHOW_IP)); |
301 |
> |
client_get_name(client_p, SHOW_IP)); |
302 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
303 |
|
"No response from %s, closing link", |
304 |
< |
get_client_name(client_p, MASK_IP)); |
304 |
> |
client_get_name(client_p, MASK_IP)); |
305 |
|
ilog(LOG_TYPE_IRCD, "No response from %s, closing link", |
306 |
< |
get_client_name(client_p, SHOW_IP)); |
306 |
> |
client_get_name(client_p, SHOW_IP)); |
307 |
|
} |
308 |
|
|
309 |
|
snprintf(buf, sizeof(buf), "Ping timeout: %ji seconds", |
453 |
|
{ |
454 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
455 |
|
"KLINE over-ruled for %s, client is kline_exempt", |
456 |
< |
get_client_name(client_p, HIDE_IP)); |
456 |
> |
client_get_name(client_p, HIDE_IP)); |
457 |
|
return; |
458 |
|
} |
459 |
|
|
470 |
|
{ |
471 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
472 |
|
"XLINE over-ruled for %s, client is xline_exempt", |
473 |
< |
get_client_name(client_p, HIDE_IP)); |
473 |
> |
client_get_name(client_p, HIDE_IP)); |
474 |
|
return; |
475 |
|
} |
476 |
|
|
482 |
|
} |
483 |
|
|
484 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%c-line active for %s", |
485 |
< |
ban_type, get_client_name(client_p, HIDE_IP)); |
485 |
> |
ban_type, client_get_name(client_p, HIDE_IP)); |
486 |
|
|
487 |
|
if (IsClient(client_p)) |
488 |
|
sendto_one_numeric(client_p, &me, ERR_YOUREBANNEDCREEP, reason); |
490 |
|
exit_client(client_p, reason); |
491 |
|
} |
492 |
|
|
437 |
– |
/* update_client_exit_stats() |
438 |
– |
* |
439 |
– |
* input - pointer to client |
440 |
– |
* output - NONE |
441 |
– |
* side effects - |
442 |
– |
*/ |
443 |
– |
static void |
444 |
– |
update_client_exit_stats(struct Client *client_p) |
445 |
– |
{ |
446 |
– |
if (IsClient(client_p)) |
447 |
– |
{ |
448 |
– |
assert(Count.total > 0); |
449 |
– |
|
450 |
– |
--Count.total; |
451 |
– |
if (HasUMode(client_p, UMODE_OPER)) |
452 |
– |
--Count.oper; |
453 |
– |
if (HasUMode(client_p, UMODE_INVISIBLE)) |
454 |
– |
--Count.invisi; |
455 |
– |
} |
456 |
– |
else if (IsServer(client_p)) |
457 |
– |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE, |
458 |
– |
"Server %s split from %s", |
459 |
– |
client_p->name, client_p->servptr->name); |
460 |
– |
} |
461 |
– |
|
493 |
|
/* find_person() |
494 |
|
* |
495 |
|
* inputs - pointer to name |
529 |
|
return NULL; |
530 |
|
|
531 |
|
target_p = whowas_get_history(name, ConfigGeneral.kill_chase_time_limit); |
501 |
– |
|
532 |
|
if (!target_p) |
503 |
– |
{ |
533 |
|
sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, name); |
505 |
– |
return NULL; |
506 |
– |
} |
534 |
|
|
535 |
|
return target_p; |
536 |
|
} |
537 |
|
|
538 |
|
/* |
539 |
< |
* get_client_name - Return the name of the client |
539 |
> |
* client_get_name - Return the name of the client |
540 |
|
* for various tracking and |
541 |
|
* admin purposes. The main purpose of this function is to |
542 |
|
* return the "socket host" name of the client, if that |
554 |
|
* to modify what it points!!! |
555 |
|
*/ |
556 |
|
const char * |
557 |
< |
get_client_name(const struct Client *client_p, enum addr_mask_type type) |
557 |
> |
client_get_name(const struct Client *client_p, enum addr_mask_type type) |
558 |
|
{ |
559 |
|
static char buf[HOSTLEN * 2 + USERLEN + 4]; /* +4 for [,@,],\0 */ |
560 |
|
|
597 |
|
void |
598 |
|
free_exited_clients(void) |
599 |
|
{ |
600 |
< |
dlink_node *node = NULL, *node_next = NULL; |
600 |
> |
dlink_node *node, *node_next; |
601 |
|
|
602 |
|
DLINK_FOREACH_SAFE(node, node_next, dead_list.head) |
603 |
|
{ |
604 |
< |
free_client(node->data); |
604 |
> |
client_free(node->data); |
605 |
|
dlinkDelete(node, &dead_list); |
606 |
|
free_dlink_node(node); |
607 |
|
} |
608 |
|
} |
609 |
|
|
610 |
|
/* |
611 |
+ |
* client_close_connection |
612 |
+ |
* Close the physical connection. This function must make |
613 |
+ |
* MyConnect(client_p) == FALSE, and set client_p->from == NULL. |
614 |
+ |
*/ |
615 |
+ |
static void |
616 |
+ |
client_close_connection(struct Client *client_p) |
617 |
+ |
{ |
618 |
+ |
assert(client_p); |
619 |
+ |
|
620 |
+ |
if (!IsDead(client_p)) |
621 |
+ |
{ |
622 |
+ |
/* attempt to flush any pending dbufs. Evil, but .. -- adrian */ |
623 |
+ |
/* there is still a chance that we might send data to this socket |
624 |
+ |
* even if it is marked as blocked (COMM_SELECT_READ handler is called |
625 |
+ |
* before COMM_SELECT_WRITE). Let's try, nothing to lose.. -adx |
626 |
+ |
*/ |
627 |
+ |
DelFlag(client_p, FLAGS_BLOCKED); |
628 |
+ |
send_queued_write(client_p); |
629 |
+ |
} |
630 |
+ |
|
631 |
+ |
if (IsClient(client_p)) |
632 |
+ |
{ |
633 |
+ |
++ServerStats.is_cl; |
634 |
+ |
ServerStats.is_cbs += client_p->connection->send.bytes; |
635 |
+ |
ServerStats.is_cbr += client_p->connection->recv.bytes; |
636 |
+ |
ServerStats.is_cti += CurrentTime - client_p->connection->firsttime; |
637 |
+ |
} |
638 |
+ |
else if (IsServer(client_p)) |
639 |
+ |
{ |
640 |
+ |
dlink_node *node = NULL; |
641 |
+ |
|
642 |
+ |
++ServerStats.is_sv; |
643 |
+ |
ServerStats.is_sbs += client_p->connection->send.bytes; |
644 |
+ |
ServerStats.is_sbr += client_p->connection->recv.bytes; |
645 |
+ |
ServerStats.is_sti += CurrentTime - client_p->connection->firsttime; |
646 |
+ |
|
647 |
+ |
DLINK_FOREACH(node, connect_items.head) |
648 |
+ |
{ |
649 |
+ |
struct MaskItem *conf = node->data; |
650 |
+ |
|
651 |
+ |
if (irccmp(conf->name, client_p->name)) |
652 |
+ |
continue; |
653 |
+ |
|
654 |
+ |
/* |
655 |
+ |
* Reset next-connect cycle of all connect{} blocks that match |
656 |
+ |
* this servername. |
657 |
+ |
*/ |
658 |
+ |
conf->until = CurrentTime + conf->class->con_freq; |
659 |
+ |
} |
660 |
+ |
} |
661 |
+ |
else |
662 |
+ |
++ServerStats.is_ni; |
663 |
+ |
|
664 |
+ |
if (tls_isusing(&client_p->connection->fd->ssl)) |
665 |
+ |
tls_shutdown(&client_p->connection->fd->ssl); |
666 |
+ |
|
667 |
+ |
if (client_p->connection->fd) |
668 |
+ |
{ |
669 |
+ |
fd_close(client_p->connection->fd); |
670 |
+ |
client_p->connection->fd = NULL; |
671 |
+ |
} |
672 |
+ |
|
673 |
+ |
dbuf_clear(&client_p->connection->buf_sendq); |
674 |
+ |
dbuf_clear(&client_p->connection->buf_recvq); |
675 |
+ |
|
676 |
+ |
xfree(client_p->connection->password); |
677 |
+ |
client_p->connection->password = NULL; |
678 |
+ |
|
679 |
+ |
conf_detach(client_p, CONF_CLIENT | CONF_OPER | CONF_SERVER); |
680 |
+ |
} |
681 |
+ |
|
682 |
+ |
/* |
683 |
|
* Exit one client, local or remote. Assuming all dependents have |
684 |
|
* been already removed, and socket closed for local client. |
685 |
|
* |
688 |
|
static void |
689 |
|
exit_one_client(struct Client *source_p, const char *comment) |
690 |
|
{ |
691 |
< |
dlink_node *node = NULL, *node_next = NULL; |
691 |
> |
dlink_node *node, *node_next; |
692 |
|
|
693 |
|
assert(!IsMe(source_p)); |
694 |
|
assert(source_p != &me); |
695 |
|
|
696 |
|
if (IsClient(source_p)) |
697 |
|
{ |
698 |
+ |
if (HasUMode(source_p, UMODE_OPER)) |
699 |
+ |
--Count.oper; |
700 |
+ |
if (HasUMode(source_p, UMODE_INVISIBLE)) |
701 |
+ |
--Count.invisi; |
702 |
+ |
|
703 |
|
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list); |
704 |
|
dlinkDelete(&source_p->node, &global_client_list); |
705 |
|
|
716 |
|
DLINK_FOREACH_SAFE(node, node_next, source_p->channel.head) |
717 |
|
remove_user_from_channel(node->data); |
718 |
|
|
719 |
< |
client_clear_svstags(source_p); |
719 |
> |
client_clear_svstags(&source_p->svstags); |
720 |
|
|
721 |
|
whowas_add_history(source_p, 0); |
722 |
|
whowas_off_history(source_p); |
723 |
|
|
724 |
|
watch_check_hash(source_p, RPL_LOGOFF); |
621 |
– |
|
622 |
– |
if (MyConnect(source_p)) |
623 |
– |
{ |
624 |
– |
clear_invites_client(source_p); |
625 |
– |
del_all_accepts(source_p); |
626 |
– |
} |
725 |
|
} |
726 |
|
else if (IsServer(source_p)) |
727 |
|
{ |
728 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
729 |
< |
dlinkDelete(&source_p->node, &global_client_list); |
728 |
> |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE, |
729 |
> |
"Server %s split from %s", |
730 |
> |
source_p->name, source_p->servptr->name); |
731 |
|
|
732 |
< |
if ((node = dlinkFindDelete(&global_server_list, source_p))) |
733 |
< |
free_dlink_node(node); |
732 |
> |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
733 |
> |
dlinkDelete(&source_p->node, &global_server_list); |
734 |
|
} |
735 |
|
|
736 |
|
/* Remove source_p from the client lists */ |
741 |
|
hash_del_client(source_p); |
742 |
|
|
743 |
|
if (HasFlag(source_p, FLAGS_USERHOST)) |
744 |
< |
userhost_del(source_p->username, source_p->host, !MyConnect(source_p)); |
646 |
< |
|
647 |
< |
update_client_exit_stats(source_p); |
744 |
> |
userhost_del(source_p->sockhost, !MyConnect(source_p)); |
745 |
|
|
746 |
|
/* Check to see if the client isn't already on the dead list */ |
747 |
|
assert(dlinkFind(&dead_list, source_p) == NULL); |
760 |
|
static void |
761 |
|
recurse_remove_clients(struct Client *source_p, const char *comment) |
762 |
|
{ |
763 |
< |
dlink_node *node = NULL, *node_next = NULL; |
763 |
> |
dlink_node *node, *node_next; |
764 |
|
|
765 |
|
DLINK_FOREACH_SAFE(node, node_next, source_p->serv->client_list.head) |
766 |
|
exit_one_client(node->data, comment); |
792 |
|
void |
793 |
|
exit_client(struct Client *source_p, const char *comment) |
794 |
|
{ |
698 |
– |
dlink_node *node = NULL; |
699 |
– |
|
795 |
|
assert(!IsMe(source_p)); |
796 |
|
assert(source_p != &me); |
797 |
|
|
798 |
|
if (MyConnect(source_p)) |
799 |
|
{ |
800 |
< |
/* DO NOT REMOVE. exit_client can be called twice after a failed |
801 |
< |
* read/write. |
800 |
> |
/* |
801 |
> |
* DO NOT REMOVE. exit_client can be called twice after a failed read/write. |
802 |
|
*/ |
803 |
|
if (HasFlag(source_p, FLAGS_CLOSING)) |
804 |
|
return; |
811 |
|
ipcache_remove_address(&source_p->connection->ip); |
812 |
|
} |
813 |
|
|
814 |
< |
delete_auth(&source_p->connection->auth); |
814 |
> |
if (source_p->connection->auth) |
815 |
> |
{ |
816 |
> |
auth_delete(source_p->connection->auth); |
817 |
> |
source_p->connection->auth = NULL; |
818 |
> |
} |
819 |
|
|
820 |
|
if (IsClient(source_p)) |
821 |
|
{ |
822 |
< |
assert(Count.local > 0); |
724 |
< |
|
725 |
< |
--Count.local; |
822 |
> |
dlink_node *node; |
823 |
|
|
824 |
|
if (HasUMode(source_p, UMODE_OPER)) |
825 |
|
if ((node = dlinkFindDelete(&oper_list, source_p))) |
831 |
|
if (source_p->connection->list_task) |
832 |
|
free_list_task(source_p); |
833 |
|
|
834 |
+ |
clear_invite_list(&source_p->connection->invited); |
835 |
+ |
del_all_accepts(source_p); |
836 |
|
watch_del_watch_list(source_p); |
837 |
|
|
838 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
839 |
|
"Client exiting: %s (%s@%s) [%s] [%s]", |
840 |
< |
source_p->name, source_p->username, source_p->host, |
840 |
> |
source_p->name, source_p->username, source_p->realhost, |
841 |
|
source_p->sockhost, comment); |
842 |
|
|
843 |
|
ilog(LOG_TYPE_USER, "%s (%ju): %s!%s@%s %s %s %ju/%ju :%s", |
850 |
|
} |
851 |
|
else if (IsServer(source_p)) |
852 |
|
{ |
754 |
– |
assert(Count.myserver > 0); |
755 |
– |
|
756 |
– |
--Count.myserver; |
757 |
– |
|
853 |
|
assert(dlinkFind(&local_server_list, source_p)); |
854 |
|
dlinkDelete(&source_p->connection->lclient_node, &local_server_list); |
855 |
|
} |
875 |
|
source_p->host, comment); |
876 |
|
} |
877 |
|
|
878 |
< |
close_connection(source_p); |
878 |
> |
client_close_connection(source_p); |
879 |
|
} |
880 |
|
else if (IsClient(source_p) && HasFlag(source_p->servptr, FLAGS_EOB)) |
881 |
|
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
882 |
|
"Client exiting at %s: %s (%s@%s) [%s] [%s]", |
883 |
|
source_p->servptr->name, source_p->name, |
884 |
< |
source_p->username, source_p->host, source_p->sockhost, comment); |
884 |
> |
source_p->username, source_p->realhost, source_p->sockhost, comment); |
885 |
|
|
886 |
|
if (IsServer(source_p)) |
887 |
|
{ |
921 |
|
} |
922 |
|
} |
923 |
|
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
924 |
< |
sendto_server(source_p->from, 0, 0, ":%s QUIT :%s", |
830 |
< |
source_p->id, comment); |
924 |
> |
sendto_server(source_p->from, 0, 0, ":%s QUIT :%s", source_p->id, comment); |
925 |
|
|
926 |
|
/* The client *better* be off all of the lists */ |
927 |
|
assert(dlinkFind(&unknown_list, source_p) == NULL); |
928 |
|
assert(dlinkFind(&local_client_list, source_p) == NULL); |
929 |
|
assert(dlinkFind(&local_server_list, source_p) == NULL); |
930 |
|
assert(dlinkFind(&oper_list, source_p) == NULL); |
931 |
+ |
assert(dlinkFind(&listing_client_list, source_p) == NULL); |
932 |
|
|
933 |
|
exit_one_client(source_p, comment); |
934 |
|
} |
975 |
|
dbuf_clear(&client_p->connection->buf_recvq); |
976 |
|
dbuf_clear(&client_p->connection->buf_sendq); |
977 |
|
|
978 |
< |
current_error = get_sockerr(client_p->connection->fd.fd); |
978 |
> |
current_error = get_sockerr(client_p->connection->fd->fd); |
979 |
|
|
980 |
|
if (IsServer(client_p) || IsHandshake(client_p)) |
981 |
|
{ |
982 |
|
if (error == 0) |
983 |
|
{ |
889 |
– |
/* Admins get the real IP */ |
984 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
985 |
|
"Server %s closed the connection", |
986 |
< |
get_client_name(client_p, SHOW_IP)); |
893 |
< |
|
894 |
< |
/* Opers get a masked IP */ |
986 |
> |
client_get_name(client_p, SHOW_IP)); |
987 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
988 |
|
"Server %s closed the connection", |
989 |
< |
get_client_name(client_p, MASK_IP)); |
898 |
< |
|
989 |
> |
client_get_name(client_p, MASK_IP)); |
990 |
|
ilog(LOG_TYPE_IRCD, "Server %s closed the connection", |
991 |
< |
get_client_name(client_p, SHOW_IP)); |
991 |
> |
client_get_name(client_p, SHOW_IP)); |
992 |
|
} |
993 |
|
else |
994 |
|
{ |
995 |
< |
report_error(L_ADMIN, "Lost connection to %s: %s", |
996 |
< |
get_client_name(client_p, SHOW_IP), current_error); |
997 |
< |
report_error(L_OPER, "Lost connection to %s: %s", |
998 |
< |
get_client_name(client_p, MASK_IP), current_error); |
995 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
996 |
> |
"Lost connection to %s: %s", |
997 |
> |
client_get_name(client_p, SHOW_IP), strerror(current_error)); |
998 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
999 |
> |
"Lost connection to %s: %s", |
1000 |
> |
client_get_name(client_p, MASK_IP), strerror(current_error)); |
1001 |
> |
ilog(LOG_TYPE_IRCD, "Lost connection to %s: %s", |
1002 |
> |
client_get_name(client_p, SHOW_IP), strerror(current_error)); |
1003 |
|
} |
1004 |
|
|
1005 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
1029 |
|
target_p = ptr->data; |
1030 |
|
eac_next = ptr->next; |
1031 |
|
|
1032 |
+ |
dlinkDelete(ptr, &abort_list); |
1033 |
+ |
free_dlink_node(ptr); |
1034 |
+ |
|
1035 |
|
if (target_p == NULL) |
1036 |
|
{ |
1037 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
1038 |
|
"Warning: null client on abort_list!"); |
941 |
– |
dlinkDelete(ptr, &abort_list); |
942 |
– |
free_dlink_node(ptr); |
1039 |
|
continue; |
1040 |
|
} |
1041 |
|
|
946 |
– |
dlinkDelete(ptr, &abort_list); |
947 |
– |
|
1042 |
|
if (HasFlag(target_p, FLAGS_SENDQEX)) |
1043 |
|
notice = "Max SendQ exceeded"; |
1044 |
|
else |
1045 |
|
notice = "Write error: connection closed"; |
1046 |
|
|
1047 |
|
exit_client(target_p, notice); |
954 |
– |
free_dlink_node(ptr); |
1048 |
|
} |
1049 |
|
} |
1050 |
|
|
1074 |
|
const char *host, struct Client *client_p, |
1075 |
|
int (*cmpfunc)(const char *, const char *)) |
1076 |
|
{ |
1077 |
< |
dlink_node *node = NULL; |
1077 |
> |
dlink_node *node; |
1078 |
|
|
1079 |
|
DLINK_FOREACH(node, client_p->connection->acceptlist.head) |
1080 |
|
{ |
1100 |
|
accept_message(struct Client *source, |
1101 |
|
struct Client *target) |
1102 |
|
{ |
1103 |
< |
dlink_node *node = NULL; |
1103 |
> |
dlink_node *node; |
1104 |
|
|
1105 |
|
if (HasFlag(source, FLAGS_SERVICE) || |
1106 |
|
(HasUMode(source, UMODE_OPER) && ConfigGeneral.opers_bypass_callerid)) |
1127 |
|
void |
1128 |
|
del_all_accepts(struct Client *client_p) |
1129 |
|
{ |
1130 |
< |
dlink_node *node = NULL, *node_next = NULL; |
1130 |
> |
dlink_node *node, *node_next; |
1131 |
|
|
1132 |
|
DLINK_FOREACH_SAFE(node, node_next, client_p->connection->acceptlist.head) |
1133 |
|
del_accept(node->data, client_p); |
1138 |
|
const struct Client *target_p) |
1139 |
|
{ |
1140 |
|
unsigned int idle = 0; |
1048 |
– |
unsigned int min_idle = 0; |
1049 |
– |
unsigned int max_idle = 0; |
1141 |
|
const struct ClassItem *const class = get_class_ptr(&target_p->connection->confs); |
1142 |
|
|
1143 |
|
if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p) |
1147 |
|
!(class->flags & CLASS_FLAGS_HIDE_IDLE_FROM_OPERS)) |
1148 |
|
return CurrentTime - target_p->connection->last_privmsg; |
1149 |
|
|
1150 |
< |
min_idle = class->min_idle; |
1151 |
< |
max_idle = class->max_idle; |
1150 |
> |
const unsigned int min_idle = class->min_idle; |
1151 |
> |
const unsigned int max_idle = class->max_idle; |
1152 |
|
|
1153 |
|
if (min_idle == max_idle) |
1154 |
|
return min_idle; |
1158 |
|
else |
1159 |
|
idle = CurrentTime - target_p->connection->last_privmsg; |
1160 |
|
|
1161 |
< |
if (!max_idle) |
1071 |
< |
idle = 0; |
1072 |
< |
else |
1161 |
> |
if (max_idle) |
1162 |
|
idle %= max_idle; |
1163 |
+ |
else |
1164 |
+ |
idle = 0; |
1165 |
|
|
1166 |
|
if (idle < min_idle) |
1167 |
|
idle = min_idle + (idle % (max_idle - min_idle)); |
1185 |
|
.when = 5 |
1186 |
|
}; |
1187 |
|
|
1097 |
– |
client_pool = mp_pool_new(sizeof(struct Client), MP_CHUNK_SIZE_CLIENT); |
1098 |
– |
connection_pool = mp_pool_new(sizeof(struct Connection), MP_CHUNK_SIZE_CONNECTION); |
1188 |
|
event_add(&event_ping, NULL); |
1189 |
|
} |