23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "client.h" |
28 |
|
#include "channel_mode.h" |
29 |
– |
#include "common.h" |
29 |
|
#include "event.h" |
30 |
|
#include "fdlist.h" |
31 |
|
#include "hash.h" |
32 |
|
#include "irc_string.h" |
34 |
– |
#include "sprintf_irc.h" |
33 |
|
#include "ircd.h" |
36 |
– |
#include "list.h" |
34 |
|
#include "s_gline.h" |
35 |
|
#include "numeric.h" |
36 |
|
#include "packet.h" |
37 |
|
#include "s_auth.h" |
38 |
|
#include "s_bsd.h" |
39 |
< |
#include "s_conf.h" |
40 |
< |
#include "s_log.h" |
39 |
> |
#include "conf.h" |
40 |
> |
#include "log.h" |
41 |
|
#include "s_misc.h" |
42 |
|
#include "s_serv.h" |
43 |
|
#include "send.h" |
50 |
|
#include "listener.h" |
51 |
|
#include "irc_res.h" |
52 |
|
#include "userhost.h" |
53 |
+ |
#include "watch.h" |
54 |
|
|
55 |
|
dlink_list listing_client_list = { NULL, NULL, 0 }; |
56 |
|
/* Pointer to beginning of Client list */ |
74 |
|
|
75 |
|
static void check_pings_list(dlink_list *); |
76 |
|
static void check_unknowns_list(void); |
77 |
< |
static void ban_them(struct Client *client_p, struct ConfItem *conf); |
77 |
> |
static void ban_them(struct Client *, struct ConfItem *); |
78 |
|
|
79 |
|
|
80 |
|
/* init_client() |
116 |
|
|
117 |
|
if (from == NULL) |
118 |
|
{ |
119 |
< |
client_p->from = client_p; /* 'from' of local client is self! */ |
120 |
< |
client_p->since = client_p->lasttime = client_p->firsttime = CurrentTime; |
119 |
> |
client_p->from = client_p; /* 'from' of local client is self! */ |
120 |
> |
client_p->localClient = BlockHeapAlloc(lclient_heap); |
121 |
> |
client_p->localClient->since = CurrentTime; |
122 |
> |
client_p->localClient->lasttime = CurrentTime; |
123 |
> |
client_p->localClient->firsttime = CurrentTime; |
124 |
> |
client_p->localClient->registration = REG_INIT; |
125 |
|
|
124 |
– |
client_p->localClient = BlockHeapAlloc(lclient_heap); |
126 |
|
/* as good a place as any... */ |
127 |
< |
dlinkAdd(client_p, make_dlink_node(), &unknown_list); |
127 |
> |
dlinkAdd(client_p, &client_p->localClient->lclient_node, &unknown_list); |
128 |
|
} |
129 |
|
else |
130 |
|
client_p->from = from; /* 'from' of local client is self! */ |
131 |
|
|
132 |
+ |
client_p->idhnext = client_p; |
133 |
|
client_p->hnext = client_p; |
134 |
|
client_p->status = STAT_UNKNOWN; |
135 |
|
strcpy(client_p->username, "unknown"); |
136 |
+ |
strcpy(client_p->svid, "0"); |
137 |
|
|
138 |
|
return client_p; |
139 |
|
} |
151 |
|
assert(client_p != NULL); |
152 |
|
assert(client_p != &me); |
153 |
|
assert(client_p->hnext == client_p); |
154 |
< |
assert(client_p->invited.head == NULL); |
154 |
> |
assert(client_p->idhnext == client_p); |
155 |
|
assert(client_p->channel.head == NULL); |
153 |
– |
assert(dlink_list_length(&client_p->invited) == 0); |
156 |
|
assert(dlink_list_length(&client_p->channel) == 0); |
157 |
+ |
assert(dlink_list_length(&client_p->whowas) == 0); |
158 |
+ |
assert(!IsServer(client_p) || IsServer(client_p) && client_p->serv); |
159 |
|
|
156 |
– |
MyFree(client_p->away); |
160 |
|
MyFree(client_p->serv); |
161 |
|
|
162 |
|
if (MyConnect(client_p)) |
163 |
|
{ |
164 |
+ |
assert(client_p->localClient->invited.head == NULL); |
165 |
+ |
assert(dlink_list_length(&client_p->localClient->invited) == 0); |
166 |
+ |
assert(dlink_list_length(&client_p->localClient->watches) == 0); |
167 |
|
assert(IsClosing(client_p) && IsDead(client_p)); |
168 |
|
|
169 |
|
MyFree(client_p->localClient->response); |
251 |
|
continue; |
252 |
|
} |
253 |
|
|
248 |
– |
if (client_p->localClient->reject_delay > 0) |
249 |
– |
{ |
250 |
– |
if (client_p->localClient->reject_delay <= CurrentTime) |
251 |
– |
exit_client(client_p, &me, "Rejected"); |
252 |
– |
continue; |
253 |
– |
} |
254 |
– |
|
255 |
– |
if (GlobalSetOptions.idletime && IsClient(client_p)) |
256 |
– |
{ |
257 |
– |
if (!IsExemptKline(client_p) && !IsOper(client_p) && |
258 |
– |
!IsIdlelined(client_p) && |
259 |
– |
((CurrentTime - client_p->localClient->last) > GlobalSetOptions.idletime)) |
260 |
– |
{ |
261 |
– |
struct ConfItem *conf; |
262 |
– |
struct AccessItem *aconf; |
263 |
– |
|
264 |
– |
conf = make_conf_item(KLINE_TYPE); |
265 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
266 |
– |
|
267 |
– |
DupString(aconf->host, client_p->host); |
268 |
– |
DupString(aconf->reason, "idle exceeder"); |
269 |
– |
DupString(aconf->user, client_p->username); |
270 |
– |
aconf->hold = CurrentTime + 60; |
271 |
– |
add_temp_line(conf); |
272 |
– |
|
273 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
274 |
– |
"Idle time limit exceeded for %s - temp k-lining", |
275 |
– |
get_client_name(client_p, HIDE_IP)); |
276 |
– |
exit_client(client_p, &me, aconf->reason); |
277 |
– |
continue; |
278 |
– |
} |
279 |
– |
} |
280 |
– |
|
254 |
|
if (!IsRegistered(client_p)) |
255 |
|
ping = CONNECTTIMEOUT, pingwarn = 0; |
256 |
|
else |
257 |
|
ping = get_client_ping(client_p, &pingwarn); |
258 |
|
|
259 |
< |
if (ping < CurrentTime - client_p->lasttime) |
259 |
> |
if (ping < CurrentTime - client_p->localClient->lasttime) |
260 |
|
{ |
261 |
|
if (!IsPingSent(client_p)) |
262 |
|
{ |
267 |
|
*/ |
268 |
|
SetPingSent(client_p); |
269 |
|
ClearPingWarning(client_p); |
270 |
< |
client_p->lasttime = CurrentTime - ping; |
270 |
> |
client_p->localClient->lasttime = CurrentTime - ping; |
271 |
|
sendto_one(client_p, "PING :%s", ID_or_name(&me, client_p)); |
272 |
|
} |
273 |
|
else |
274 |
|
{ |
275 |
< |
if (CurrentTime - client_p->lasttime >= 2 * ping) |
275 |
> |
if (CurrentTime - client_p->localClient->lasttime >= 2 * ping) |
276 |
|
{ |
277 |
|
/* |
278 |
|
* If the client/server hasn't talked to us in 2*ping seconds |
286 |
|
sendto_realops_flags(UMODE_ALL, L_OPER, |
287 |
|
"No response from %s, closing link", |
288 |
|
get_client_name(client_p, MASK_IP)); |
289 |
< |
ilog(L_NOTICE, "No response from %s, closing link", |
289 |
> |
ilog(LOG_TYPE_IRCD, "No response from %s, closing link", |
290 |
|
get_client_name(client_p, HIDE_IP)); |
291 |
|
} |
319 |
– |
ircsprintf(scratch, "Ping timeout: %d seconds", |
320 |
– |
(int)(CurrentTime - client_p->lasttime)); |
292 |
|
|
293 |
+ |
snprintf(scratch, sizeof(scratch), "Ping timeout: %d seconds", |
294 |
+ |
(int)(CurrentTime - client_p->localClient->lasttime)); |
295 |
|
exit_client(client_p, &me, scratch); |
296 |
|
} |
297 |
|
else if (!IsPingWarning(client_p) && pingwarn > 0 && |
298 |
|
(IsServer(client_p) || IsHandshake(client_p)) && |
299 |
< |
CurrentTime - client_p->lasttime >= ping + pingwarn) |
299 |
> |
CurrentTime - client_p->localClient->lasttime >= ping + pingwarn) |
300 |
|
{ |
301 |
|
/* |
302 |
|
* If the server hasn't replied in pingwarn seconds after sending |
309 |
|
sendto_realops_flags(UMODE_ALL, L_OPER, |
310 |
|
"Warning, no response from %s in %d seconds", |
311 |
|
get_client_name(client_p, MASK_IP), pingwarn); |
312 |
< |
ilog(L_NOTICE, "No response from %s in %d seconds", |
312 |
> |
ilog(LOG_TYPE_IRCD, "No response from %s in %d seconds", |
313 |
|
get_client_name(client_p, HIDE_IP), pingwarn); |
314 |
|
} |
315 |
|
} |
332 |
|
{ |
333 |
|
struct Client *client_p = ptr->data; |
334 |
|
|
335 |
< |
if (client_p->localClient->reject_delay > 0) |
336 |
< |
{ |
364 |
< |
if (client_p->localClient->reject_delay <= CurrentTime) |
365 |
< |
exit_client(client_p, &me, "Rejected"); |
366 |
< |
continue; |
367 |
< |
} |
368 |
< |
|
369 |
< |
/* Check UNKNOWN connections - if they have been in this state |
335 |
> |
/* |
336 |
> |
* Check UNKNOWN connections - if they have been in this state |
337 |
|
* for > 30s, close them. |
338 |
|
*/ |
339 |
< |
if (client_p->firsttime ? ((CurrentTime - client_p->firsttime) > 30) : 0) |
340 |
< |
exit_client(client_p, &me, "Connection timed out"); |
339 |
> |
if (IsAuthFinished(client_p) && (CurrentTime - client_p->localClient->firsttime) > 30) |
340 |
> |
exit_client(client_p, &me, "Registration timed out"); |
341 |
|
} |
342 |
|
} |
343 |
|
|
450 |
|
ban_them(struct Client *client_p, struct ConfItem *conf) |
451 |
|
{ |
452 |
|
const char *user_reason = NULL; /* What is sent to user */ |
486 |
– |
const char *channel_reason = NULL; /* What is sent to channel */ |
453 |
|
struct AccessItem *aconf = NULL; |
454 |
|
struct MatchItem *xconf = NULL; |
455 |
|
const char *type_string = NULL; |
484 |
|
break; |
485 |
|
} |
486 |
|
|
487 |
< |
if (ConfigFileEntry.kline_with_reason) |
488 |
< |
{ |
489 |
< |
if (aconf != NULL) |
490 |
< |
user_reason = aconf->reason ? aconf->reason : type_string; |
525 |
< |
if (xconf != NULL) |
526 |
< |
user_reason = xconf->reason ? xconf->reason : type_string; |
527 |
< |
} |
528 |
< |
else |
529 |
< |
user_reason = type_string; |
530 |
< |
|
531 |
< |
if (ConfigFileEntry.kline_reason != NULL) |
532 |
< |
channel_reason = ConfigFileEntry.kline_reason; |
533 |
< |
else |
534 |
< |
channel_reason = user_reason; |
487 |
> |
if (aconf != NULL) |
488 |
> |
user_reason = aconf->reason ? aconf->reason : type_string; |
489 |
> |
if (xconf != NULL) |
490 |
> |
user_reason = xconf->reason ? xconf->reason : type_string; |
491 |
|
|
492 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s active for %s", |
493 |
|
type_string, get_client_name(client_p, HIDE_IP)); |
496 |
|
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP), |
497 |
|
me.name, client_p->name, user_reason); |
498 |
|
|
499 |
< |
exit_client(client_p, &me, channel_reason); |
499 |
> |
exit_client(client_p, &me, user_reason); |
500 |
|
} |
501 |
|
|
502 |
|
/* update_client_exit_stats() |
508 |
|
static void |
509 |
|
update_client_exit_stats(struct Client *client_p) |
510 |
|
{ |
511 |
< |
if (IsServer(client_p)) |
556 |
< |
{ |
557 |
< |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, |
558 |
< |
"Server %s split from %s", |
559 |
< |
client_p->name, client_p->servptr->name); |
560 |
< |
} |
561 |
< |
else if (IsClient(client_p)) |
511 |
> |
if (IsClient(client_p)) |
512 |
|
{ |
513 |
+ |
assert(Count.total > 0); |
514 |
|
--Count.total; |
515 |
< |
if (IsOper(client_p)) |
515 |
> |
if (HasUMode(client_p, UMODE_OPER)) |
516 |
|
--Count.oper; |
517 |
< |
if (IsInvisible(client_p)) |
517 |
> |
if (HasUMode(client_p, UMODE_INVISIBLE)) |
518 |
|
--Count.invisi; |
519 |
|
} |
520 |
+ |
else if (IsServer(client_p)) |
521 |
+ |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, "Server %s split from %s", |
522 |
+ |
client_p->name, client_p->servptr->name); |
523 |
|
|
524 |
|
if (splitchecking && !splitmode) |
525 |
|
check_splitmode(NULL); |
531 |
|
* output - return client pointer |
532 |
|
* side effects - find person by (nick)name |
533 |
|
*/ |
580 |
– |
/* XXX - ugly wrapper */ |
534 |
|
struct Client * |
535 |
|
find_person(const struct Client *client_p, const char *name) |
536 |
|
{ |
541 |
|
if ((c2ptr = hash_find_id(name)) != NULL) |
542 |
|
{ |
543 |
|
/* invisible users shall not be found by UID guessing */ |
544 |
< |
if (IsInvisible(c2ptr) && !IsServer(client_p)) |
544 |
> |
if (HasUMode(c2ptr, UMODE_INVISIBLE) && !IsServer(client_p)) |
545 |
|
c2ptr = NULL; |
546 |
|
} |
547 |
|
} |
548 |
|
else |
549 |
< |
c2ptr = find_client(name); |
549 |
> |
c2ptr = hash_find_client(name); |
550 |
|
|
551 |
|
return ((c2ptr != NULL && IsClient(c2ptr)) ? c2ptr : NULL); |
552 |
|
} |
566 |
|
*chasing = 0; |
567 |
|
|
568 |
|
if (who) |
569 |
< |
return(who); |
569 |
> |
return who; |
570 |
|
|
571 |
|
if (IsDigit(*user)) |
572 |
< |
return(NULL); |
572 |
> |
return NULL; |
573 |
|
|
574 |
|
if ((who = get_history(user, |
575 |
|
(time_t)ConfigFileEntry.kill_chase_time_limit)) |
577 |
|
{ |
578 |
|
sendto_one(source_p, form_str(ERR_NOSUCHNICK), |
579 |
|
me.name, source_p->name, user); |
580 |
< |
return(NULL); |
580 |
> |
return NULL; |
581 |
|
} |
582 |
|
|
583 |
|
if (chasing) |
584 |
|
*chasing = 1; |
585 |
|
|
586 |
< |
return(who); |
586 |
> |
return who; |
587 |
|
} |
588 |
|
|
589 |
|
/* |
605 |
|
* to modify what it points!!! |
606 |
|
*/ |
607 |
|
const char * |
608 |
< |
get_client_name(struct Client *client, int showip) |
608 |
> |
get_client_name(const struct Client *client, enum addr_mask_type type) |
609 |
|
{ |
610 |
|
static char nbuf[HOSTLEN * 2 + USERLEN + 5]; |
611 |
|
|
612 |
|
assert(client != NULL); |
613 |
|
|
614 |
< |
if (irccmp(client->name, client->host) == 0) |
615 |
< |
return(client->name); |
614 |
> |
if (!MyConnect(client)) |
615 |
> |
return client->name; |
616 |
|
|
617 |
< |
if (ConfigServerHide.hide_server_ips) |
618 |
< |
if (IsServer(client) || IsConnecting(client) || IsHandshake(client)) |
619 |
< |
showip = MASK_IP; |
617 |
> |
if (IsServer(client) || IsConnecting(client) || IsHandshake(client)) |
618 |
> |
{ |
619 |
> |
if (!irccmp(client->name, client->host)) |
620 |
> |
return client->name; |
621 |
> |
else if (ConfigServerHide.hide_server_ips) |
622 |
> |
type = MASK_IP; |
623 |
> |
} |
624 |
|
|
625 |
|
if (ConfigFileEntry.hide_spoof_ips) |
626 |
< |
if (showip == SHOW_IP && IsIPSpoof(client)) |
627 |
< |
showip = MASK_IP; |
626 |
> |
if (type == SHOW_IP && IsIPSpoof(client)) |
627 |
> |
type = MASK_IP; |
628 |
|
|
629 |
|
/* And finally, let's get the host information, ip or name */ |
630 |
< |
switch (showip) |
630 |
> |
switch (type) |
631 |
|
{ |
632 |
|
case SHOW_IP: |
633 |
< |
if (MyConnect(client)) |
634 |
< |
{ |
635 |
< |
ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username, |
636 |
< |
client->sockhost); |
680 |
< |
break; |
681 |
< |
} |
633 |
> |
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", |
634 |
> |
client->name, |
635 |
> |
client->username, client->sockhost); |
636 |
> |
break; |
637 |
|
case MASK_IP: |
638 |
< |
ircsprintf(nbuf, "%s[%s@255.255.255.255]", client->name, |
639 |
< |
client->username); |
638 |
> |
if (client->localClient->aftype == AF_INET) |
639 |
> |
snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]", |
640 |
> |
client->name, client->username); |
641 |
> |
else |
642 |
> |
snprintf(nbuf, sizeof(nbuf), "%s[%s@ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]", |
643 |
> |
client->name, client->username); |
644 |
|
break; |
645 |
|
default: |
646 |
< |
ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username, |
647 |
< |
client->host); |
646 |
> |
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", |
647 |
> |
client->name, |
648 |
> |
client->username, client->host); |
649 |
|
} |
650 |
|
|
651 |
< |
return(nbuf); |
651 |
> |
return nbuf; |
652 |
|
} |
653 |
|
|
654 |
|
void |
655 |
|
free_exited_clients(void) |
656 |
|
{ |
657 |
< |
dlink_node *ptr, *next; |
698 |
< |
struct Client *target_p; |
657 |
> |
dlink_node *ptr = NULL, *next = NULL; |
658 |
|
|
659 |
|
DLINK_FOREACH_SAFE(ptr, next, dead_list.head) |
660 |
|
{ |
661 |
< |
target_p = ptr->data; |
703 |
< |
|
704 |
< |
if (ptr->data == NULL) |
705 |
< |
{ |
706 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
707 |
< |
"Warning: null client on dead_list!"); |
708 |
< |
dlinkDelete(ptr, &dead_list); |
709 |
< |
free_dlink_node(ptr); |
710 |
< |
continue; |
711 |
< |
} |
712 |
< |
|
713 |
< |
free_client(target_p); |
661 |
> |
free_client(ptr->data); |
662 |
|
dlinkDelete(ptr, &dead_list); |
663 |
|
free_dlink_node(ptr); |
664 |
|
} |
677 |
|
|
678 |
|
assert(!IsMe(source_p)); |
679 |
|
|
680 |
< |
if (IsServer(source_p)) |
733 |
< |
{ |
734 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->servers); |
735 |
< |
|
736 |
< |
if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL) |
737 |
< |
free_dlink_node(lp); |
738 |
< |
|
739 |
< |
if (!MyConnect(source_p)) |
740 |
< |
{ |
741 |
< |
source_p->from->serv->dep_servers--; |
742 |
< |
assert(source_p->from->serv->dep_servers > 0); |
743 |
< |
} |
744 |
< |
} |
745 |
< |
else if (IsClient(source_p)) |
680 |
> |
if (IsClient(source_p)) |
681 |
|
{ |
682 |
|
if (source_p->servptr->serv != NULL) |
683 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->users); |
683 |
> |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list); |
684 |
|
|
685 |
< |
/* If a person is on a channel, send a QUIT notice |
686 |
< |
** to every client (person) on the same channel (so |
687 |
< |
** that the client can show the "**signoff" message). |
688 |
< |
** (Note: The notice is to the local clients *only*) |
689 |
< |
*/ |
685 |
> |
/* |
686 |
> |
* If a person is on a channel, send a QUIT notice |
687 |
> |
* to every client (person) on the same channel (so |
688 |
> |
* that the client can show the "**signoff" message). |
689 |
> |
* (Note: The notice is to the local clients *only*) |
690 |
> |
*/ |
691 |
|
sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s", |
692 |
|
source_p->name, source_p->username, |
693 |
|
source_p->host, quitmsg); |
694 |
|
DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head) |
695 |
|
remove_user_from_channel(lp->data); |
696 |
|
|
761 |
– |
/* Clean up invitefield */ |
762 |
– |
DLINK_FOREACH_SAFE(lp, next_lp, source_p->invited.head) |
763 |
– |
del_invite(lp->data, source_p); |
764 |
– |
|
765 |
– |
/* Clean up allow lists */ |
766 |
– |
del_all_accepts(source_p); |
697 |
|
add_history(source_p, 0); |
698 |
|
off_history(source_p); |
699 |
|
|
700 |
< |
if (!MyConnect(source_p)) |
700 |
> |
watch_check_hash(source_p, RPL_LOGOFF); |
701 |
> |
|
702 |
> |
if (MyConnect(source_p)) |
703 |
|
{ |
704 |
< |
source_p->from->serv->dep_users--; |
705 |
< |
assert(source_p->from->serv->dep_users >= 0); |
704 |
> |
/* Clean up invitefield */ |
705 |
> |
DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head) |
706 |
> |
del_invite(lp->data, source_p); |
707 |
> |
|
708 |
> |
del_all_accepts(source_p); |
709 |
|
} |
710 |
|
} |
711 |
+ |
else if (IsServer(source_p)) |
712 |
+ |
{ |
713 |
+ |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
714 |
+ |
|
715 |
+ |
if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL) |
716 |
+ |
free_dlink_node(lp); |
717 |
+ |
} |
718 |
|
|
719 |
|
/* Remove source_p from the client lists */ |
720 |
|
if (HasID(source_p)) |
754 |
|
static void |
755 |
|
recurse_send_quits(struct Client *original_source_p, struct Client *source_p, |
756 |
|
struct Client *from, struct Client *to, const char *comment, |
757 |
< |
const char *splitstr, const char *myname) |
757 |
> |
const char *splitstr) |
758 |
|
{ |
759 |
|
dlink_node *ptr, *next; |
760 |
|
struct Client *target_p; |
819 |
– |
int hidden = match(myname, source_p->name); |
761 |
|
|
762 |
|
assert(to != source_p); /* should be already removed from serv_list */ |
763 |
|
|
764 |
|
/* If this server can handle quit storm (QS) removal |
765 |
|
* of dependents, just send the SQUIT |
825 |
– |
* |
826 |
– |
* Always check *all* dependent servers if some of them are |
827 |
– |
* hidden behind fakename. If so, send out the QUITs -adx |
766 |
|
*/ |
767 |
< |
if (hidden || !IsCapable(to, CAP_QS)) |
768 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head) |
767 |
> |
if (!IsCapable(to, CAP_QS)) |
768 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
769 |
|
{ |
770 |
|
target_p = ptr->data; |
771 |
|
sendto_one(to, ":%s QUIT :%s", target_p->name, splitstr); |
772 |
|
} |
773 |
|
|
774 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head) |
774 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head) |
775 |
|
recurse_send_quits(original_source_p, ptr->data, from, to, |
776 |
< |
comment, splitstr, myname); |
776 |
> |
comment, splitstr); |
777 |
|
|
778 |
< |
if (!hidden && ((source_p == original_source_p && to != from) || |
779 |
< |
!IsCapable(to, CAP_QS))) |
778 |
> |
if ((source_p == original_source_p && to != from) || |
779 |
> |
!IsCapable(to, CAP_QS)) |
780 |
|
{ |
781 |
|
/* don't use a prefix here - we have to be 100% sure the message |
782 |
|
* will be accepted without Unknown prefix etc.. */ |
795 |
|
{ |
796 |
|
dlink_node *ptr, *next; |
797 |
|
|
798 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head) |
798 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
799 |
|
exit_one_client(ptr->data, quitmsg); |
800 |
|
|
801 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head) |
801 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head) |
802 |
|
{ |
803 |
|
recurse_remove_clients(ptr->data, quitmsg); |
804 |
|
exit_one_client(ptr->data, quitmsg); |
805 |
|
} |
868 |
– |
|
869 |
– |
assert(source_p->serv->dep_servers == 1); |
870 |
– |
assert(source_p->serv->dep_users == 0); |
806 |
|
} |
807 |
|
|
808 |
|
/* |
814 |
|
remove_dependents(struct Client *source_p, struct Client *from, |
815 |
|
const char *comment, const char *splitstr) |
816 |
|
{ |
817 |
< |
struct Client *to; |
883 |
< |
struct ConfItem *conf; |
884 |
< |
static char myname[HOSTLEN+1]; |
885 |
< |
dlink_node *ptr; |
817 |
> |
dlink_node *ptr = NULL; |
818 |
|
|
819 |
|
DLINK_FOREACH(ptr, serv_list.head) |
820 |
< |
{ |
821 |
< |
to = ptr->data; |
890 |
< |
|
891 |
< |
if ((conf = to->serv->sconf) != NULL) |
892 |
< |
strlcpy(myname, my_name_for_link(conf), sizeof(myname)); |
893 |
< |
else |
894 |
< |
strlcpy(myname, me.name, sizeof(myname)); |
895 |
< |
recurse_send_quits(source_p, source_p, from, to, |
896 |
< |
comment, splitstr, myname); |
897 |
< |
} |
820 |
> |
recurse_send_quits(source_p, source_p, from, ptr->data, |
821 |
> |
comment, splitstr); |
822 |
|
|
823 |
|
recurse_remove_clients(source_p, splitstr); |
824 |
|
} |
828 |
|
* this on any struct Client, regardless of its state. |
829 |
|
* |
830 |
|
* Note, you shouldn't exit remote _users_ without first doing |
831 |
< |
* SetKilled and propagating a kill or similar message. However, |
832 |
< |
* it is perfectly correct to call exit_client to force a _server_ |
831 |
> |
* AddFlag(x, FLAGS_KILLED) and propagating a kill or similar message. |
832 |
> |
* However, it is perfectly correct to call exit_client to force a _server_ |
833 |
|
* quit (either local or remote one). |
834 |
|
* |
835 |
|
* inputs: - a client pointer that is going to be exited |
844 |
|
void |
845 |
|
exit_client(struct Client *source_p, struct Client *from, const char *comment) |
846 |
|
{ |
847 |
< |
dlink_node *m; |
847 |
> |
dlink_node *m = NULL; |
848 |
|
|
849 |
|
if (MyConnect(source_p)) |
850 |
|
{ |
859 |
|
if (IsIpHash(source_p)) |
860 |
|
remove_one_ip(&source_p->localClient->ip); |
861 |
|
|
862 |
< |
delete_auth(source_p); |
862 |
> |
if (source_p->localClient->auth) |
863 |
> |
{ |
864 |
> |
delete_auth(source_p->localClient->auth); |
865 |
> |
source_p->localClient->auth = NULL; |
866 |
> |
} |
867 |
|
|
868 |
|
/* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
869 |
|
* STAT_HANDSHAKE or STAT_UNKNOWN |
873 |
|
*/ |
874 |
|
if (!IsRegistered(source_p)) |
875 |
|
{ |
876 |
< |
if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL) |
877 |
< |
free_dlink_node(m); |
876 |
> |
assert(dlinkFind(&unknown_list, source_p)); |
877 |
> |
|
878 |
> |
dlinkDelete(&source_p->localClient->lclient_node, &unknown_list); |
879 |
|
} |
880 |
|
else if (IsClient(source_p)) |
881 |
|
{ |
882 |
+ |
time_t on_for = CurrentTime - source_p->localClient->firsttime; |
883 |
+ |
assert(Count.local > 0); |
884 |
|
Count.local--; |
885 |
|
|
886 |
< |
if (IsOper(source_p)) |
886 |
> |
if (HasUMode(source_p, UMODE_OPER)) |
887 |
|
{ |
888 |
|
if ((m = dlinkFindDelete(&oper_list, source_p)) != NULL) |
889 |
|
free_dlink_node(m); |
890 |
|
} |
891 |
|
|
892 |
+ |
assert(dlinkFind(&local_client_list, source_p)); |
893 |
|
dlinkDelete(&source_p->localClient->lclient_node, &local_client_list); |
894 |
+ |
|
895 |
|
if (source_p->localClient->list_task != NULL) |
896 |
|
free_list_task(source_p->localClient->list_task, source_p); |
897 |
|
|
898 |
+ |
watch_del_watch_list(source_p); |
899 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, "Client exiting: %s (%s@%s) [%s] [%s]", |
900 |
|
source_p->name, source_p->username, source_p->host, comment, |
901 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
902 |
|
"255.255.255.255" : source_p->sockhost); |
903 |
+ |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, "CLIEXIT: %s %s %s %s 0 %s", |
904 |
+ |
source_p->name, |
905 |
+ |
source_p->username, |
906 |
+ |
source_p->host, |
907 |
+ |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
908 |
+ |
"255.255.255.255" : source_p->sockhost, |
909 |
+ |
comment); |
910 |
+ |
ilog(LOG_TYPE_USER, "%s (%3u:%02u:%02u): %s!%s@%s %llu/%llu", |
911 |
+ |
myctime(source_p->localClient->firsttime), (unsigned int)(on_for / 3600), |
912 |
+ |
(unsigned int)((on_for % 3600)/60), (unsigned int)(on_for % 60), |
913 |
+ |
source_p->name, source_p->username, source_p->host, |
914 |
+ |
source_p->localClient->send.bytes>>10, |
915 |
+ |
source_p->localClient->recv.bytes>>10); |
916 |
|
} |
917 |
|
|
918 |
|
/* As soon as a client is known to be a server of some sort |
919 |
|
* it has to be put on the serv_list, or SJOIN's to this new server |
920 |
|
* from the connect burst will not be seen. |
921 |
+ |
* XXX - TBV. This is not true. The only place where we put a server on |
922 |
+ |
* serv_list is in server_estab right now after registration process. |
923 |
+ |
* And only after this, a burst is sent to the remote server, i.e. we never |
924 |
+ |
* send a burst to STAT_CONNECTING, or STAT_HANDSHAKE. This will need |
925 |
+ |
* more investigation later on, but for now, it's not a problem after all. |
926 |
|
*/ |
927 |
|
if (IsServer(source_p) || IsConnecting(source_p) || |
928 |
|
IsHandshake(source_p)) |
929 |
|
{ |
930 |
< |
if ((m = dlinkFindDelete(&serv_list, source_p)) != NULL) |
930 |
> |
if (dlinkFind(&serv_list, source_p)) |
931 |
|
{ |
932 |
< |
free_dlink_node(m); |
932 |
> |
dlinkDelete(&source_p->localClient->lclient_node, &serv_list); |
933 |
|
unset_chcap_usage_counts(source_p); |
934 |
|
} |
935 |
|
|
936 |
|
if (IsServer(source_p)) |
985 |
– |
{ |
937 |
|
Count.myserver--; |
987 |
– |
if (ServerInfo.hub) |
988 |
– |
remove_lazylink_flags(source_p->localClient->serverMask); |
989 |
– |
else |
990 |
– |
uplink = NULL; |
991 |
– |
} |
938 |
|
} |
939 |
|
|
994 |
– |
log_user_exit(source_p); |
995 |
– |
|
940 |
|
if (!IsDead(source_p)) |
941 |
|
{ |
942 |
|
if (IsServer(source_p)) |
972 |
|
assert(source_p->serv != NULL && source_p->servptr != NULL); |
973 |
|
|
974 |
|
if (ConfigServerHide.hide_servers) |
975 |
< |
/* set netsplit message to "*.net *.split" to still show |
975 |
> |
/* |
976 |
> |
* Set netsplit message to "*.net *.split" to still show |
977 |
|
* that its a split, but hide the servers splitting |
978 |
|
*/ |
979 |
|
strcpy(splitstr, "*.net *.split"); |
987 |
|
{ |
988 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
989 |
|
"%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
990 |
< |
source_p->name, (int)(CurrentTime - source_p->firsttime), |
990 |
> |
source_p->name, (int)(CurrentTime - source_p->localClient->firsttime), |
991 |
|
source_p->localClient->send.bytes >> 10, |
992 |
|
source_p->localClient->recv.bytes >> 10); |
993 |
< |
ilog(L_NOTICE, "%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
994 |
< |
source_p->name, (int)(CurrentTime - source_p->firsttime), |
993 |
> |
ilog(LOG_TYPE_IRCD, "%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
994 |
> |
source_p->name, (int)(CurrentTime - source_p->localClient->firsttime), |
995 |
|
source_p->localClient->send.bytes >> 10, |
996 |
|
source_p->localClient->recv.bytes >> 10); |
997 |
|
} |
998 |
|
} |
999 |
< |
else if (IsClient(source_p) && !IsKilled(source_p)) |
999 |
> |
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
1000 |
|
{ |
1001 |
< |
sendto_server(NULL, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS, |
1001 |
> |
sendto_server(from->from, CAP_TS6, NOCAPS, |
1002 |
|
":%s QUIT :%s", ID(source_p), comment); |
1003 |
< |
sendto_server(NULL, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS, |
1003 |
> |
sendto_server(from->from, NOCAPS, CAP_TS6, |
1004 |
|
":%s QUIT :%s", source_p->name, comment); |
1005 |
|
} |
1006 |
|
|
1059 |
|
|
1060 |
|
if (IsServer(client_p) || IsHandshake(client_p)) |
1061 |
|
{ |
1062 |
< |
int connected = CurrentTime - client_p->firsttime; |
1062 |
> |
int connected = CurrentTime - client_p->localClient->firsttime; |
1063 |
|
|
1064 |
|
if (error == 0) |
1065 |
|
{ |
1073 |
|
"Server %s closed the connection", |
1074 |
|
get_client_name(client_p, MASK_IP)); |
1075 |
|
|
1076 |
< |
ilog(L_NOTICE, "Server %s closed the connection", |
1076 |
> |
ilog(LOG_TYPE_IRCD, "Server %s closed the connection", |
1077 |
|
get_client_name(client_p, SHOW_IP)); |
1078 |
|
} |
1079 |
|
else |
1080 |
|
{ |
1081 |
< |
report_error(L_ADMIN, "Lost connection to %s: %d", |
1081 |
> |
report_error(L_ADMIN, "Lost connection to %s: %s", |
1082 |
|
get_client_name(client_p, SHOW_IP), current_error); |
1083 |
< |
report_error(L_OPER, "Lost connection to %s: %d", |
1083 |
> |
report_error(L_OPER, "Lost connection to %s: %s", |
1084 |
|
get_client_name(client_p, MASK_IP), current_error); |
1085 |
|
} |
1086 |
|
|
1096 |
|
strlcpy(errmsg, "Remote host closed the connection", |
1097 |
|
sizeof(errmsg)); |
1098 |
|
else |
1099 |
< |
ircsprintf(errmsg, "Read error: %s", |
1100 |
< |
strerror(current_error)); |
1099 |
> |
snprintf(errmsg, sizeof(errmsg), "Read error: %s", |
1100 |
> |
strerror(current_error)); |
1101 |
|
|
1102 |
|
exit_client(client_p, &me, errmsg); |
1103 |
|
} |
1137 |
|
|
1138 |
|
/* |
1139 |
|
* accept processing, this adds a form of "caller ID" to ircd |
1140 |
< |
* |
1140 |
> |
* |
1141 |
|
* If a client puts themselves into "caller ID only" mode, |
1142 |
< |
* only clients that match a client pointer they have put on |
1142 |
> |
* only clients that match a client pointer they have put on |
1143 |
|
* the accept list will be allowed to message them. |
1144 |
|
* |
1145 |
< |
* [ source.on_allow_list ] -> [ target1 ] -> [ target2 ] |
1201 |
< |
* |
1202 |
< |
* [target.allow_list] -> [ source1 ] -> [source2 ] |
1203 |
< |
* |
1204 |
< |
* i.e. a target will have a link list of source pointers it will allow |
1205 |
< |
* each source client then has a back pointer pointing back |
1206 |
< |
* to the client that has it on its accept list. |
1207 |
< |
* This allows for exit_one_client to remove these now bogus entries |
1208 |
< |
* from any client having an accept on them. |
1145 |
> |
* Diane Bruce, "Dianora" db@db.net |
1146 |
|
*/ |
1147 |
|
|
1148 |
< |
/* accept_message() |
1149 |
< |
* |
1213 |
< |
* inputs - pointer to source client |
1214 |
< |
* - pointer to target client |
1215 |
< |
* output - 1 if accept this message 0 if not |
1216 |
< |
* side effects - See if source is on target's allow list |
1217 |
< |
*/ |
1218 |
< |
int |
1219 |
< |
accept_message(struct Client *source, struct Client *target) |
1148 |
> |
void |
1149 |
> |
del_accept(struct split_nuh_item *accept_p, struct Client *client_p) |
1150 |
|
{ |
1151 |
< |
dlink_node *ptr; |
1222 |
< |
|
1223 |
< |
DLINK_FOREACH(ptr, target->allow_list.head) |
1224 |
< |
{ |
1225 |
< |
struct Client *target_p = ptr->data; |
1226 |
< |
|
1227 |
< |
if (source == target_p) |
1228 |
< |
return (1); |
1229 |
< |
} |
1230 |
< |
|
1231 |
< |
if (IsSoftCallerId(target)) |
1232 |
< |
{ |
1233 |
< |
DLINK_FOREACH(ptr, target->channel.head) |
1234 |
< |
if (IsMember(source, ptr->data)) |
1235 |
< |
return (1); |
1236 |
< |
} |
1151 |
> |
dlinkDelete(&accept_p->node, &client_p->localClient->acceptlist); |
1152 |
|
|
1153 |
< |
return (0); |
1153 |
> |
MyFree(accept_p->nickptr); |
1154 |
> |
MyFree(accept_p->userptr); |
1155 |
> |
MyFree(accept_p->hostptr); |
1156 |
> |
MyFree(accept_p); |
1157 |
|
} |
1158 |
|
|
1159 |
< |
/* del_from_accept() |
1160 |
< |
* |
1161 |
< |
* inputs - pointer to source client |
1244 |
< |
* - pointer to target client |
1245 |
< |
* output - NONE |
1246 |
< |
* side effects - Delete's source pointer to targets allow list |
1247 |
< |
* |
1248 |
< |
* Walk through the target's accept list, remove if source is found, |
1249 |
< |
* Then walk through the source's on_accept_list remove target if found. |
1250 |
< |
*/ |
1251 |
< |
void |
1252 |
< |
del_from_accept(struct Client *source, struct Client *target) |
1159 |
> |
struct split_nuh_item * |
1160 |
> |
find_accept(const char *nick, const char *user, |
1161 |
> |
const char *host, struct Client *client_p, int do_match) |
1162 |
|
{ |
1163 |
< |
dlink_node *ptr; |
1164 |
< |
dlink_node *ptr2; |
1165 |
< |
dlink_node *next_ptr; |
1257 |
< |
dlink_node *next_ptr2; |
1258 |
< |
struct Client *target_p; |
1163 |
> |
dlink_node *ptr = NULL; |
1164 |
> |
/* XXX We wouldn't need that if match() would return 0 on match */ |
1165 |
> |
int (*cmpfunc)(const char *, const char *) = do_match ? match : irccmp; |
1166 |
|
|
1167 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, target->allow_list.head) |
1167 |
> |
DLINK_FOREACH(ptr, client_p->localClient->acceptlist.head) |
1168 |
|
{ |
1169 |
< |
target_p = ptr->data; |
1169 |
> |
struct split_nuh_item *accept_p = ptr->data; |
1170 |
|
|
1171 |
< |
if (source == target_p) |
1172 |
< |
{ |
1173 |
< |
dlinkDelete(ptr, &target->allow_list); |
1174 |
< |
free_dlink_node(ptr); |
1268 |
< |
|
1269 |
< |
DLINK_FOREACH_SAFE(ptr2, next_ptr2, source->on_allow_list.head) |
1270 |
< |
{ |
1271 |
< |
target_p = ptr2->data; |
1272 |
< |
|
1273 |
< |
if (target == target_p) |
1274 |
< |
{ |
1275 |
< |
dlinkDelete(ptr2, &source->on_allow_list); |
1276 |
< |
free_dlink_node(ptr2); |
1277 |
< |
} |
1278 |
< |
} |
1279 |
< |
} |
1171 |
> |
if (cmpfunc(accept_p->nickptr, nick) == do_match && |
1172 |
> |
cmpfunc(accept_p->userptr, user) == do_match && |
1173 |
> |
cmpfunc(accept_p->hostptr, host) == do_match) |
1174 |
> |
return accept_p; |
1175 |
|
} |
1281 |
– |
} |
1176 |
|
|
1177 |
< |
/* del_all_accepts() |
1284 |
< |
* |
1285 |
< |
* inputs - pointer to exiting client |
1286 |
< |
* output - NONE |
1287 |
< |
* side effects - Walk through given clients allow_list and on_allow_list |
1288 |
< |
* remove all references to this client |
1289 |
< |
*/ |
1290 |
< |
void |
1291 |
< |
del_all_accepts(struct Client *client_p) |
1292 |
< |
{ |
1293 |
< |
dlink_node *ptr, *next_ptr; |
1294 |
< |
|
1295 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->allow_list.head) |
1296 |
< |
del_from_accept(ptr->data, client_p); |
1297 |
< |
|
1298 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) |
1299 |
< |
del_from_accept(client_p, ptr->data); |
1177 |
> |
return NULL; |
1178 |
|
} |
1179 |
|
|
1180 |
< |
/* del_all_their_accepts() |
1303 |
< |
* |
1304 |
< |
* inputs - pointer to exiting client |
1305 |
< |
* output - NONE |
1306 |
< |
* side effects - Walk through given clients on_allow_list |
1307 |
< |
* remove all references to this client, |
1308 |
< |
* allow this client to keep their own allow_list |
1309 |
< |
*/ |
1310 |
< |
void |
1311 |
< |
del_all_their_accepts(struct Client *client_p) |
1312 |
< |
{ |
1313 |
< |
dlink_node *ptr, *next_ptr; |
1314 |
< |
|
1315 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) |
1316 |
< |
del_from_accept(client_p, ptr->data); |
1317 |
< |
} |
1318 |
< |
|
1319 |
< |
/* set_initial_nick() |
1320 |
< |
* |
1321 |
< |
* inputs |
1322 |
< |
* output |
1323 |
< |
* side effects - |
1180 |
> |
/* accept_message() |
1181 |
|
* |
1182 |
< |
* This function is only called to set up an initially registering |
1183 |
< |
* client. |
1182 |
> |
* inputs - pointer to source client |
1183 |
> |
* - pointer to target client |
1184 |
> |
* output - 1 if accept this message 0 if not |
1185 |
> |
* side effects - See if source is on target's allow list |
1186 |
|
*/ |
1187 |
< |
void |
1188 |
< |
set_initial_nick(struct Client *client_p, struct Client *source_p, |
1189 |
< |
const char *nick) |
1187 |
> |
int |
1188 |
> |
accept_message(struct Client *source, |
1189 |
> |
struct Client *target) |
1190 |
|
{ |
1191 |
< |
char buf[USERLEN + 1]; |
1191 |
> |
dlink_node *ptr = NULL; |
1192 |
|
|
1193 |
< |
/* Client setting NICK the first time */ |
1194 |
< |
|
1195 |
< |
/* This had to be copied here to avoid problems.. */ |
1337 |
< |
source_p->tsinfo = CurrentTime; |
1338 |
< |
|
1339 |
< |
if (source_p->name[0]) |
1340 |
< |
hash_del_client(source_p); |
1341 |
< |
|
1342 |
< |
strlcpy(source_p->name, nick, sizeof(source_p->name)); |
1343 |
< |
hash_add_client(source_p); |
1193 |
> |
if (source == target || find_accept(source->name, source->username, |
1194 |
> |
source->host, target, 1)) |
1195 |
> |
return 1; |
1196 |
|
|
1197 |
< |
/* fd_desc is long enough */ |
1198 |
< |
fd_note(&client_p->localClient->fd, "Nick: %s", nick); |
1199 |
< |
|
1200 |
< |
/* They have the nick they want now.. */ |
1349 |
< |
client_p->llname[0] = '\0'; |
1350 |
< |
|
1351 |
< |
if (source_p->flags & FLAGS_GOTUSER) |
1352 |
< |
{ |
1353 |
< |
strlcpy(buf, source_p->username, sizeof(buf)); |
1197 |
> |
if (HasUMode(target, UMODE_SOFTCALLERID)) |
1198 |
> |
DLINK_FOREACH(ptr, target->channel.head) |
1199 |
> |
if (IsMember(source, ((struct Membership *)ptr->data)->chptr)) |
1200 |
> |
return 1; |
1201 |
|
|
1202 |
< |
/* |
1356 |
< |
* USER already received, now we have NICK. |
1357 |
< |
* *NOTE* For servers "NICK" *must* precede the |
1358 |
< |
* user message (giving USER before NICK is possible |
1359 |
< |
* only for local client connection!). register_user |
1360 |
< |
* may reject the client and call exit_client for it |
1361 |
< |
* --must test this and exit m_nick too!!! |
1362 |
< |
*/ |
1363 |
< |
register_local_user(client_p, source_p, nick, buf); |
1364 |
< |
} |
1202 |
> |
return 0; |
1203 |
|
} |
1204 |
|
|
1205 |
< |
/* change_local_nick() |
1205 |
> |
/* del_all_accepts() |
1206 |
|
* |
1207 |
< |
* inputs - pointer to server |
1208 |
< |
* - pointer to client |
1209 |
< |
* - nick |
1372 |
< |
* output - |
1373 |
< |
* side effects - changes nick of a LOCAL user |
1207 |
> |
* inputs - pointer to exiting client |
1208 |
> |
* output - NONE |
1209 |
> |
* side effects - Walk through given clients acceptlist and remove all entries |
1210 |
|
*/ |
1211 |
|
void |
1212 |
< |
change_local_nick(struct Client *client_p, struct Client *source_p, const char *nick) |
1212 |
> |
del_all_accepts(struct Client *client_p) |
1213 |
|
{ |
1214 |
< |
/* |
1379 |
< |
** Client just changing his/her nick. If he/she is |
1380 |
< |
** on a channel, send note of change to all clients |
1381 |
< |
** on that channel. Propagate notice to other servers. |
1382 |
< |
*/ |
1383 |
< |
if ((source_p->localClient->last_nick_change + |
1384 |
< |
ConfigFileEntry.max_nick_time) < CurrentTime) |
1385 |
< |
source_p->localClient->number_of_nick_changes = 0; |
1386 |
< |
source_p->localClient->last_nick_change = CurrentTime; |
1387 |
< |
source_p->localClient->number_of_nick_changes++; |
1388 |
< |
|
1389 |
< |
if ((ConfigFileEntry.anti_nick_flood && |
1390 |
< |
(source_p->localClient->number_of_nick_changes |
1391 |
< |
<= ConfigFileEntry.max_nick_changes)) || |
1392 |
< |
!ConfigFileEntry.anti_nick_flood || |
1393 |
< |
(IsOper(source_p) && ConfigFileEntry.no_oper_flood)) |
1394 |
< |
{ |
1395 |
< |
if (irccmp(source_p->name, nick)) |
1396 |
< |
source_p->tsinfo = CurrentTime; |
1397 |
< |
|
1398 |
< |
/* XXX - the format of this notice should eventually be changed |
1399 |
< |
* to either %s[%s@%s], or even better would be get_client_name() -bill |
1400 |
< |
*/ |
1401 |
< |
sendto_realops_flags(UMODE_NCHANGE, L_ALL, "Nick change: From %s to %s [%s@%s]", |
1402 |
< |
source_p->name, nick, source_p->username, source_p->host); |
1403 |
< |
sendto_common_channels_local(source_p, 1, ":%s!%s@%s NICK :%s", |
1404 |
< |
source_p->name, source_p->username, |
1405 |
< |
source_p->host, nick); |
1406 |
< |
|
1407 |
< |
add_history(source_p, 1); |
1408 |
< |
|
1409 |
< |
/* Only hubs care about lazy link nicks not being sent on yet |
1410 |
< |
* lazylink leafs/leafs always send their nicks up to hub, |
1411 |
< |
* hence must always propagate nick changes. |
1412 |
< |
* hubs might not propagate a nick change, if the leaf |
1413 |
< |
* does not know about that client yet. |
1414 |
< |
*/ |
1415 |
< |
sendto_server(client_p, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS, |
1416 |
< |
":%s NICK %s :%lu", |
1417 |
< |
ID(source_p), nick, (unsigned long)source_p->tsinfo); |
1418 |
< |
sendto_server(client_p, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS, |
1419 |
< |
":%s NICK %s :%lu", |
1420 |
< |
source_p->name, nick, (unsigned long)source_p->tsinfo); |
1421 |
< |
} |
1422 |
< |
else |
1423 |
< |
{ |
1424 |
< |
sendto_one(source_p, form_str(ERR_NICKTOOFAST), |
1425 |
< |
me.name, source_p->name, source_p->name, |
1426 |
< |
nick, ConfigFileEntry.max_nick_time); |
1427 |
< |
return; |
1428 |
< |
} |
1429 |
< |
|
1430 |
< |
/* Finally, add to hash */ |
1431 |
< |
if (source_p->name[0]) |
1432 |
< |
hash_del_client(source_p); |
1433 |
< |
|
1434 |
< |
strcpy(source_p->name, nick); |
1435 |
< |
hash_add_client(source_p); |
1436 |
< |
|
1437 |
< |
/* Make sure everyone that has this client on its accept list |
1438 |
< |
* loses that reference. |
1439 |
< |
*/ |
1440 |
< |
del_all_their_accepts(source_p); |
1214 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
1215 |
|
|
1216 |
< |
/* fd_desc is long enough */ |
1217 |
< |
fd_note(&client_p->localClient->fd, "Nick: %s", nick); |
1216 |
> |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head) |
1217 |
> |
del_accept(ptr->data, client_p); |
1218 |
|
} |