1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2015 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 |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU General Public License |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
< |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
|
* USA |
20 |
|
*/ |
21 |
|
|
60 |
|
dlink_list global_server_list; |
61 |
|
dlink_list oper_list; |
62 |
|
|
63 |
< |
static mp_pool_t *client_pool, *lclient_pool; |
63 |
> |
static mp_pool_t *client_pool, *connection_pool; |
64 |
|
static dlink_list dead_list, abort_list; |
65 |
|
static dlink_node *eac_next; /* next aborted client to exit */ |
66 |
|
|
83 |
|
struct Client * |
84 |
|
make_client(struct Client *from) |
85 |
|
{ |
86 |
< |
struct Client *client_p = mp_pool_get(client_pool); |
86 |
> |
struct Client *const client_p = mp_pool_get(client_pool); |
87 |
|
|
88 |
|
if (!from) |
89 |
|
{ |
90 |
< |
client_p->from = client_p; /* 'from' of local client is self! */ |
91 |
< |
client_p->localClient = mp_pool_get(lclient_pool); |
92 |
< |
client_p->localClient->since = CurrentTime; |
93 |
< |
client_p->localClient->lasttime = CurrentTime; |
94 |
< |
client_p->localClient->firsttime = CurrentTime; |
95 |
< |
client_p->localClient->registration = REG_INIT; |
90 |
> |
client_p->from = client_p; /* 'from' of local client is self! */ |
91 |
> |
client_p->connection = mp_pool_get(connection_pool); |
92 |
> |
client_p->connection->since = CurrentTime; |
93 |
> |
client_p->connection->lasttime = CurrentTime; |
94 |
> |
client_p->connection->firsttime = CurrentTime; |
95 |
> |
client_p->connection->registration = REG_INIT; |
96 |
|
|
97 |
|
/* as good a place as any... */ |
98 |
< |
dlinkAdd(client_p, &client_p->localClient->lclient_node, &unknown_list); |
98 |
> |
dlinkAdd(client_p, &client_p->connection->lclient_node, &unknown_list); |
99 |
|
} |
100 |
|
else |
101 |
< |
client_p->from = from; /* 'from' of local client is self! */ |
101 |
> |
client_p->from = from; |
102 |
|
|
103 |
|
client_p->idhnext = client_p; |
104 |
< |
client_p->hnext = client_p; |
104 |
> |
client_p->hnext = client_p; |
105 |
|
SetUnknown(client_p); |
106 |
|
strcpy(client_p->username, "unknown"); |
107 |
< |
strcpy(client_p->svid, "0"); |
107 |
> |
strcpy(client_p->account, "0"); |
108 |
|
|
109 |
|
return client_p; |
110 |
|
} |
119 |
|
static void |
120 |
|
free_client(struct Client *client_p) |
121 |
|
{ |
122 |
– |
assert(client_p); |
122 |
|
assert(client_p != &me); |
123 |
|
assert(client_p->hnext == client_p); |
124 |
|
assert(client_p->idhnext == client_p); |
132 |
|
|
133 |
|
if (MyConnect(client_p)) |
134 |
|
{ |
135 |
< |
assert(client_p->localClient->invited.head == NULL); |
136 |
< |
assert(dlink_list_length(&client_p->localClient->invited) == 0); |
137 |
< |
assert(dlink_list_length(&client_p->localClient->watches) == 0); |
135 |
> |
assert(client_p->connection->invited.head == NULL); |
136 |
> |
assert(dlink_list_length(&client_p->connection->invited) == 0); |
137 |
> |
assert(dlink_list_length(&client_p->connection->watches) == 0); |
138 |
|
assert(IsClosing(client_p) && IsDead(client_p)); |
139 |
|
|
140 |
< |
MyFree(client_p->localClient->response); |
141 |
< |
MyFree(client_p->localClient->auth_oper); |
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 |
|
|
145 |
|
/* |
146 |
< |
* clean up extra sockets from P-lines which have been discarded. |
146 |
> |
* Clean up extra sockets from listen{} blocks which have been discarded. |
147 |
|
*/ |
148 |
< |
if (client_p->localClient->listener) |
148 |
> |
if (client_p->connection->listener) |
149 |
|
{ |
150 |
< |
assert(0 < client_p->localClient->listener->ref_count); |
151 |
< |
if (0 == --client_p->localClient->listener->ref_count && |
151 |
< |
!client_p->localClient->listener->active) |
152 |
< |
free_listener(client_p->localClient->listener); |
150 |
> |
listener_release(client_p->connection->listener); |
151 |
> |
client_p->connection->listener = NULL; |
152 |
|
} |
153 |
|
|
154 |
< |
dbuf_clear(&client_p->localClient->buf_recvq); |
155 |
< |
dbuf_clear(&client_p->localClient->buf_sendq); |
154 |
> |
dbuf_clear(&client_p->connection->buf_recvq); |
155 |
> |
dbuf_clear(&client_p->connection->buf_sendq); |
156 |
|
|
157 |
< |
mp_pool_release(client_p->localClient); |
157 |
> |
mp_pool_release(client_p->connection); |
158 |
|
} |
159 |
|
|
160 |
|
mp_pool_release(client_p); |
161 |
|
} |
162 |
|
|
163 |
+ |
void |
164 |
+ |
client_clear_svstags(struct Client *client_p) |
165 |
+ |
{ |
166 |
+ |
dlink_node *node = NULL, *node_next = NULL; |
167 |
+ |
|
168 |
+ |
DLINK_FOREACH_SAFE(node, node_next, client_p->svstags.head) |
169 |
+ |
{ |
170 |
+ |
struct ServicesTag *svstag = node->data; |
171 |
+ |
|
172 |
+ |
dlinkDelete(&svstag->node, &client_p->svstags); |
173 |
+ |
MyFree(svstag->tag); |
174 |
+ |
MyFree(svstag); |
175 |
+ |
} |
176 |
+ |
} |
177 |
+ |
|
178 |
|
/* check_pings_list() |
179 |
|
* |
180 |
|
* inputs - pointer to list to check |
186 |
|
{ |
187 |
|
char buf[IRCD_BUFSIZE] = ""; |
188 |
|
int ping = 0; /* ping time value from client */ |
189 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
189 |
> |
dlink_node *node = NULL, *node_next = NULL; |
190 |
|
|
191 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, list->head) |
191 |
> |
DLINK_FOREACH_SAFE(node, node_next, list->head) |
192 |
|
{ |
193 |
< |
struct Client *client_p = ptr->data; |
193 |
> |
struct Client *client_p = node->data; |
194 |
|
|
195 |
|
if (IsDead(client_p)) |
196 |
|
continue; /* Ignore it, its been exited already */ |
198 |
|
if (!IsRegistered(client_p)) |
199 |
|
ping = CONNECTTIMEOUT; |
200 |
|
else |
201 |
< |
ping = get_client_ping(&client_p->localClient->confs); |
201 |
> |
ping = get_client_ping(&client_p->connection->confs); |
202 |
|
|
203 |
< |
if (ping < CurrentTime - client_p->localClient->lasttime) |
203 |
> |
if (ping < CurrentTime - client_p->connection->lasttime) |
204 |
|
{ |
205 |
|
if (!IsPingSent(client_p)) |
206 |
|
{ |
210 |
|
* it is still alive. |
211 |
|
*/ |
212 |
|
SetPingSent(client_p); |
213 |
< |
client_p->localClient->lasttime = CurrentTime - ping; |
213 |
> |
client_p->connection->lasttime = CurrentTime - ping; |
214 |
|
sendto_one(client_p, "PING :%s", ID_or_name(&me, client_p)); |
215 |
|
} |
216 |
|
else |
217 |
|
{ |
218 |
< |
if (CurrentTime - client_p->localClient->lasttime >= 2 * ping) |
218 |
> |
if (CurrentTime - client_p->connection->lasttime >= 2 * ping) |
219 |
|
{ |
220 |
|
/* |
221 |
|
* If the client/server hasn't talked to us in 2*ping seconds |
234 |
|
} |
235 |
|
|
236 |
|
snprintf(buf, sizeof(buf), "Ping timeout: %d seconds", |
237 |
< |
(int)(CurrentTime - client_p->localClient->lasttime)); |
237 |
> |
(int)(CurrentTime - client_p->connection->lasttime)); |
238 |
|
exit_client(client_p, buf); |
239 |
|
} |
240 |
|
} |
251 |
|
static void |
252 |
|
check_unknowns_list(void) |
253 |
|
{ |
254 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
254 |
> |
dlink_node *node = NULL, *node_next = NULL; |
255 |
|
|
256 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, unknown_list.head) |
256 |
> |
DLINK_FOREACH_SAFE(node, node_next, unknown_list.head) |
257 |
|
{ |
258 |
< |
struct Client *client_p = ptr->data; |
258 |
> |
struct Client *client_p = node->data; |
259 |
|
|
260 |
|
/* |
261 |
|
* Check UNKNOWN connections - if they have been in this state |
262 |
|
* for > 30s, close them. |
263 |
|
*/ |
264 |
< |
if (IsAuthFinished(client_p) && (CurrentTime - client_p->localClient->firsttime) > 30) |
264 |
> |
if (IsAuthFinished(client_p) && (CurrentTime - client_p->connection->firsttime) > 30) |
265 |
|
exit_client(client_p, "Registration timed out"); |
266 |
|
} |
267 |
|
} |
293 |
|
*/ |
294 |
|
|
295 |
|
static void |
296 |
< |
check_pings(void *notused) |
296 |
> |
check_pings(void *unused) |
297 |
|
{ |
298 |
|
check_pings_list(&local_client_list); |
299 |
|
check_pings_list(&local_server_list); |
311 |
|
check_conf_klines(void) |
312 |
|
{ |
313 |
|
struct MaskItem *conf = NULL; |
314 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
314 |
> |
dlink_node *node = NULL, *node_next = NULL; |
315 |
|
|
316 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, local_client_list.head) |
316 |
> |
DLINK_FOREACH_SAFE(node, node_next, local_client_list.head) |
317 |
|
{ |
318 |
< |
struct Client *client_p = ptr->data; |
318 |
> |
struct Client *client_p = node->data; |
319 |
|
|
320 |
< |
/* If a client is already being exited |
321 |
< |
*/ |
308 |
< |
if (IsDead(client_p) || !IsClient(client_p)) |
320 |
> |
/* If a client is already being exited */ |
321 |
> |
if (IsDead(client_p)) |
322 |
|
continue; |
323 |
|
|
324 |
< |
if ((conf = find_conf_by_address(NULL, &client_p->localClient->ip, CONF_DLINE, |
325 |
< |
client_p->localClient->aftype, NULL, NULL, 1))) |
324 |
> |
if ((conf = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE, |
325 |
> |
client_p->connection->aftype, NULL, NULL, 1))) |
326 |
|
{ |
327 |
|
conf_try_ban(client_p, conf); |
328 |
|
continue; /* and go examine next fd/client_p */ |
330 |
|
|
331 |
|
if (ConfigGeneral.glines) |
332 |
|
{ |
333 |
< |
if ((conf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
334 |
< |
CONF_GLINE, client_p->localClient->aftype, |
333 |
> |
if ((conf = find_conf_by_address(client_p->host, &client_p->connection->ip, |
334 |
> |
CONF_GLINE, client_p->connection->aftype, |
335 |
|
client_p->username, NULL, 1))) |
336 |
|
{ |
337 |
|
conf_try_ban(client_p, conf); |
340 |
|
} |
341 |
|
} |
342 |
|
|
343 |
< |
if ((conf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
344 |
< |
CONF_KLINE, client_p->localClient->aftype, |
343 |
> |
if ((conf = find_conf_by_address(client_p->host, &client_p->connection->ip, |
344 |
> |
CONF_KLINE, client_p->connection->aftype, |
345 |
|
client_p->username, NULL, 1))) |
346 |
|
{ |
347 |
|
conf_try_ban(client_p, conf); |
357 |
|
} |
358 |
|
|
359 |
|
/* also check the unknowns list for new dlines */ |
360 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, unknown_list.head) |
360 |
> |
DLINK_FOREACH_SAFE(node, node_next, unknown_list.head) |
361 |
|
{ |
362 |
< |
struct Client *client_p = ptr->data; |
362 |
> |
struct Client *client_p = node->data; |
363 |
|
|
364 |
< |
if ((conf = find_conf_by_address(NULL, &client_p->localClient->ip, CONF_DLINE, |
365 |
< |
client_p->localClient->aftype, NULL, NULL, 1))) |
364 |
> |
if ((conf = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE, |
365 |
> |
client_p->connection->aftype, NULL, NULL, 1))) |
366 |
|
{ |
367 |
|
conf_try_ban(client_p, conf); |
368 |
|
continue; /* and go examine next fd/client_p */ |
402 |
|
type_string = kline_string; |
403 |
|
break; |
404 |
|
case CONF_DLINE: |
405 |
< |
if (find_conf_by_address(NULL, &client_p->localClient->ip, CONF_EXEMPT, |
406 |
< |
client_p->localClient->aftype, NULL, NULL, 1)) |
405 |
> |
if (find_conf_by_address(NULL, &client_p->connection->ip, CONF_EXEMPT, |
406 |
> |
client_p->connection->aftype, NULL, NULL, 1)) |
407 |
|
return; |
408 |
|
type_string = dline_string; |
409 |
|
break; |
451 |
|
if (IsClient(client_p)) |
452 |
|
{ |
453 |
|
assert(Count.total > 0); |
454 |
+ |
|
455 |
|
--Count.total; |
456 |
|
if (HasUMode(client_p, UMODE_OPER)) |
457 |
|
--Count.oper; |
497 |
|
struct Client * |
498 |
|
find_chasing(struct Client *source_p, const char *name) |
499 |
|
{ |
500 |
< |
struct Client *who = find_person(source_p, name); |
500 |
> |
struct Client *target_p = find_person(source_p, name); |
501 |
|
|
502 |
< |
if (who) |
503 |
< |
return who; |
502 |
> |
if (target_p) |
503 |
> |
return target_p; |
504 |
|
|
505 |
|
if (IsDigit(*name)) |
506 |
|
return NULL; |
507 |
|
|
508 |
< |
if ((who = whowas_get_history(name, |
509 |
< |
(time_t)ConfigGeneral.kill_chase_time_limit)) |
510 |
< |
== NULL) |
508 |
> |
target_p = whowas_get_history(name, (time_t)ConfigGeneral.kill_chase_time_limit); |
509 |
> |
|
510 |
> |
if (!target_p) |
511 |
|
{ |
512 |
|
sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, name); |
513 |
|
return NULL; |
514 |
|
} |
515 |
|
|
516 |
< |
return who; |
516 |
> |
return target_p; |
517 |
|
} |
518 |
|
|
519 |
|
/* |
539 |
|
{ |
540 |
|
static char buf[HOSTLEN * 2 + USERLEN + 5]; |
541 |
|
|
528 |
– |
assert(client_p); |
529 |
– |
|
542 |
|
if (!MyConnect(client_p)) |
543 |
|
return client_p->name; |
544 |
|
|
550 |
|
type = MASK_IP; |
551 |
|
} |
552 |
|
|
541 |
– |
if (ConfigGeneral.hide_spoof_ips) |
542 |
– |
if (IsIPSpoof(client_p) && type == SHOW_IP) |
543 |
– |
type = MASK_IP; |
544 |
– |
|
553 |
|
/* And finally, let's get the host information, ip or name */ |
554 |
|
switch (type) |
555 |
|
{ |
559 |
|
client_p->username, client_p->sockhost); |
560 |
|
break; |
561 |
|
case MASK_IP: |
562 |
< |
if (client_p->localClient->aftype == AF_INET) |
562 |
> |
if (client_p->connection->aftype == AF_INET) |
563 |
|
snprintf(buf, sizeof(buf), "%s[%s@255.255.255.255]", |
564 |
|
client_p->name, client_p->username); |
565 |
|
else |
578 |
|
void |
579 |
|
free_exited_clients(void) |
580 |
|
{ |
581 |
< |
dlink_node *ptr = NULL, *next = NULL; |
581 |
> |
dlink_node *node = NULL, *node_next = NULL; |
582 |
|
|
583 |
< |
DLINK_FOREACH_SAFE(ptr, next, dead_list.head) |
583 |
> |
DLINK_FOREACH_SAFE(node, node_next, dead_list.head) |
584 |
|
{ |
585 |
< |
free_client(ptr->data); |
586 |
< |
dlinkDelete(ptr, &dead_list); |
587 |
< |
free_dlink_node(ptr); |
585 |
> |
free_client(node->data); |
586 |
> |
dlinkDelete(node, &dead_list); |
587 |
> |
free_dlink_node(node); |
588 |
|
} |
589 |
|
} |
590 |
|
|
597 |
|
static void |
598 |
|
exit_one_client(struct Client *source_p, const char *comment) |
599 |
|
{ |
600 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
600 |
> |
dlink_node *node = NULL, *node_next = NULL; |
601 |
|
|
602 |
|
assert(!IsMe(source_p)); |
603 |
|
assert(source_p != &me); |
616 |
|
sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s", |
617 |
|
source_p->name, source_p->username, |
618 |
|
source_p->host, comment); |
619 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->channel.head) |
620 |
< |
remove_user_from_channel(ptr->data); |
619 |
> |
|
620 |
> |
DLINK_FOREACH_SAFE(node, node_next, source_p->channel.head) |
621 |
> |
remove_user_from_channel(node->data); |
622 |
|
|
623 |
|
whowas_add_history(source_p, 0); |
624 |
|
whowas_off_history(source_p); |
628 |
|
if (MyConnect(source_p)) |
629 |
|
{ |
630 |
|
/* Clean up invitefield */ |
631 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->localClient->invited.head) |
632 |
< |
del_invite(ptr->data, source_p); |
631 |
> |
DLINK_FOREACH_SAFE(node, node_next, source_p->connection->invited.head) |
632 |
> |
del_invite(node->data, source_p); |
633 |
|
|
634 |
|
del_all_accepts(source_p); |
635 |
|
} |
639 |
|
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
640 |
|
dlinkDelete(&source_p->node, &global_client_list); |
641 |
|
|
642 |
< |
if ((ptr = dlinkFindDelete(&global_server_list, source_p))) |
643 |
< |
free_dlink_node(ptr); |
642 |
> |
if ((node = dlinkFindDelete(&global_server_list, source_p))) |
643 |
> |
free_dlink_node(node); |
644 |
|
} |
645 |
|
|
646 |
|
/* Remove source_p from the client lists */ |
647 |
|
if (source_p->id[0]) |
648 |
|
hash_del_id(source_p); |
649 |
+ |
|
650 |
|
if (source_p->name[0]) |
651 |
|
hash_del_client(source_p); |
652 |
|
|
672 |
|
static void |
673 |
|
recurse_remove_clients(struct Client *source_p, const char *comment) |
674 |
|
{ |
675 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
675 |
> |
dlink_node *node = NULL, *node_next = NULL; |
676 |
|
|
677 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->client_list.head) |
678 |
< |
exit_one_client(ptr->data, comment); |
677 |
> |
DLINK_FOREACH_SAFE(node, node_next, source_p->serv->client_list.head) |
678 |
> |
exit_one_client(node->data, comment); |
679 |
|
|
680 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->server_list.head) |
680 |
> |
DLINK_FOREACH_SAFE(node, node_next, source_p->serv->server_list.head) |
681 |
|
{ |
682 |
< |
recurse_remove_clients(ptr->data, comment); |
683 |
< |
exit_one_client(ptr->data, comment); |
682 |
> |
recurse_remove_clients(node->data, comment); |
683 |
> |
exit_one_client(node->data, comment); |
684 |
|
} |
685 |
|
} |
686 |
|
|
704 |
|
void |
705 |
|
exit_client(struct Client *source_p, const char *comment) |
706 |
|
{ |
707 |
< |
dlink_node *m = NULL; |
707 |
> |
dlink_node *node = NULL; |
708 |
|
|
709 |
|
assert(!IsMe(source_p)); |
710 |
|
assert(source_p != &me); |
722 |
|
if (HasFlag(source_p, FLAGS_IPHASH)) |
723 |
|
{ |
724 |
|
DelFlag(source_p, FLAGS_IPHASH); |
725 |
< |
ipcache_remove_address(&source_p->localClient->ip); |
725 |
> |
ipcache_remove_address(&source_p->connection->ip); |
726 |
|
} |
727 |
|
|
728 |
< |
delete_auth(&source_p->localClient->auth); |
728 |
> |
delete_auth(&source_p->connection->auth); |
729 |
|
|
730 |
|
/* |
731 |
|
* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
738 |
|
{ |
739 |
|
assert(dlinkFind(&unknown_list, source_p)); |
740 |
|
|
741 |
< |
dlinkDelete(&source_p->localClient->lclient_node, &unknown_list); |
741 |
> |
dlinkDelete(&source_p->connection->lclient_node, &unknown_list); |
742 |
|
} |
743 |
|
else if (IsClient(source_p)) |
744 |
|
{ |
745 |
< |
time_t on_for = CurrentTime - source_p->localClient->firsttime; |
745 |
> |
time_t on_for = CurrentTime - source_p->connection->firsttime; |
746 |
> |
|
747 |
|
assert(Count.local > 0); |
748 |
< |
Count.local--; |
748 |
> |
|
749 |
> |
--Count.local; |
750 |
|
|
751 |
|
if (HasUMode(source_p, UMODE_OPER)) |
752 |
< |
if ((m = dlinkFindDelete(&oper_list, source_p))) |
753 |
< |
free_dlink_node(m); |
752 |
> |
if ((node = dlinkFindDelete(&oper_list, source_p))) |
753 |
> |
free_dlink_node(node); |
754 |
|
|
755 |
|
assert(dlinkFind(&local_client_list, source_p)); |
756 |
< |
dlinkDelete(&source_p->localClient->lclient_node, &local_client_list); |
756 |
> |
dlinkDelete(&source_p->connection->lclient_node, &local_client_list); |
757 |
|
|
758 |
< |
if (source_p->localClient->list_task) |
758 |
> |
if (source_p->connection->list_task) |
759 |
|
free_list_task(source_p); |
760 |
|
|
761 |
|
watch_del_watch_list(source_p); |
762 |
+ |
client_clear_svstags(source_p); |
763 |
+ |
|
764 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
765 |
|
"Client exiting: %s (%s@%s) [%s] [%s]", |
766 |
|
source_p->name, source_p->username, source_p->host, comment, |
767 |
< |
ConfigGeneral.hide_spoof_ips && IsIPSpoof(source_p) ? |
768 |
< |
"255.255.255.255" : source_p->sockhost); |
767 |
> |
source_p->sockhost); |
768 |
> |
|
769 |
|
ilog(LOG_TYPE_USER, "%s (%3u:%02u:%02u): %s!%s@%s %llu/%llu", |
770 |
< |
myctime(source_p->localClient->firsttime), (unsigned int)(on_for / 3600), |
770 |
> |
myctime(source_p->connection->firsttime), (unsigned int)(on_for / 3600), |
771 |
|
(unsigned int)((on_for % 3600)/60), (unsigned int)(on_for % 60), |
772 |
|
source_p->name, source_p->username, source_p->host, |
773 |
< |
source_p->localClient->send.bytes>>10, |
774 |
< |
source_p->localClient->recv.bytes>>10); |
773 |
> |
source_p->connection->send.bytes>>10, |
774 |
> |
source_p->connection->recv.bytes>>10); |
775 |
|
} |
776 |
|
else if (IsServer(source_p)) |
777 |
|
{ |
778 |
|
assert(Count.myserver > 0); |
779 |
+ |
|
780 |
|
--Count.myserver; |
781 |
|
|
782 |
|
assert(dlinkFind(&local_server_list, source_p)); |
783 |
< |
dlinkDelete(&source_p->localClient->lclient_node, &local_server_list); |
783 |
> |
dlinkDelete(&source_p->connection->lclient_node, &local_server_list); |
784 |
|
} |
785 |
|
|
786 |
|
if (!IsDead(source_p)) |
826 |
|
|
827 |
|
/* Send SQUIT for source_p in every direction. source_p is already off of local_server_list here */ |
828 |
|
if (!HasFlag(source_p, FLAGS_SQUIT)) |
829 |
< |
sendto_server(NULL, NOCAPS, NOCAPS, "SQUIT %s :%s", source_p->id, comment); |
829 |
> |
sendto_server(NULL, 0, 0, "SQUIT %s :%s", source_p->id, comment); |
830 |
|
|
831 |
|
/* Now exit the clients internally */ |
832 |
|
recurse_remove_clients(source_p, splitstr); |
833 |
|
|
834 |
|
if (MyConnect(source_p)) |
835 |
|
{ |
836 |
+ |
int connected = CurrentTime - source_p->connection->firsttime; |
837 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
838 |
< |
"%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
839 |
< |
source_p->name, (int)(CurrentTime - source_p->localClient->firsttime), |
840 |
< |
source_p->localClient->send.bytes >> 10, |
841 |
< |
source_p->localClient->recv.bytes >> 10); |
842 |
< |
ilog(LOG_TYPE_IRCD, "%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
843 |
< |
source_p->name, (int)(CurrentTime - source_p->localClient->firsttime), |
844 |
< |
source_p->localClient->send.bytes >> 10, |
845 |
< |
source_p->localClient->recv.bytes >> 10); |
838 |
> |
"%s was connected for %d day%s, %2d:%02d:%02d. %llu/%llu sendK/recvK.", |
839 |
> |
source_p->name, connected/86400, (connected/86400 == 1) ? "" : "s", |
840 |
> |
(connected % 86400) / 3600, (connected % 3600) / 60, connected % 60, |
841 |
> |
source_p->connection->send.bytes >> 10, |
842 |
> |
source_p->connection->recv.bytes >> 10); |
843 |
> |
ilog(LOG_TYPE_IRCD, "%s was connected for %d day%s, %2d:%02d:%02d. %llu/%llu sendK/recvK.", |
844 |
> |
source_p->name, connected/86400, (connected/86400 == 1) ? "" : "s", |
845 |
> |
(connected % 86400) / 3600, (connected % 3600) / 60, connected % 60, |
846 |
> |
source_p->connection->send.bytes >> 10, |
847 |
> |
source_p->connection->recv.bytes >> 10); |
848 |
|
} |
849 |
|
} |
850 |
|
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
851 |
< |
sendto_server(source_p->from, NOCAPS, NOCAPS, ":%s QUIT :%s", |
851 |
> |
sendto_server(source_p->from, 0, 0, ":%s QUIT :%s", |
852 |
|
source_p->id, comment); |
853 |
|
|
854 |
|
/* The client *better* be off all of the lists */ |
867 |
|
void |
868 |
|
dead_link_on_write(struct Client *client_p, int ierrno) |
869 |
|
{ |
870 |
< |
dlink_node *ptr; |
870 |
> |
dlink_node *node; |
871 |
|
|
872 |
|
if (IsDefunct(client_p)) |
873 |
|
return; |
874 |
|
|
875 |
< |
dbuf_clear(&client_p->localClient->buf_recvq); |
876 |
< |
dbuf_clear(&client_p->localClient->buf_sendq); |
875 |
> |
dbuf_clear(&client_p->connection->buf_recvq); |
876 |
> |
dbuf_clear(&client_p->connection->buf_sendq); |
877 |
|
|
878 |
|
assert(dlinkFind(&abort_list, client_p) == NULL); |
879 |
< |
ptr = make_dlink_node(); |
879 |
> |
node = make_dlink_node(); |
880 |
|
/* don't let exit_aborted_clients() finish yet */ |
881 |
< |
dlinkAddTail(client_p, ptr, &abort_list); |
881 |
> |
dlinkAddTail(client_p, node, &abort_list); |
882 |
|
|
883 |
|
if (eac_next == NULL) |
884 |
< |
eac_next = ptr; |
884 |
> |
eac_next = node; |
885 |
|
|
886 |
|
SetDead(client_p); /* You are dead my friend */ |
887 |
|
} |
899 |
|
if (IsDefunct(client_p)) |
900 |
|
return; |
901 |
|
|
902 |
< |
dbuf_clear(&client_p->localClient->buf_recvq); |
903 |
< |
dbuf_clear(&client_p->localClient->buf_sendq); |
902 |
> |
dbuf_clear(&client_p->connection->buf_recvq); |
903 |
> |
dbuf_clear(&client_p->connection->buf_sendq); |
904 |
|
|
905 |
< |
current_error = get_sockerr(client_p->localClient->fd.fd); |
905 |
> |
current_error = get_sockerr(client_p->connection->fd.fd); |
906 |
|
|
907 |
|
if (IsServer(client_p) || IsHandshake(client_p)) |
908 |
|
{ |
909 |
< |
int connected = CurrentTime - client_p->localClient->firsttime; |
909 |
> |
int connected = CurrentTime - client_p->connection->firsttime; |
910 |
|
|
911 |
|
if (error == 0) |
912 |
|
{ |
932 |
|
} |
933 |
|
|
934 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
935 |
< |
"%s had been connected for %d day%s, %2d:%02d:%02d", |
935 |
> |
"%s was connected for %d day%s, %2d:%02d:%02d", |
936 |
|
client_p->name, connected/86400, |
937 |
|
(connected/86400 == 1) ? "" : "s", |
938 |
|
(connected % 86400) / 3600, (connected % 3600) / 60, |
995 |
|
void |
996 |
|
del_accept(struct split_nuh_item *accept_p, struct Client *client_p) |
997 |
|
{ |
998 |
< |
dlinkDelete(&accept_p->node, &client_p->localClient->acceptlist); |
998 |
> |
dlinkDelete(&accept_p->node, &client_p->connection->acceptlist); |
999 |
|
|
1000 |
|
MyFree(accept_p->nickptr); |
1001 |
|
MyFree(accept_p->userptr); |
1008 |
|
const char *host, struct Client *client_p, |
1009 |
|
int (*cmpfunc)(const char *, const char *)) |
1010 |
|
{ |
1011 |
< |
dlink_node *ptr = NULL; |
1011 |
> |
dlink_node *node = NULL; |
1012 |
|
|
1013 |
< |
DLINK_FOREACH(ptr, client_p->localClient->acceptlist.head) |
1013 |
> |
DLINK_FOREACH(node, client_p->connection->acceptlist.head) |
1014 |
|
{ |
1015 |
< |
struct split_nuh_item *accept_p = ptr->data; |
1015 |
> |
struct split_nuh_item *accept_p = node->data; |
1016 |
|
|
1017 |
|
if (!cmpfunc(accept_p->nickptr, nick) && |
1018 |
|
!cmpfunc(accept_p->userptr, user) && |
1034 |
|
accept_message(struct Client *source, |
1035 |
|
struct Client *target) |
1036 |
|
{ |
1037 |
< |
dlink_node *ptr = NULL; |
1037 |
> |
dlink_node *node = NULL; |
1038 |
> |
|
1039 |
> |
if (HasFlag(source, FLAGS_SERVICE) || |
1040 |
> |
(HasUMode(source, UMODE_OPER) && ConfigGeneral.opers_bypass_callerid)) |
1041 |
> |
return 1; |
1042 |
|
|
1043 |
|
if (source == target || find_accept(source->name, source->username, |
1044 |
|
source->host, target, match)) |
1045 |
|
return 1; |
1046 |
|
|
1047 |
< |
if (HasUMode(target, UMODE_SOFTCALLERID)) |
1048 |
< |
DLINK_FOREACH(ptr, target->channel.head) |
1049 |
< |
if (IsMember(source, ((struct Membership *)ptr->data)->chptr)) |
1047 |
> |
if (!HasUMode(target, UMODE_CALLERID) && HasUMode(target, UMODE_SOFTCALLERID)) |
1048 |
> |
DLINK_FOREACH(node, target->channel.head) |
1049 |
> |
if (IsMember(source, ((struct Membership *)node->data)->chptr)) |
1050 |
|
return 1; |
1051 |
|
|
1052 |
|
return 0; |
1061 |
|
void |
1062 |
|
del_all_accepts(struct Client *client_p) |
1063 |
|
{ |
1064 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
1064 |
> |
dlink_node *node = NULL, *node_next = NULL; |
1065 |
|
|
1066 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->acceptlist.head) |
1067 |
< |
del_accept(ptr->data, client_p); |
1066 |
> |
DLINK_FOREACH_SAFE(node, node_next, client_p->connection->acceptlist.head) |
1067 |
> |
del_accept(node->data, client_p); |
1068 |
|
} |
1069 |
|
|
1070 |
|
unsigned int |
1071 |
< |
idle_time_get(const struct Client *source_p, const struct Client *target_p) |
1071 |
> |
client_get_idle_time(const struct Client *source_p, |
1072 |
> |
const struct Client *target_p) |
1073 |
|
{ |
1074 |
|
unsigned int idle = 0; |
1075 |
|
unsigned int min_idle = 0; |
1076 |
|
unsigned int max_idle = 0; |
1077 |
< |
const struct ClassItem *class = get_class_ptr(&target_p->localClient->confs); |
1077 |
> |
const struct ClassItem *const class = get_class_ptr(&target_p->connection->confs); |
1078 |
|
|
1079 |
|
if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p) |
1080 |
< |
return CurrentTime - target_p->localClient->last_privmsg; |
1080 |
> |
return CurrentTime - target_p->connection->last_privmsg; |
1081 |
> |
|
1082 |
|
if (HasUMode(source_p, UMODE_OPER) && |
1083 |
|
!(class->flags & CLASS_FLAGS_HIDE_IDLE_FROM_OPERS)) |
1084 |
< |
return CurrentTime - target_p->localClient->last_privmsg; |
1084 |
> |
return CurrentTime - target_p->connection->last_privmsg; |
1085 |
|
|
1086 |
|
min_idle = class->min_idle; |
1087 |
|
max_idle = class->max_idle; |
1092 |
|
if (class->flags & CLASS_FLAGS_RANDOM_IDLE) |
1093 |
|
idle = genrand_int32(); |
1094 |
|
else |
1095 |
< |
idle = CurrentTime - target_p->localClient->last_privmsg; |
1095 |
> |
idle = CurrentTime - target_p->connection->last_privmsg; |
1096 |
|
|
1097 |
|
if (!max_idle) |
1098 |
|
idle = 0; |
1122 |
|
}; |
1123 |
|
|
1124 |
|
client_pool = mp_pool_new(sizeof(struct Client), MP_CHUNK_SIZE_CLIENT); |
1125 |
< |
lclient_pool = mp_pool_new(sizeof(struct LocalUser), MP_CHUNK_SIZE_LCLIENT); |
1125 |
> |
connection_pool = mp_pool_new(sizeof(struct Connection), MP_CHUNK_SIZE_CONNECTION); |
1126 |
|
event_add(&event_ping, NULL); |
1127 |
|
} |