45 |
|
#include "s_user.h" |
46 |
|
#include "dbuf.h" |
47 |
|
#include "memory.h" |
48 |
+ |
#include "mempool.h" |
49 |
|
#include "hostmask.h" |
49 |
– |
#include "balloc.h" |
50 |
|
#include "listener.h" |
51 |
|
#include "irc_res.h" |
52 |
|
#include "userhost.h" |
53 |
|
#include "watch.h" |
54 |
+ |
#include "rng_mt.h" |
55 |
|
|
56 |
|
dlink_list listing_client_list = { NULL, NULL, 0 }; |
57 |
|
/* Pointer to beginning of Client list */ |
65 |
|
|
66 |
|
static EVH check_pings; |
67 |
|
|
68 |
< |
static BlockHeap *client_heap = NULL; |
69 |
< |
static BlockHeap *lclient_heap = NULL; |
68 |
> |
static mp_pool_t *client_pool = NULL; |
69 |
> |
static mp_pool_t *lclient_pool = NULL; |
70 |
|
|
71 |
|
static dlink_list dead_list = { NULL, NULL, 0}; |
72 |
|
static dlink_list abort_list = { NULL, NULL, 0}; |
75 |
|
|
76 |
|
static void check_pings_list(dlink_list *); |
77 |
|
static void check_unknowns_list(void); |
78 |
< |
static void ban_them(struct Client *, struct ConfItem *); |
78 |
> |
static void ban_them(struct Client *, struct MaskItem *); |
79 |
|
|
80 |
|
|
81 |
< |
/* init_client() |
81 |
> |
/* client_init() |
82 |
|
* |
83 |
|
* inputs - NONE |
84 |
|
* output - NONE |
85 |
|
* side effects - initialize client free memory |
86 |
|
*/ |
87 |
|
void |
88 |
< |
init_client(void) |
88 |
> |
client_init(void) |
89 |
|
{ |
90 |
|
/* start off the check ping event .. -- adrian |
91 |
|
* Every 30 seconds is plenty -- db |
92 |
|
*/ |
93 |
< |
client_heap = BlockHeapCreate("client", sizeof(struct Client), CLIENT_HEAP_SIZE); |
94 |
< |
lclient_heap = BlockHeapCreate("local client", sizeof(struct LocalUser), LCLIENT_HEAP_SIZE); |
93 |
> |
client_pool = mp_pool_new(sizeof(struct Client), MP_CHUNK_SIZE_CLIENT); |
94 |
> |
lclient_pool = mp_pool_new(sizeof(struct LocalUser), MP_CHUNK_SIZE_LCLIENT); |
95 |
|
eventAdd("check_pings", check_pings, NULL, 5); |
96 |
|
} |
97 |
|
|
113 |
|
struct Client * |
114 |
|
make_client(struct Client *from) |
115 |
|
{ |
116 |
< |
struct Client *client_p = BlockHeapAlloc(client_heap); |
116 |
> |
struct Client *client_p = mp_pool_get(client_pool); |
117 |
> |
|
118 |
> |
memset(client_p, 0, sizeof(*client_p)); |
119 |
|
|
120 |
|
if (from == NULL) |
121 |
|
{ |
122 |
|
client_p->from = client_p; /* 'from' of local client is self! */ |
123 |
< |
client_p->localClient = BlockHeapAlloc(lclient_heap); |
123 |
> |
client_p->localClient = mp_pool_get(lclient_pool); |
124 |
> |
|
125 |
> |
memset(client_p->localClient, 0, sizeof(*client_p->localClient)); |
126 |
> |
|
127 |
|
client_p->localClient->since = CurrentTime; |
128 |
|
client_p->localClient->lasttime = CurrentTime; |
129 |
|
client_p->localClient->firsttime = CurrentTime; |
135 |
|
else |
136 |
|
client_p->from = from; /* 'from' of local client is self! */ |
137 |
|
|
138 |
+ |
client_p->idhnext = client_p; |
139 |
|
client_p->hnext = client_p; |
140 |
|
client_p->status = STAT_UNKNOWN; |
141 |
|
strcpy(client_p->username, "unknown"); |
142 |
+ |
strcpy(client_p->svid, "0"); |
143 |
|
|
144 |
|
return client_p; |
145 |
|
} |
157 |
|
assert(client_p != NULL); |
158 |
|
assert(client_p != &me); |
159 |
|
assert(client_p->hnext == client_p); |
160 |
+ |
assert(client_p->idhnext == client_p); |
161 |
|
assert(client_p->channel.head == NULL); |
162 |
|
assert(dlink_list_length(&client_p->channel) == 0); |
163 |
+ |
assert(dlink_list_length(&client_p->whowas) == 0); |
164 |
+ |
assert(!IsServer(client_p) || (IsServer(client_p) && client_p->serv)); |
165 |
|
|
155 |
– |
MyFree(client_p->away); |
166 |
|
MyFree(client_p->serv); |
167 |
|
|
168 |
|
if (MyConnect(client_p)) |
169 |
|
{ |
170 |
|
assert(client_p->localClient->invited.head == NULL); |
171 |
|
assert(dlink_list_length(&client_p->localClient->invited) == 0); |
172 |
+ |
assert(dlink_list_length(&client_p->localClient->watches) == 0); |
173 |
|
assert(IsClosing(client_p) && IsDead(client_p)); |
174 |
|
|
175 |
|
MyFree(client_p->localClient->response); |
189 |
|
dbuf_clear(&client_p->localClient->buf_recvq); |
190 |
|
dbuf_clear(&client_p->localClient->buf_sendq); |
191 |
|
|
192 |
< |
BlockHeapFree(lclient_heap, client_p->localClient); |
192 |
> |
mp_pool_release(client_p->localClient); |
193 |
|
} |
194 |
|
|
195 |
< |
BlockHeapFree(client_heap, client_p); |
195 |
> |
mp_pool_release(client_p); |
196 |
|
} |
197 |
|
|
198 |
|
/* |
239 |
|
check_pings_list(dlink_list *list) |
240 |
|
{ |
241 |
|
char scratch[32]; /* way too generous but... */ |
242 |
< |
struct Client *client_p; /* current local client_p being examined */ |
243 |
< |
int ping, pingwarn; /* ping time value from client */ |
233 |
< |
dlink_node *ptr, *next_ptr; |
242 |
> |
int ping = 0; /* ping time value from client */ |
243 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
244 |
|
|
245 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) |
246 |
|
{ |
247 |
< |
client_p = ptr->data; |
247 |
> |
struct Client *client_p = ptr->data; |
248 |
|
|
249 |
|
/* |
250 |
|
** Note: No need to notify opers here. It's |
256 |
|
continue; |
257 |
|
} |
258 |
|
|
249 |
– |
if (client_p->localClient->reject_delay > 0) |
250 |
– |
{ |
251 |
– |
if (client_p->localClient->reject_delay <= CurrentTime) |
252 |
– |
exit_client(client_p, &me, "Rejected"); |
253 |
– |
continue; |
254 |
– |
} |
255 |
– |
|
259 |
|
if (!IsRegistered(client_p)) |
260 |
< |
ping = CONNECTTIMEOUT, pingwarn = 0; |
260 |
> |
ping = CONNECTTIMEOUT; |
261 |
|
else |
262 |
< |
ping = get_client_ping(client_p, &pingwarn); |
262 |
> |
ping = get_client_ping(&client_p->localClient->confs); |
263 |
|
|
264 |
|
if (ping < CurrentTime - client_p->localClient->lasttime) |
265 |
|
{ |
271 |
|
* it is still alive. |
272 |
|
*/ |
273 |
|
SetPingSent(client_p); |
271 |
– |
ClearPingWarning(client_p); |
274 |
|
client_p->localClient->lasttime = CurrentTime - ping; |
275 |
|
sendto_one(client_p, "PING :%s", ID_or_name(&me, client_p)); |
276 |
|
} |
284 |
|
*/ |
285 |
|
if (IsServer(client_p) || IsHandshake(client_p)) |
286 |
|
{ |
287 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
287 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
288 |
|
"No response from %s, closing link", |
289 |
|
get_client_name(client_p, HIDE_IP)); |
290 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
290 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
291 |
|
"No response from %s, closing link", |
292 |
|
get_client_name(client_p, MASK_IP)); |
293 |
|
ilog(LOG_TYPE_IRCD, "No response from %s, closing link", |
298 |
|
(int)(CurrentTime - client_p->localClient->lasttime)); |
299 |
|
exit_client(client_p, &me, scratch); |
300 |
|
} |
299 |
– |
else if (!IsPingWarning(client_p) && pingwarn > 0 && |
300 |
– |
(IsServer(client_p) || IsHandshake(client_p)) && |
301 |
– |
CurrentTime - client_p->localClient->lasttime >= ping + pingwarn) |
302 |
– |
{ |
303 |
– |
/* |
304 |
– |
* If the server hasn't replied in pingwarn seconds after sending |
305 |
– |
* the PING, notify the opers so that they are aware of the problem. |
306 |
– |
*/ |
307 |
– |
SetPingWarning(client_p); |
308 |
– |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
309 |
– |
"Warning, no response from %s in %d seconds", |
310 |
– |
get_client_name(client_p, HIDE_IP), pingwarn); |
311 |
– |
sendto_realops_flags(UMODE_ALL, L_OPER, |
312 |
– |
"Warning, no response from %s in %d seconds", |
313 |
– |
get_client_name(client_p, MASK_IP), pingwarn); |
314 |
– |
ilog(LOG_TYPE_IRCD, "No response from %s in %d seconds", |
315 |
– |
get_client_name(client_p, HIDE_IP), pingwarn); |
316 |
– |
} |
301 |
|
} |
302 |
|
} |
303 |
|
} |
318 |
|
{ |
319 |
|
struct Client *client_p = ptr->data; |
320 |
|
|
337 |
– |
if (client_p->localClient->reject_delay > 0) |
338 |
– |
{ |
339 |
– |
if (client_p->localClient->reject_delay <= CurrentTime) |
340 |
– |
exit_client(client_p, &me, "Rejected"); |
341 |
– |
continue; |
342 |
– |
} |
343 |
– |
|
321 |
|
/* |
322 |
|
* Check UNKNOWN connections - if they have been in this state |
323 |
|
* for > 30s, close them. |
338 |
|
check_conf_klines(void) |
339 |
|
{ |
340 |
|
struct Client *client_p = NULL; /* current local client_p being examined */ |
341 |
< |
struct AccessItem *aconf = NULL; |
365 |
< |
struct ConfItem *conf = NULL; |
341 |
> |
struct MaskItem *conf = NULL; |
342 |
|
dlink_node *ptr, *next_ptr; |
343 |
|
|
344 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, local_client_list.head) |
350 |
|
if (IsDead(client_p) || !IsClient(client_p)) |
351 |
|
continue; |
352 |
|
|
353 |
< |
/* if there is a returned struct ConfItem then kill it */ |
378 |
< |
if ((aconf = find_dline_conf(&client_p->localClient->ip, |
353 |
> |
if ((conf = find_dline_conf(&client_p->localClient->ip, |
354 |
|
client_p->localClient->aftype)) != NULL) |
355 |
|
{ |
356 |
< |
if (aconf->status & CONF_EXEMPTDLINE) |
356 |
> |
if (conf->type == CONF_EXEMPT) |
357 |
|
continue; |
358 |
|
|
384 |
– |
conf = unmap_conf_item(aconf); |
359 |
|
ban_them(client_p, conf); |
360 |
|
continue; /* and go examine next fd/client_p */ |
361 |
|
} |
362 |
|
|
363 |
< |
if (ConfigFileEntry.glines && (aconf = find_gline(client_p))) |
363 |
> |
if (ConfigFileEntry.glines && (conf = find_gline(client_p))) |
364 |
|
{ |
365 |
|
if (IsExemptKline(client_p) || |
366 |
|
IsExemptGline(client_p)) |
367 |
|
{ |
368 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
368 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
369 |
|
"GLINE over-ruled for %s, client is %sline_exempt", |
370 |
|
get_client_name(client_p, HIDE_IP), IsExemptKline(client_p) ? "k" : "g"); |
371 |
|
continue; |
372 |
|
} |
373 |
|
|
400 |
– |
conf = unmap_conf_item(aconf); |
374 |
|
ban_them(client_p, conf); |
375 |
|
/* and go examine next fd/client_p */ |
376 |
|
continue; |
377 |
|
} |
378 |
|
|
379 |
< |
if ((aconf = find_kill(client_p)) != NULL) |
379 |
> |
if ((conf = find_kill(client_p)) != NULL) |
380 |
|
{ |
408 |
– |
|
409 |
– |
/* if there is a returned struct AccessItem.. then kill it */ |
381 |
|
if (IsExemptKline(client_p)) |
382 |
|
{ |
383 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
383 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
384 |
|
"KLINE over-ruled for %s, client is kline_exempt", |
385 |
|
get_client_name(client_p, HIDE_IP)); |
386 |
|
continue; |
387 |
|
} |
388 |
|
|
418 |
– |
conf = unmap_conf_item(aconf); |
389 |
|
ban_them(client_p, conf); |
390 |
|
continue; |
391 |
|
} |
392 |
|
|
393 |
< |
/* if there is a returned struct MatchItem then kill it */ |
394 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, client_p->info, |
425 |
< |
NULL, NULL, 0)) != NULL || |
426 |
< |
(conf = find_matching_name_conf(RXLINE_TYPE, client_p->info, |
427 |
< |
NULL, NULL, 0)) != NULL) |
393 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, client_p->info, |
394 |
> |
NULL, NULL, 0))) |
395 |
|
{ |
396 |
|
ban_them(client_p, conf); |
397 |
|
continue; |
403 |
|
{ |
404 |
|
client_p = ptr->data; |
405 |
|
|
406 |
< |
if ((aconf = find_dline_conf(&client_p->localClient->ip, |
407 |
< |
client_p->localClient->aftype))) |
406 |
> |
if ((conf = find_dline_conf(&client_p->localClient->ip, |
407 |
> |
client_p->localClient->aftype))) |
408 |
|
{ |
409 |
< |
if (aconf->status & CONF_EXEMPTDLINE) |
409 |
> |
if (conf->type == CONF_EXEMPT) |
410 |
|
continue; |
411 |
|
|
412 |
|
exit_client(client_p, &me, "D-lined"); |
418 |
|
* ban_them |
419 |
|
* |
420 |
|
* inputs - pointer to client to ban |
421 |
< |
* - pointer to ConfItem |
421 |
> |
* - pointer to MaskItem |
422 |
|
* output - NONE |
423 |
|
* side effects - given client_p is banned |
424 |
|
*/ |
425 |
|
static void |
426 |
< |
ban_them(struct Client *client_p, struct ConfItem *conf) |
426 |
> |
ban_them(struct Client *client_p, struct MaskItem *conf) |
427 |
|
{ |
428 |
|
const char *user_reason = NULL; /* What is sent to user */ |
462 |
– |
const char *channel_reason = NULL; /* What is sent to channel */ |
463 |
– |
struct AccessItem *aconf = NULL; |
464 |
– |
struct MatchItem *xconf = NULL; |
429 |
|
const char *type_string = NULL; |
430 |
|
const char dline_string[] = "D-line"; |
431 |
|
const char kline_string[] = "K-line"; |
434 |
|
|
435 |
|
switch (conf->type) |
436 |
|
{ |
437 |
< |
case RKLINE_TYPE: |
474 |
< |
case KLINE_TYPE: |
437 |
> |
case CONF_KLINE: |
438 |
|
type_string = kline_string; |
476 |
– |
aconf = map_to_conf(conf); |
439 |
|
break; |
440 |
< |
case DLINE_TYPE: |
440 |
> |
case CONF_DLINE: |
441 |
|
type_string = dline_string; |
480 |
– |
aconf = map_to_conf(conf); |
442 |
|
break; |
443 |
< |
case GLINE_TYPE: |
443 |
> |
case CONF_GLINE: |
444 |
|
type_string = gline_string; |
484 |
– |
aconf = map_to_conf(conf); |
445 |
|
break; |
446 |
< |
case RXLINE_TYPE: |
487 |
< |
case XLINE_TYPE: |
446 |
> |
case CONF_XLINE: |
447 |
|
type_string = xline_string; |
448 |
< |
xconf = map_to_conf(conf); |
490 |
< |
++xconf->count; |
448 |
> |
++conf->count; |
449 |
|
break; |
450 |
|
default: |
451 |
|
assert(0); |
452 |
|
break; |
453 |
|
} |
454 |
|
|
455 |
< |
if (ConfigFileEntry.kline_with_reason) |
498 |
< |
{ |
499 |
< |
if (aconf != NULL) |
500 |
< |
user_reason = aconf->reason ? aconf->reason : type_string; |
501 |
< |
if (xconf != NULL) |
502 |
< |
user_reason = xconf->reason ? xconf->reason : type_string; |
503 |
< |
} |
504 |
< |
else |
505 |
< |
user_reason = type_string; |
506 |
< |
|
507 |
< |
if (ConfigFileEntry.kline_reason != NULL) |
508 |
< |
channel_reason = ConfigFileEntry.kline_reason; |
509 |
< |
else |
510 |
< |
channel_reason = user_reason; |
455 |
> |
user_reason = conf->reason ? conf->reason : type_string; |
456 |
|
|
457 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s active for %s", |
457 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s active for %s", |
458 |
|
type_string, get_client_name(client_p, HIDE_IP)); |
459 |
|
|
460 |
|
if (IsClient(client_p)) |
461 |
|
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP), |
462 |
|
me.name, client_p->name, user_reason); |
463 |
|
|
464 |
< |
exit_client(client_p, &me, channel_reason); |
464 |
> |
exit_client(client_p, &me, user_reason); |
465 |
|
} |
466 |
|
|
467 |
|
/* update_client_exit_stats() |
483 |
|
--Count.invisi; |
484 |
|
} |
485 |
|
else if (IsServer(client_p)) |
486 |
< |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, "Server %s split from %s", |
486 |
> |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE, |
487 |
> |
"Server %s split from %s", |
488 |
|
client_p->name, client_p->servptr->name); |
489 |
|
|
490 |
|
if (splitchecking && !splitmode) |
497 |
|
* output - return client pointer |
498 |
|
* side effects - find person by (nick)name |
499 |
|
*/ |
554 |
– |
/* XXX - ugly wrapper */ |
500 |
|
struct Client * |
501 |
|
find_person(const struct Client *client_p, const char *name) |
502 |
|
{ |
503 |
< |
struct Client *c2ptr; |
503 |
> |
struct Client *c2ptr = NULL; |
504 |
|
|
505 |
|
if (IsDigit(*name)) |
506 |
|
{ |
507 |
|
if ((c2ptr = hash_find_id(name)) != NULL) |
508 |
|
{ |
509 |
|
/* invisible users shall not be found by UID guessing */ |
510 |
< |
if (HasUMode(c2ptr, UMODE_INVISIBLE) && !IsServer(client_p)) |
511 |
< |
c2ptr = NULL; |
510 |
> |
if (HasUMode(c2ptr, UMODE_INVISIBLE)) |
511 |
> |
if (!IsServer(client_p) && !HasFlag(client_p, FLAGS_SERVICE)) |
512 |
> |
c2ptr = NULL; |
513 |
|
} |
514 |
|
} |
515 |
|
else |
578 |
|
|
579 |
|
assert(client != NULL); |
580 |
|
|
581 |
< |
if (!MyConnect(client) || !irccmp(client->name, client->host)) |
581 |
> |
if (!MyConnect(client)) |
582 |
|
return client->name; |
583 |
|
|
584 |
< |
if (ConfigServerHide.hide_server_ips) |
585 |
< |
if (IsServer(client) || IsConnecting(client) || IsHandshake(client)) |
584 |
> |
if (IsServer(client) || IsConnecting(client) || IsHandshake(client)) |
585 |
> |
{ |
586 |
> |
if (!irccmp(client->name, client->host)) |
587 |
> |
return client->name; |
588 |
> |
else if (ConfigServerHide.hide_server_ips) |
589 |
|
type = MASK_IP; |
590 |
+ |
} |
591 |
|
|
592 |
|
if (ConfigFileEntry.hide_spoof_ips) |
593 |
|
if (type == SHOW_IP && IsIPSpoof(client)) |
655 |
|
* that the client can show the "**signoff" message). |
656 |
|
* (Note: The notice is to the local clients *only*) |
657 |
|
*/ |
658 |
< |
sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s", |
658 |
> |
sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s", |
659 |
|
source_p->name, source_p->username, |
660 |
|
source_p->host, quitmsg); |
661 |
|
DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head) |
725 |
|
{ |
726 |
|
dlink_node *ptr, *next; |
727 |
|
struct Client *target_p; |
778 |
– |
int hidden = match(me.name, source_p->name); /* XXX */ |
728 |
|
|
729 |
|
assert(to != source_p); /* should be already removed from serv_list */ |
730 |
|
|
731 |
|
/* If this server can handle quit storm (QS) removal |
732 |
|
* of dependents, just send the SQUIT |
784 |
– |
* |
785 |
– |
* Always check *all* dependent servers if some of them are |
786 |
– |
* hidden behind fakename. If so, send out the QUITs -adx |
733 |
|
*/ |
734 |
< |
if (hidden || !IsCapable(to, CAP_QS)) |
734 |
> |
if (!IsCapable(to, CAP_QS)) |
735 |
|
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
736 |
|
{ |
737 |
|
target_p = ptr->data; |
742 |
|
recurse_send_quits(original_source_p, ptr->data, from, to, |
743 |
|
comment, splitstr); |
744 |
|
|
745 |
< |
if (!hidden && ((source_p == original_source_p && to != from) || |
746 |
< |
!IsCapable(to, CAP_QS))) |
745 |
> |
if ((source_p == original_source_p && to != from) || |
746 |
> |
!IsCapable(to, CAP_QS)) |
747 |
|
{ |
748 |
|
/* don't use a prefix here - we have to be 100% sure the message |
749 |
|
* will be accepted without Unknown prefix etc.. */ |
826 |
|
if (IsIpHash(source_p)) |
827 |
|
remove_one_ip(&source_p->localClient->ip); |
828 |
|
|
829 |
< |
if (source_p->localClient->auth) |
884 |
< |
{ |
885 |
< |
delete_auth(source_p->localClient->auth); |
886 |
< |
source_p->localClient->auth = NULL; |
887 |
< |
} |
829 |
> |
delete_auth(&source_p->localClient->auth); |
830 |
|
|
831 |
< |
/* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
831 |
> |
/* |
832 |
> |
* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
833 |
|
* STAT_HANDSHAKE or STAT_UNKNOWN |
834 |
|
* all of which are lumped together into unknown_list |
835 |
|
* |
848 |
|
Count.local--; |
849 |
|
|
850 |
|
if (HasUMode(source_p, UMODE_OPER)) |
908 |
– |
{ |
851 |
|
if ((m = dlinkFindDelete(&oper_list, source_p)) != NULL) |
852 |
|
free_dlink_node(m); |
911 |
– |
} |
853 |
|
|
854 |
|
assert(dlinkFind(&local_client_list, source_p)); |
855 |
|
dlinkDelete(&source_p->localClient->lclient_node, &local_client_list); |
858 |
|
free_list_task(source_p->localClient->list_task, source_p); |
859 |
|
|
860 |
|
watch_del_watch_list(source_p); |
861 |
< |
sendto_realops_flags(UMODE_CCONN, L_ALL, "Client exiting: %s (%s@%s) [%s] [%s]", |
861 |
> |
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
862 |
> |
"Client exiting: %s (%s@%s) [%s] [%s]", |
863 |
|
source_p->name, source_p->username, source_p->host, comment, |
864 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
865 |
|
"255.255.255.255" : source_p->sockhost); |
866 |
< |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, "CLIEXIT: %s %s %s %s 0 %s", |
866 |
> |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, SEND_NOTICE, |
867 |
> |
"CLIEXIT: %s %s %s %s 0 %s", |
868 |
|
source_p->name, |
869 |
|
source_p->username, |
870 |
|
source_p->host, |
878 |
|
source_p->localClient->send.bytes>>10, |
879 |
|
source_p->localClient->recv.bytes>>10); |
880 |
|
} |
881 |
< |
|
939 |
< |
/* As soon as a client is known to be a server of some sort |
940 |
< |
* it has to be put on the serv_list, or SJOIN's to this new server |
941 |
< |
* from the connect burst will not be seen. |
942 |
< |
* XXX - TBV. This is not true. The only place where we put a server on |
943 |
< |
* serv_list is in server_estab right now after registration process. |
944 |
< |
* And only after this, a burst is sent to the remote server, i.e. we never |
945 |
< |
* send a burst to STAT_CONNECTING, or STAT_HANDSHAKE. This will need |
946 |
< |
* more investigation later on, but for now, it's not a problem after all. |
947 |
< |
*/ |
948 |
< |
if (IsServer(source_p) || IsConnecting(source_p) || |
949 |
< |
IsHandshake(source_p)) |
881 |
> |
else if (IsServer(source_p)) |
882 |
|
{ |
883 |
< |
if (dlinkFind(&serv_list, source_p)) |
884 |
< |
{ |
953 |
< |
dlinkDelete(&source_p->localClient->lclient_node, &serv_list); |
954 |
< |
unset_chcap_usage_counts(source_p); |
955 |
< |
} |
883 |
> |
assert(Count.myserver > 0); |
884 |
> |
--Count.myserver; |
885 |
|
|
886 |
< |
if (IsServer(source_p)) |
887 |
< |
Count.myserver--; |
886 |
> |
assert(dlinkFind(&serv_list, source_p)); |
887 |
> |
dlinkDelete(&source_p->localClient->lclient_node, &serv_list); |
888 |
> |
unset_chcap_usage_counts(source_p); |
889 |
|
} |
890 |
|
|
891 |
|
if (!IsDead(source_p)) |
914 |
|
*/ |
915 |
|
close_connection(source_p); |
916 |
|
} |
917 |
+ |
else if (IsClient(source_p) && HasFlag(source_p->servptr, FLAGS_EOB)) |
918 |
+ |
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
919 |
+ |
"Client exiting at %s: %s (%s@%s) [%s]", |
920 |
+ |
source_p->servptr->name, source_p->name, |
921 |
+ |
source_p->username, source_p->host, comment); |
922 |
|
|
923 |
|
if (IsServer(source_p)) |
924 |
|
{ |
941 |
|
|
942 |
|
if (source_p->servptr == &me) |
943 |
|
{ |
944 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
944 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
945 |
|
"%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
946 |
|
source_p->name, (int)(CurrentTime - source_p->localClient->firsttime), |
947 |
|
source_p->localClient->send.bytes >> 10, |
954 |
|
} |
955 |
|
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
956 |
|
{ |
957 |
< |
sendto_server(from->from, NULL, CAP_TS6, NOCAPS, |
957 |
> |
sendto_server(from->from, CAP_TS6, NOCAPS, |
958 |
|
":%s QUIT :%s", ID(source_p), comment); |
959 |
< |
sendto_server(from->from, NULL, NOCAPS, CAP_TS6, |
959 |
> |
sendto_server(from->from, NOCAPS, CAP_TS6, |
960 |
|
":%s QUIT :%s", source_p->name, comment); |
961 |
|
} |
962 |
|
|
1020 |
|
if (error == 0) |
1021 |
|
{ |
1022 |
|
/* Admins get the real IP */ |
1023 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1023 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1024 |
|
"Server %s closed the connection", |
1025 |
|
get_client_name(client_p, SHOW_IP)); |
1026 |
|
|
1027 |
|
/* Opers get a masked IP */ |
1028 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
1028 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
1029 |
|
"Server %s closed the connection", |
1030 |
|
get_client_name(client_p, MASK_IP)); |
1031 |
|
|
1040 |
|
get_client_name(client_p, MASK_IP), current_error); |
1041 |
|
} |
1042 |
|
|
1043 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
1043 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1044 |
|
"%s had been connected for %d day%s, %2d:%02d:%02d", |
1045 |
|
client_p->name, connected/86400, |
1046 |
|
(connected/86400 == 1) ? "" : "s", |
1072 |
|
|
1073 |
|
if (target_p == NULL) |
1074 |
|
{ |
1075 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
1075 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1076 |
|
"Warning: null client on abort_list!"); |
1077 |
|
dlinkDelete(ptr, &abort_list); |
1078 |
|
free_dlink_node(ptr); |
1124 |
|
{ |
1125 |
|
struct split_nuh_item *accept_p = ptr->data; |
1126 |
|
|
1127 |
< |
if (cmpfunc(accept_p->nickptr, nick) == do_match && |
1128 |
< |
cmpfunc(accept_p->userptr, user) == do_match && |
1129 |
< |
cmpfunc(accept_p->hostptr, host) == do_match) |
1127 |
> |
if (!cmpfunc(accept_p->nickptr, nick) && |
1128 |
> |
!cmpfunc(accept_p->userptr, user) && |
1129 |
> |
!cmpfunc(accept_p->hostptr, host)) |
1130 |
|
return accept_p; |
1131 |
|
} |
1132 |
|
|
1172 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head) |
1173 |
|
del_accept(ptr->data, client_p); |
1174 |
|
} |
1175 |
+ |
|
1176 |
+ |
unsigned int |
1177 |
+ |
idle_time_get(const struct Client *source_p, const struct Client *target_p) |
1178 |
+ |
{ |
1179 |
+ |
unsigned int idle = 0; |
1180 |
+ |
unsigned int min_idle = 0; |
1181 |
+ |
unsigned int max_idle = 0; |
1182 |
+ |
const struct ClassItem *class = get_class_ptr(&target_p->localClient->confs); |
1183 |
+ |
|
1184 |
+ |
if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p) |
1185 |
+ |
return CurrentTime - target_p->localClient->last_privmsg; |
1186 |
+ |
if (HasUMode(source_p, UMODE_OPER) && |
1187 |
+ |
!(class->flags & CLASS_FLAGS_HIDE_IDLE_FROM_OPERS)) |
1188 |
+ |
return CurrentTime - target_p->localClient->last_privmsg; |
1189 |
+ |
|
1190 |
+ |
min_idle = class->min_idle; |
1191 |
+ |
max_idle = class->max_idle; |
1192 |
+ |
|
1193 |
+ |
if (min_idle == max_idle) |
1194 |
+ |
return min_idle; |
1195 |
+ |
|
1196 |
+ |
if (class->flags & CLASS_FLAGS_RANDOM_IDLE) |
1197 |
+ |
idle = genrand_int32(); |
1198 |
+ |
else |
1199 |
+ |
idle = CurrentTime - target_p->localClient->last_privmsg; |
1200 |
+ |
|
1201 |
+ |
if (max_idle == 0) |
1202 |
+ |
idle = 0; |
1203 |
+ |
else |
1204 |
+ |
idle %= max_idle; |
1205 |
+ |
|
1206 |
+ |
if (idle < min_idle) |
1207 |
+ |
idle = min_idle + (idle % (max_idle - min_idle)); |
1208 |
+ |
|
1209 |
+ |
return idle; |
1210 |
+ |
} |