119 |
|
|
120 |
|
memset(client_p, 0, sizeof(*client_p)); |
121 |
|
|
122 |
< |
if (from == NULL) |
122 |
> |
if (!from) |
123 |
|
{ |
124 |
|
client_p->from = client_p; /* 'from' of local client is self! */ |
125 |
|
client_p->localClient = mp_pool_get(lclient_pool); |
156 |
|
static void |
157 |
|
free_client(struct Client *client_p) |
158 |
|
{ |
159 |
< |
assert(client_p != NULL); |
159 |
> |
assert(client_p); |
160 |
|
assert(client_p != &me); |
161 |
|
assert(client_p->hnext == client_p); |
162 |
|
assert(client_p->idhnext == client_p); |
315 |
|
static void |
316 |
|
check_unknowns_list(void) |
317 |
|
{ |
318 |
< |
dlink_node *ptr, *next_ptr; |
318 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
319 |
|
|
320 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, unknown_list.head) |
320 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, unknown_list.head) |
321 |
|
{ |
322 |
|
struct Client *client_p = ptr->data; |
323 |
|
|
354 |
|
continue; |
355 |
|
|
356 |
|
if ((conf = find_dline_conf(&client_p->localClient->ip, |
357 |
< |
client_p->localClient->aftype)) != NULL) |
357 |
> |
client_p->localClient->aftype))) |
358 |
|
{ |
359 |
|
if (conf->type == CONF_EXEMPT) |
360 |
|
continue; |
513 |
|
|
514 |
|
if (IsDigit(*name)) |
515 |
|
{ |
516 |
< |
if (IsServer(source_p->from) || HasFlag(source_p->from, FLAGS_SERVICE)) |
516 |
> |
if (IsServer(source_p->from)) |
517 |
|
target_p = hash_find_id(name); |
518 |
|
} |
519 |
|
else |
568 |
|
* to modify what it points!!! |
569 |
|
*/ |
570 |
|
const char * |
571 |
< |
get_client_name(const struct Client *client, enum addr_mask_type type) |
571 |
> |
get_client_name(const struct Client *client_p, enum addr_mask_type type) |
572 |
|
{ |
573 |
|
static char nbuf[HOSTLEN * 2 + USERLEN + 5]; |
574 |
|
|
575 |
< |
assert(client != NULL); |
575 |
> |
assert(client_p); |
576 |
|
|
577 |
< |
if (!MyConnect(client)) |
578 |
< |
return client->name; |
577 |
> |
if (!MyConnect(client_p)) |
578 |
> |
return client_p->name; |
579 |
|
|
580 |
< |
if (IsServer(client) || IsConnecting(client) || IsHandshake(client)) |
580 |
> |
if (IsServer(client_p) || IsConnecting(client_p) || IsHandshake(client_p)) |
581 |
|
{ |
582 |
< |
if (!irccmp(client->name, client->host)) |
583 |
< |
return client->name; |
582 |
> |
if (!irccmp(client_p->name, client_p->host)) |
583 |
> |
return client_p->name; |
584 |
|
else if (ConfigServerHide.hide_server_ips) |
585 |
|
type = MASK_IP; |
586 |
|
} |
587 |
|
|
588 |
|
if (ConfigFileEntry.hide_spoof_ips) |
589 |
< |
if (type == SHOW_IP && IsIPSpoof(client)) |
589 |
> |
if (type == SHOW_IP && IsIPSpoof(client_p)) |
590 |
|
type = MASK_IP; |
591 |
|
|
592 |
|
/* And finally, let's get the host information, ip or name */ |
594 |
|
{ |
595 |
|
case SHOW_IP: |
596 |
|
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", |
597 |
< |
client->name, |
598 |
< |
client->username, client->sockhost); |
597 |
> |
client_p->name, |
598 |
> |
client_p->username, client_p->sockhost); |
599 |
|
break; |
600 |
|
case MASK_IP: |
601 |
< |
if (client->localClient->aftype == AF_INET) |
601 |
> |
if (client_p->localClient->aftype == AF_INET) |
602 |
|
snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]", |
603 |
< |
client->name, client->username); |
603 |
> |
client_p->name, client_p->username); |
604 |
|
else |
605 |
|
snprintf(nbuf, sizeof(nbuf), "%s[%s@ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]", |
606 |
< |
client->name, client->username); |
606 |
> |
client_p->name, client_p->username); |
607 |
|
break; |
608 |
|
default: |
609 |
|
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", |
610 |
< |
client->name, |
611 |
< |
client->username, client->host); |
610 |
> |
client_p->name, |
611 |
> |
client_p->username, client_p->host); |
612 |
|
} |
613 |
|
|
614 |
|
return nbuf; |
636 |
|
static void |
637 |
|
exit_one_client(struct Client *source_p, const char *quitmsg) |
638 |
|
{ |
639 |
< |
dlink_node *lp = NULL, *next_lp = NULL; |
639 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
640 |
|
|
641 |
|
assert(!IsMe(source_p)); |
642 |
|
|
653 |
|
sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s", |
654 |
|
source_p->name, source_p->username, |
655 |
|
source_p->host, quitmsg); |
656 |
< |
DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head) |
657 |
< |
remove_user_from_channel(lp->data); |
656 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->channel.head) |
657 |
> |
remove_user_from_channel(ptr->data); |
658 |
|
|
659 |
|
whowas_add_history(source_p, 0); |
660 |
|
whowas_off_history(source_p); |
664 |
|
if (MyConnect(source_p)) |
665 |
|
{ |
666 |
|
/* Clean up invitefield */ |
667 |
< |
DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head) |
668 |
< |
del_invite(lp->data, source_p); |
667 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->localClient->invited.head) |
668 |
> |
del_invite(ptr->data, source_p); |
669 |
|
|
670 |
|
del_all_accepts(source_p); |
671 |
|
} |
674 |
|
{ |
675 |
|
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
676 |
|
|
677 |
< |
if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL) |
678 |
< |
free_dlink_node(lp); |
677 |
> |
if ((ptr = dlinkFindDelete(&global_serv_list, source_p))) |
678 |
> |
free_dlink_node(ptr); |
679 |
|
} |
680 |
|
|
681 |
|
/* Remove source_p from the client lists */ |
691 |
|
* NOTE: source_p->node.next cannot be NULL if the client is added |
692 |
|
* to global_client_list (there is always &me at its end) |
693 |
|
*/ |
694 |
< |
if (source_p->node.next != NULL) /* XXX: not needed? */ |
694 |
> |
if (source_p->node.next) /* XXX: not needed? */ |
695 |
|
dlinkDelete(&source_p->node, &global_client_list); |
696 |
|
|
697 |
|
update_client_exit_stats(source_p); |
713 |
|
static void |
714 |
|
recurse_remove_clients(struct Client *source_p, const char *quitmsg) |
715 |
|
{ |
716 |
< |
dlink_node *ptr, *next; |
716 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
717 |
|
|
718 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
718 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->client_list.head) |
719 |
|
exit_one_client(ptr->data, quitmsg); |
720 |
|
|
721 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head) |
721 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->server_list.head) |
722 |
|
{ |
723 |
|
recurse_remove_clients(ptr->data, quitmsg); |
724 |
|
exit_one_client(ptr->data, quitmsg); |
746 |
|
exit_client(struct Client *source_p, const char *comment) |
747 |
|
{ |
748 |
|
dlink_node *m = NULL; |
749 |
– |
/* Store the direction to source_p, close_connection sets it to NULL */ |
750 |
– |
struct Client *client_p = source_p->from; |
749 |
|
|
750 |
|
if (MyConnect(source_p)) |
751 |
|
{ |
782 |
|
Count.local--; |
783 |
|
|
784 |
|
if (HasUMode(source_p, UMODE_OPER)) |
785 |
< |
if ((m = dlinkFindDelete(&oper_list, source_p)) != NULL) |
785 |
> |
if ((m = dlinkFindDelete(&oper_list, source_p))) |
786 |
|
free_dlink_node(m); |
787 |
|
|
788 |
|
assert(dlinkFind(&local_client_list, source_p)); |
789 |
|
dlinkDelete(&source_p->localClient->lclient_node, &local_client_list); |
790 |
|
|
791 |
< |
if (source_p->localClient->list_task != NULL) |
791 |
> |
if (source_p->localClient->list_task) |
792 |
|
free_list_task(source_p->localClient->list_task, source_p); |
793 |
|
|
794 |
|
watch_del_watch_list(source_p); |
853 |
|
char splitstr[HOSTLEN + HOSTLEN + 2] = ""; |
854 |
|
|
855 |
|
/* This shouldn't ever happen */ |
856 |
< |
assert(source_p->serv != NULL && source_p->servptr != NULL); |
856 |
> |
assert(source_p->serv && source_p->servptr); |
857 |
|
|
858 |
|
if (ConfigServerHide.hide_servers) |
859 |
|
/* |
872 |
|
/* Now exit the clients internally */ |
873 |
|
recurse_remove_clients(source_p, splitstr); |
874 |
|
|
875 |
< |
if (source_p->servptr == &me) |
875 |
> |
if (MyConnect(source_p)) |
876 |
|
{ |
877 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
878 |
|
"%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
886 |
|
} |
887 |
|
} |
888 |
|
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
889 |
< |
sendto_server(client_p, NOCAPS, NOCAPS, ":%s QUIT :%s", |
889 |
> |
sendto_server(source_p->from, NOCAPS, NOCAPS, ":%s QUIT :%s", |
890 |
|
source_p->id, comment); |
891 |
|
|
892 |
|
/* The client *better* be off all of the lists */ |
1095 |
|
void |
1096 |
|
del_all_accepts(struct Client *client_p) |
1097 |
|
{ |
1098 |
< |
dlink_node *ptr = NULL, *next_ptr = NULL; |
1098 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
1099 |
|
|
1100 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head) |
1100 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->acceptlist.head) |
1101 |
|
del_accept(ptr->data, client_p); |
1102 |
|
} |
1103 |
|
|
1126 |
|
else |
1127 |
|
idle = CurrentTime - target_p->localClient->last_privmsg; |
1128 |
|
|
1129 |
< |
if (max_idle == 0) |
1129 |
> |
if (!max_idle) |
1130 |
|
idle = 0; |
1131 |
|
else |
1132 |
|
idle %= max_idle; |