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" |
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" |
45 |
|
#include "s_user.h" |
46 |
|
#include "dbuf.h" |
47 |
|
#include "memory.h" |
48 |
+ |
#include "mempool.h" |
49 |
|
#include "hostmask.h" |
50 |
– |
#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() |
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 |
|
|
156 |
– |
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 */ |
234 |
< |
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 |
|
|
250 |
– |
if (client_p->localClient->reject_delay > 0) |
251 |
– |
{ |
252 |
– |
if (client_p->localClient->reject_delay <= CurrentTime) |
253 |
– |
exit_client(client_p, &me, "Rejected"); |
254 |
– |
continue; |
255 |
– |
} |
256 |
– |
|
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); |
272 |
– |
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(L_NOTICE, "No response from %s, closing link", |
293 |
> |
ilog(LOG_TYPE_IRCD, "No response from %s, closing link", |
294 |
|
get_client_name(client_p, HIDE_IP)); |
295 |
|
} |
296 |
|
|
298 |
|
(int)(CurrentTime - client_p->localClient->lasttime)); |
299 |
|
exit_client(client_p, &me, scratch); |
300 |
|
} |
300 |
– |
else if (!IsPingWarning(client_p) && pingwarn > 0 && |
301 |
– |
(IsServer(client_p) || IsHandshake(client_p)) && |
302 |
– |
CurrentTime - client_p->localClient->lasttime >= ping + pingwarn) |
303 |
– |
{ |
304 |
– |
/* |
305 |
– |
* If the server hasn't replied in pingwarn seconds after sending |
306 |
– |
* the PING, notify the opers so that they are aware of the problem. |
307 |
– |
*/ |
308 |
– |
SetPingWarning(client_p); |
309 |
– |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
310 |
– |
"Warning, no response from %s in %d seconds", |
311 |
– |
get_client_name(client_p, HIDE_IP), pingwarn); |
312 |
– |
sendto_realops_flags(UMODE_ALL, L_OPER, |
313 |
– |
"Warning, no response from %s in %d seconds", |
314 |
– |
get_client_name(client_p, MASK_IP), pingwarn); |
315 |
– |
ilog(L_NOTICE, "No response from %s in %d seconds", |
316 |
– |
get_client_name(client_p, HIDE_IP), pingwarn); |
317 |
– |
} |
301 |
|
} |
302 |
|
} |
303 |
|
} |
318 |
|
{ |
319 |
|
struct Client *client_p = ptr->data; |
320 |
|
|
338 |
– |
if (client_p->localClient->reject_delay > 0) |
339 |
– |
{ |
340 |
– |
if (client_p->localClient->reject_delay <= CurrentTime) |
341 |
– |
exit_client(client_p, &me, "Rejected"); |
342 |
– |
continue; |
343 |
– |
} |
344 |
– |
|
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; |
366 |
< |
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 */ |
379 |
< |
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 |
|
|
385 |
– |
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 |
|
|
401 |
– |
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 |
|
{ |
409 |
– |
|
410 |
– |
/* 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 |
|
|
419 |
– |
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 */ |
425 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, client_p->info, |
393 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, client_p->info, |
394 |
|
NULL, NULL, 0)) != NULL || |
395 |
< |
(conf = find_matching_name_conf(RXLINE_TYPE, client_p->info, |
395 |
> |
(conf = find_matching_name_conf(CONF_RXLINE, client_p->info, |
396 |
|
NULL, NULL, 0)) != NULL) |
397 |
|
{ |
398 |
|
ban_them(client_p, conf); |
405 |
|
{ |
406 |
|
client_p = ptr->data; |
407 |
|
|
408 |
< |
if ((aconf = find_dline_conf(&client_p->localClient->ip, |
409 |
< |
client_p->localClient->aftype))) |
408 |
> |
if ((conf = find_dline_conf(&client_p->localClient->ip, |
409 |
> |
client_p->localClient->aftype))) |
410 |
|
{ |
411 |
< |
if (aconf->status & CONF_EXEMPTDLINE) |
411 |
> |
if (conf->type == CONF_EXEMPT) |
412 |
|
continue; |
413 |
|
|
414 |
|
exit_client(client_p, &me, "D-lined"); |
420 |
|
* ban_them |
421 |
|
* |
422 |
|
* inputs - pointer to client to ban |
423 |
< |
* - pointer to ConfItem |
423 |
> |
* - pointer to MaskItem |
424 |
|
* output - NONE |
425 |
|
* side effects - given client_p is banned |
426 |
|
*/ |
427 |
|
static void |
428 |
< |
ban_them(struct Client *client_p, struct ConfItem *conf) |
428 |
> |
ban_them(struct Client *client_p, struct MaskItem *conf) |
429 |
|
{ |
430 |
|
const char *user_reason = NULL; /* What is sent to user */ |
463 |
– |
const char *channel_reason = NULL; /* What is sent to channel */ |
464 |
– |
struct AccessItem *aconf = NULL; |
465 |
– |
struct MatchItem *xconf = NULL; |
431 |
|
const char *type_string = NULL; |
432 |
|
const char dline_string[] = "D-line"; |
433 |
|
const char kline_string[] = "K-line"; |
436 |
|
|
437 |
|
switch (conf->type) |
438 |
|
{ |
439 |
< |
case RKLINE_TYPE: |
440 |
< |
case KLINE_TYPE: |
439 |
> |
case CONF_RKLINE: |
440 |
> |
case CONF_KLINE: |
441 |
|
type_string = kline_string; |
477 |
– |
aconf = map_to_conf(conf); |
442 |
|
break; |
443 |
< |
case DLINE_TYPE: |
443 |
> |
case CONF_DLINE: |
444 |
|
type_string = dline_string; |
481 |
– |
aconf = map_to_conf(conf); |
445 |
|
break; |
446 |
< |
case GLINE_TYPE: |
446 |
> |
case CONF_GLINE: |
447 |
|
type_string = gline_string; |
485 |
– |
aconf = map_to_conf(conf); |
448 |
|
break; |
449 |
< |
case RXLINE_TYPE: |
450 |
< |
case XLINE_TYPE: |
449 |
> |
case CONF_RXLINE: |
450 |
> |
case CONF_XLINE: |
451 |
|
type_string = xline_string; |
452 |
< |
xconf = map_to_conf(conf); |
491 |
< |
++xconf->count; |
452 |
> |
++conf->count; |
453 |
|
break; |
454 |
|
default: |
455 |
|
assert(0); |
456 |
|
break; |
457 |
|
} |
458 |
|
|
459 |
< |
if (ConfigFileEntry.kline_with_reason) |
499 |
< |
{ |
500 |
< |
if (aconf != NULL) |
501 |
< |
user_reason = aconf->reason ? aconf->reason : type_string; |
502 |
< |
if (xconf != NULL) |
503 |
< |
user_reason = xconf->reason ? xconf->reason : type_string; |
504 |
< |
} |
505 |
< |
else |
506 |
< |
user_reason = type_string; |
507 |
< |
|
508 |
< |
if (ConfigFileEntry.kline_reason != NULL) |
509 |
< |
channel_reason = ConfigFileEntry.kline_reason; |
510 |
< |
else |
511 |
< |
channel_reason = user_reason; |
459 |
> |
user_reason = conf->reason ? conf->reason : type_string; |
460 |
|
|
461 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s active for %s", |
461 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s active for %s", |
462 |
|
type_string, get_client_name(client_p, HIDE_IP)); |
463 |
|
|
464 |
|
if (IsClient(client_p)) |
465 |
|
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP), |
466 |
|
me.name, client_p->name, user_reason); |
467 |
|
|
468 |
< |
exit_client(client_p, &me, channel_reason); |
468 |
> |
exit_client(client_p, &me, user_reason); |
469 |
|
} |
470 |
|
|
471 |
|
/* update_client_exit_stats() |
487 |
|
--Count.invisi; |
488 |
|
} |
489 |
|
else if (IsServer(client_p)) |
490 |
< |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, "Server %s split from %s", |
490 |
> |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE, |
491 |
> |
"Server %s split from %s", |
492 |
|
client_p->name, client_p->servptr->name); |
493 |
|
|
494 |
|
if (splitchecking && !splitmode) |
501 |
|
* output - return client pointer |
502 |
|
* side effects - find person by (nick)name |
503 |
|
*/ |
555 |
– |
/* XXX - ugly wrapper */ |
504 |
|
struct Client * |
505 |
|
find_person(const struct Client *client_p, const char *name) |
506 |
|
{ |
507 |
< |
struct Client *c2ptr; |
507 |
> |
struct Client *c2ptr = NULL; |
508 |
|
|
509 |
|
if (IsDigit(*name)) |
510 |
|
{ |
511 |
|
if ((c2ptr = hash_find_id(name)) != NULL) |
512 |
|
{ |
513 |
|
/* invisible users shall not be found by UID guessing */ |
514 |
< |
if (HasUMode(c2ptr, UMODE_INVISIBLE) && !IsServer(client_p)) |
515 |
< |
c2ptr = NULL; |
514 |
> |
if (HasUMode(c2ptr, UMODE_INVISIBLE)) |
515 |
> |
if (!IsServer(client_p) && !HasFlag(client_p, FLAGS_SERVICE)) |
516 |
> |
c2ptr = NULL; |
517 |
|
} |
518 |
|
} |
519 |
|
else |
576 |
|
* to modify what it points!!! |
577 |
|
*/ |
578 |
|
const char * |
579 |
< |
get_client_name(const struct Client *client, int showip) |
579 |
> |
get_client_name(const struct Client *client, enum addr_mask_type type) |
580 |
|
{ |
581 |
|
static char nbuf[HOSTLEN * 2 + USERLEN + 5]; |
582 |
|
|
583 |
|
assert(client != NULL); |
584 |
|
|
585 |
< |
if (irccmp(client->name, client->host) == 0) |
585 |
> |
if (!MyConnect(client)) |
586 |
|
return client->name; |
587 |
|
|
588 |
< |
if (ConfigServerHide.hide_server_ips) |
589 |
< |
if (IsServer(client) || IsConnecting(client) || IsHandshake(client)) |
590 |
< |
showip = MASK_IP; |
588 |
> |
if (IsServer(client) || IsConnecting(client) || IsHandshake(client)) |
589 |
> |
{ |
590 |
> |
if (!irccmp(client->name, client->host)) |
591 |
> |
return client->name; |
592 |
> |
else if (ConfigServerHide.hide_server_ips) |
593 |
> |
type = MASK_IP; |
594 |
> |
} |
595 |
|
|
596 |
|
if (ConfigFileEntry.hide_spoof_ips) |
597 |
< |
if (showip == SHOW_IP && IsIPSpoof(client)) |
598 |
< |
showip = MASK_IP; |
597 |
> |
if (type == SHOW_IP && IsIPSpoof(client)) |
598 |
> |
type = MASK_IP; |
599 |
|
|
600 |
|
/* And finally, let's get the host information, ip or name */ |
601 |
< |
switch (showip) |
601 |
> |
switch (type) |
602 |
|
{ |
603 |
|
case SHOW_IP: |
604 |
< |
if (MyConnect(client)) |
605 |
< |
{ |
606 |
< |
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", |
607 |
< |
client->name, |
655 |
< |
client->username, client->sockhost); |
656 |
< |
break; |
657 |
< |
} |
604 |
> |
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", |
605 |
> |
client->name, |
606 |
> |
client->username, client->sockhost); |
607 |
> |
break; |
608 |
|
case MASK_IP: |
609 |
< |
snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]", |
610 |
< |
client->name, client->username); |
609 |
> |
if (client->localClient->aftype == AF_INET) |
610 |
> |
snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]", |
611 |
> |
client->name, client->username); |
612 |
> |
else |
613 |
> |
snprintf(nbuf, sizeof(nbuf), "%s[%s@ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]", |
614 |
> |
client->name, client->username); |
615 |
|
break; |
616 |
|
default: |
617 |
|
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", |
659 |
|
* that the client can show the "**signoff" message). |
660 |
|
* (Note: The notice is to the local clients *only*) |
661 |
|
*/ |
662 |
< |
sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s", |
662 |
> |
sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s", |
663 |
|
source_p->name, source_p->username, |
664 |
|
source_p->host, quitmsg); |
665 |
|
DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head) |
729 |
|
{ |
730 |
|
dlink_node *ptr, *next; |
731 |
|
struct Client *target_p; |
778 |
– |
int hidden = match(me.name, source_p->name); /* XXX */ |
732 |
|
|
733 |
|
assert(to != source_p); /* should be already removed from serv_list */ |
734 |
|
|
735 |
|
/* If this server can handle quit storm (QS) removal |
736 |
|
* 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 |
737 |
|
*/ |
738 |
< |
if (hidden || !IsCapable(to, CAP_QS)) |
738 |
> |
if (!IsCapable(to, CAP_QS)) |
739 |
|
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
740 |
|
{ |
741 |
|
target_p = ptr->data; |
746 |
|
recurse_send_quits(original_source_p, ptr->data, from, to, |
747 |
|
comment, splitstr); |
748 |
|
|
749 |
< |
if (!hidden && ((source_p == original_source_p && to != from) || |
750 |
< |
!IsCapable(to, CAP_QS))) |
749 |
> |
if ((source_p == original_source_p && to != from) || |
750 |
> |
!IsCapable(to, CAP_QS)) |
751 |
|
{ |
752 |
|
/* don't use a prefix here - we have to be 100% sure the message |
753 |
|
* will be accepted without Unknown prefix etc.. */ |
836 |
|
source_p->localClient->auth = NULL; |
837 |
|
} |
838 |
|
|
839 |
< |
/* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
839 |
> |
/* |
840 |
> |
* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
841 |
|
* STAT_HANDSHAKE or STAT_UNKNOWN |
842 |
|
* all of which are lumped together into unknown_list |
843 |
|
* |
851 |
|
} |
852 |
|
else if (IsClient(source_p)) |
853 |
|
{ |
854 |
+ |
time_t on_for = CurrentTime - source_p->localClient->firsttime; |
855 |
|
assert(Count.local > 0); |
856 |
|
Count.local--; |
857 |
|
|
858 |
|
if (HasUMode(source_p, UMODE_OPER)) |
907 |
– |
{ |
859 |
|
if ((m = dlinkFindDelete(&oper_list, source_p)) != NULL) |
860 |
|
free_dlink_node(m); |
910 |
– |
} |
861 |
|
|
862 |
|
assert(dlinkFind(&local_client_list, source_p)); |
863 |
|
dlinkDelete(&source_p->localClient->lclient_node, &local_client_list); |
866 |
|
free_list_task(source_p->localClient->list_task, source_p); |
867 |
|
|
868 |
|
watch_del_watch_list(source_p); |
869 |
< |
sendto_realops_flags(UMODE_CCONN, L_ALL, "Client exiting: %s (%s@%s) [%s] [%s]", |
869 |
> |
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
870 |
> |
"Client exiting: %s (%s@%s) [%s] [%s]", |
871 |
|
source_p->name, source_p->username, source_p->host, comment, |
872 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
873 |
|
"255.255.255.255" : source_p->sockhost); |
874 |
< |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, "CLIEXIT: %s %s %s %s 0 %s", |
874 |
> |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, SEND_NOTICE, |
875 |
> |
"CLIEXIT: %s %s %s %s 0 %s", |
876 |
|
source_p->name, |
877 |
|
source_p->username, |
878 |
|
source_p->host, |
927 |
– |
|
879 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
880 |
|
"255.255.255.255" : source_p->sockhost, |
881 |
|
comment); |
882 |
+ |
ilog(LOG_TYPE_USER, "%s (%3u:%02u:%02u): %s!%s@%s %llu/%llu", |
883 |
+ |
myctime(source_p->localClient->firsttime), (unsigned int)(on_for / 3600), |
884 |
+ |
(unsigned int)((on_for % 3600)/60), (unsigned int)(on_for % 60), |
885 |
+ |
source_p->name, source_p->username, source_p->host, |
886 |
+ |
source_p->localClient->send.bytes>>10, |
887 |
+ |
source_p->localClient->recv.bytes>>10); |
888 |
+ |
} |
889 |
+ |
else if (IsServer(source_p)) |
890 |
+ |
{ |
891 |
+ |
assert(Count.myserver > 0); |
892 |
+ |
--Count.myserver; |
893 |
+ |
|
894 |
+ |
assert(dlinkFind(&serv_list, source_p)); |
895 |
+ |
dlinkDelete(&source_p->localClient->lclient_node, &serv_list); |
896 |
+ |
unset_chcap_usage_counts(source_p); |
897 |
|
} |
898 |
|
|
933 |
– |
/* As soon as a client is known to be a server of some sort |
934 |
– |
* it has to be put on the serv_list, or SJOIN's to this new server |
935 |
– |
* from the connect burst will not be seen. |
936 |
– |
* XXX - TBV. This is not true. The only place where we put a server on |
937 |
– |
* serv_list is in server_estab right now after registration process. |
938 |
– |
* And only after this, a burst is sent to the remote server, i.e. we never |
939 |
– |
* send a burst to STAT_CONNECTING, or STAT_HANDSHAKE. This will need |
940 |
– |
* more investigation later on, but for now, it's not a problem after all. |
941 |
– |
*/ |
942 |
– |
if (IsServer(source_p) || IsConnecting(source_p) || |
943 |
– |
IsHandshake(source_p)) |
944 |
– |
{ |
945 |
– |
if (dlinkFind(&serv_list, source_p)) |
946 |
– |
{ |
947 |
– |
dlinkDelete(&source_p->localClient->lclient_node, &serv_list); |
948 |
– |
unset_chcap_usage_counts(source_p); |
949 |
– |
} |
950 |
– |
|
951 |
– |
if (IsServer(source_p)) |
952 |
– |
Count.myserver--; |
953 |
– |
} |
954 |
– |
|
955 |
– |
log_user_exit(source_p); |
956 |
– |
|
899 |
|
if (!IsDead(source_p)) |
900 |
|
{ |
901 |
|
if (IsServer(source_p)) |
944 |
|
|
945 |
|
if (source_p->servptr == &me) |
946 |
|
{ |
947 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
947 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
948 |
|
"%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
949 |
|
source_p->name, (int)(CurrentTime - source_p->localClient->firsttime), |
950 |
|
source_p->localClient->send.bytes >> 10, |
951 |
|
source_p->localClient->recv.bytes >> 10); |
952 |
< |
ilog(L_NOTICE, "%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
952 |
> |
ilog(LOG_TYPE_IRCD, "%s was connected for %d seconds. %llu/%llu sendK/recvK.", |
953 |
|
source_p->name, (int)(CurrentTime - source_p->localClient->firsttime), |
954 |
|
source_p->localClient->send.bytes >> 10, |
955 |
|
source_p->localClient->recv.bytes >> 10); |
957 |
|
} |
958 |
|
else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED)) |
959 |
|
{ |
960 |
< |
sendto_server(from->from, NULL, CAP_TS6, NOCAPS, |
960 |
> |
sendto_server(from->from, CAP_TS6, NOCAPS, |
961 |
|
":%s QUIT :%s", ID(source_p), comment); |
962 |
< |
sendto_server(from->from, NULL, NOCAPS, CAP_TS6, |
962 |
> |
sendto_server(from->from, NOCAPS, CAP_TS6, |
963 |
|
":%s QUIT :%s", source_p->name, comment); |
964 |
|
} |
965 |
|
|
1023 |
|
if (error == 0) |
1024 |
|
{ |
1025 |
|
/* Admins get the real IP */ |
1026 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1026 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1027 |
|
"Server %s closed the connection", |
1028 |
|
get_client_name(client_p, SHOW_IP)); |
1029 |
|
|
1030 |
|
/* Opers get a masked IP */ |
1031 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
1031 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
1032 |
|
"Server %s closed the connection", |
1033 |
|
get_client_name(client_p, MASK_IP)); |
1034 |
|
|
1035 |
< |
ilog(L_NOTICE, "Server %s closed the connection", |
1035 |
> |
ilog(LOG_TYPE_IRCD, "Server %s closed the connection", |
1036 |
|
get_client_name(client_p, SHOW_IP)); |
1037 |
|
} |
1038 |
|
else |
1043 |
|
get_client_name(client_p, MASK_IP), current_error); |
1044 |
|
} |
1045 |
|
|
1046 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
1046 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1047 |
|
"%s had been connected for %d day%s, %2d:%02d:%02d", |
1048 |
|
client_p->name, connected/86400, |
1049 |
|
(connected/86400 == 1) ? "" : "s", |
1075 |
|
|
1076 |
|
if (target_p == NULL) |
1077 |
|
{ |
1078 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
1078 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1079 |
|
"Warning: null client on abort_list!"); |
1080 |
|
dlinkDelete(ptr, &abort_list); |
1081 |
|
free_dlink_node(ptr); |
1127 |
|
{ |
1128 |
|
struct split_nuh_item *accept_p = ptr->data; |
1129 |
|
|
1130 |
< |
if (cmpfunc(accept_p->nickptr, nick) == do_match && |
1131 |
< |
cmpfunc(accept_p->userptr, user) == do_match && |
1132 |
< |
cmpfunc(accept_p->hostptr, host) == do_match) |
1130 |
> |
if (!cmpfunc(accept_p->nickptr, nick) && |
1131 |
> |
!cmpfunc(accept_p->userptr, user) && |
1132 |
> |
!cmpfunc(accept_p->hostptr, host)) |
1133 |
|
return accept_p; |
1134 |
|
} |
1135 |
|
|
1175 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head) |
1176 |
|
del_accept(ptr->data, client_p); |
1177 |
|
} |
1178 |
+ |
|
1179 |
+ |
unsigned int |
1180 |
+ |
idle_time_get(const struct Client *source_p, const struct Client *target_p) |
1181 |
+ |
{ |
1182 |
+ |
unsigned int idle = 0; |
1183 |
+ |
unsigned int min_idle = 0; |
1184 |
+ |
unsigned int max_idle = 0; |
1185 |
+ |
struct ClassItem *class = get_class_ptr(&target_p->localClient->confs); |
1186 |
+ |
|
1187 |
+ |
if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p) |
1188 |
+ |
return CurrentTime - target_p->localClient->last_privmsg; |
1189 |
+ |
if (HasUMode(source_p, UMODE_OPER) && |
1190 |
+ |
!(class->flags & CLASS_FLAGS_HIDE_IDLE_FROM_OPERS)) |
1191 |
+ |
return CurrentTime - target_p->localClient->last_privmsg; |
1192 |
+ |
|
1193 |
+ |
min_idle = class->min_idle; |
1194 |
+ |
max_idle = class->max_idle; |
1195 |
+ |
|
1196 |
+ |
if (min_idle == max_idle) |
1197 |
+ |
return min_idle; |
1198 |
+ |
|
1199 |
+ |
if (class->flags & CLASS_FLAGS_RANDOM_IDLE) |
1200 |
+ |
idle = genrand_int32(); |
1201 |
+ |
else |
1202 |
+ |
idle = CurrentTime - target_p->localClient->last_privmsg; |
1203 |
+ |
|
1204 |
+ |
if (max_idle == 0) |
1205 |
+ |
idle = 0; |
1206 |
+ |
else |
1207 |
+ |
idle %= max_idle; |
1208 |
+ |
|
1209 |
+ |
if (idle < min_idle) |
1210 |
+ |
idle = min_idle + (idle % (max_idle - min_idle)); |
1211 |
+ |
|
1212 |
+ |
return idle; |
1213 |
+ |
} |