35 |
|
#include "irc_string.h" |
36 |
|
#include "sprintf_irc.h" |
37 |
|
#include "s_bsd.h" |
38 |
– |
#include "irc_getnameinfo.h" |
38 |
|
#include "ircd.h" |
39 |
|
#include "list.h" |
40 |
|
#include "listener.h" |
43 |
|
#include "s_conf.h" |
44 |
|
#include "s_log.h" |
45 |
|
#include "s_serv.h" |
47 |
– |
#include "s_stats.h" |
46 |
|
#include "send.h" |
47 |
|
#include "supported.h" |
48 |
|
#include "whowas.h" |
49 |
|
#include "memory.h" |
50 |
|
#include "packet.h" |
51 |
+ |
#include "rng_mt.h" |
52 |
|
#include "userhost.h" |
53 |
|
#include "hook.h" |
54 |
|
#include "s_misc.h" |
55 |
|
#include "msg.h" |
56 |
< |
#include "pcre.h" |
56 |
> |
#include "watch.h" |
57 |
|
|
58 |
|
int MaxClientCount = 1; |
59 |
|
int MaxConnectionCount = 1; |
285 |
|
const char *nick, const char *username) |
286 |
|
{ |
287 |
|
const struct AccessItem *aconf = NULL; |
289 |
– |
char ipaddr[HOSTIPLEN]; |
288 |
|
dlink_node *ptr = NULL; |
289 |
|
dlink_node *m = NULL; |
290 |
|
|
300 |
|
if (!IsPingSent(source_p) && |
301 |
|
source_p->localClient->random_ping == 0) |
302 |
|
{ |
303 |
< |
source_p->localClient->random_ping = (unsigned long)rand(); |
304 |
< |
sendto_one(source_p, "PING :%lu", |
303 |
> |
do |
304 |
> |
source_p->localClient->random_ping = genrand_int32(); |
305 |
> |
while (!source_p->localClient->random_ping); |
306 |
> |
|
307 |
> |
sendto_one(source_p, "PING :%u", |
308 |
|
source_p->localClient->random_ping); |
309 |
|
SetPingSent(source_p); |
310 |
|
return; |
339 |
|
|
340 |
|
if (IsNeedIdentd(aconf)) |
341 |
|
{ |
342 |
< |
ServerStats->is_ref++; |
342 |
> |
++ServerStats.is_ref; |
343 |
|
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install " |
344 |
|
"identd to use this server", me.name, source_p->name); |
345 |
|
exit_client(source_p, &me, "Install identd"); |
368 |
|
|
369 |
|
if (!match_conf_password(pass, aconf)) |
370 |
|
{ |
371 |
< |
ServerStats->is_ref++; |
371 |
> |
++ServerStats.is_ref; |
372 |
|
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), |
373 |
|
me.name, source_p->name); |
374 |
|
exit_client(source_p, &me, "Bad Password"); |
384 |
|
/* report if user has &^>= etc. and set flags as needed in source_p */ |
385 |
|
report_and_set_user_flags(source_p, aconf); |
386 |
|
|
387 |
+ |
if (IsDead(client_p)) |
388 |
+ |
return; |
389 |
+ |
|
390 |
|
/* Limit clients - |
391 |
|
* We want to be able to have servers and F-line clients |
392 |
|
* connect, so save room for "buffer" connections. |
401 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
402 |
|
"Too many clients, rejecting %s[%s].", |
403 |
|
nick, source_p->host); |
404 |
< |
ServerStats->is_ref++; |
404 |
> |
++ServerStats.is_ref; |
405 |
|
exit_client(source_p, &me, "Sorry, server is full - try later"); |
406 |
|
return; |
407 |
|
} |
413 |
|
|
414 |
|
sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)", |
415 |
|
nick, source_p->username, source_p->host); |
416 |
< |
ServerStats->is_ref++; |
416 |
> |
++ServerStats.is_ref; |
417 |
|
ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username); |
418 |
|
exit_client(source_p, &me, tmpstr2); |
419 |
|
return; |
424 |
|
if (check_xline(source_p)) |
425 |
|
return; |
426 |
|
|
423 |
– |
if (IsDead(client_p)) |
424 |
– |
return; |
425 |
– |
|
427 |
|
if (me.id[0]) |
428 |
|
{ |
429 |
|
const char *id = execute_callback(uid_get_cb, source_p); |
435 |
|
hash_add_id(source_p); |
436 |
|
} |
437 |
|
|
437 |
– |
irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip, |
438 |
– |
source_p->localClient->ip.ss_len, ipaddr, |
439 |
– |
HOSTIPLEN, NULL, 0, NI_NUMERICHOST); |
440 |
– |
|
438 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, |
439 |
|
"Client connecting: %s (%s@%s) [%s] {%s} [%s]", |
440 |
|
nick, source_p->username, source_p->host, |
441 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
442 |
< |
"255.255.255.255" : ipaddr, get_client_class(source_p), |
442 |
> |
"255.255.255.255" : source_p->sockhost, |
443 |
> |
get_client_class(source_p), |
444 |
|
source_p->info); |
445 |
|
|
446 |
|
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, |
447 |
|
"CLICONN %s %s %s %s %s %s %s 0 %s", |
448 |
|
nick, source_p->username, source_p->host, |
449 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
450 |
< |
"255.255.255.255" : ipaddr, |
450 |
> |
"255.255.255.255" : source_p->sockhost, |
451 |
|
get_client_class(source_p), |
452 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
453 |
|
"<hidden>" : source_p->client_host, |
456 |
|
source_p->info); |
457 |
|
|
458 |
|
|
461 |
– |
/* If they have died in send_* don't do anything. */ |
462 |
– |
if (IsDead(source_p)) |
463 |
– |
return; |
464 |
– |
|
459 |
|
if (ConfigFileEntry.invisible_on_connect) |
460 |
|
{ |
461 |
|
source_p->umodes |= UMODE_INVISIBLE; |
462 |
< |
Count.invisi++; |
462 |
> |
++Count.invisi; |
463 |
|
} |
464 |
|
|
465 |
|
if ((++Count.local) > Count.max_loc) |
474 |
|
SetClient(source_p); |
475 |
|
|
476 |
|
source_p->servptr = &me; |
477 |
< |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
477 |
> |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
478 |
|
|
479 |
|
/* Increment our total user count here */ |
480 |
|
if (++Count.total > Count.max_tot) |
481 |
|
Count.max_tot = Count.total; |
482 |
< |
Count.totalrestartcount++; |
482 |
> |
++Count.totalrestartcount; |
483 |
|
|
484 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
485 |
|
|
520 |
|
assert(source_p->username != username); |
521 |
|
|
522 |
|
strlcpy(source_p->host, host, sizeof(source_p->host)); |
529 |
– |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
523 |
|
strlcpy(source_p->username, username, sizeof(source_p->username)); |
524 |
|
|
525 |
|
/* |
563 |
|
if (++Count.total > Count.max_tot) |
564 |
|
Count.max_tot = Count.total; |
565 |
|
|
573 |
– |
++source_p->from->serv->dep_users; |
574 |
– |
|
566 |
|
SetClient(source_p); |
567 |
< |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
567 |
> |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
568 |
|
add_user_host(source_p->username, source_p->host, 1); |
569 |
|
SetUserHost(source_p); |
570 |
|
|
591 |
|
else |
592 |
|
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
593 |
|
|
594 |
+ |
watch_check_hash(source_p, RPL_LOGON); |
595 |
+ |
|
596 |
|
if (*ubuf == '\0') |
597 |
|
{ |
598 |
|
ubuf[0] = '+'; |
599 |
|
ubuf[1] = '\0'; |
600 |
|
} |
601 |
|
|
602 |
< |
/* arghhh one could try not introducing new nicks to ll leafs |
610 |
< |
* but then you have to introduce them "on the fly" in SJOIN |
611 |
< |
* not fun. |
612 |
< |
* Its not going to cost much more bandwidth to simply let new |
613 |
< |
* nicks just ride on through. |
614 |
< |
*/ |
615 |
< |
|
616 |
< |
/* We now introduce nicks "on the fly" in SJOIN anyway -- |
617 |
< |
* you _need_ to if you aren't going to burst everyone initially. |
618 |
< |
* |
619 |
< |
* Only send to non CAP_LL servers, unless we're a lazylink leaf, |
620 |
< |
* in that case just send it to the uplink. |
621 |
< |
* -davidt |
622 |
< |
* rewritten to cope with SIDs .. eww eww eww --is |
623 |
< |
*/ |
624 |
< |
if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) && |
625 |
< |
client_p != uplink) |
602 |
> |
DLINK_FOREACH(server_node, serv_list.head) |
603 |
|
{ |
604 |
< |
if (IsCapable(uplink, CAP_TS6) && HasID(source_p)) |
605 |
< |
{ |
606 |
< |
sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
604 |
> |
struct Client *server = server_node->data; |
605 |
> |
|
606 |
> |
if (server == client_p) |
607 |
> |
continue; |
608 |
> |
|
609 |
> |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
610 |
> |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
611 |
|
source_p->servptr->id, |
612 |
|
source_p->name, source_p->hopcount+1, |
613 |
|
(unsigned long)source_p->tsinfo, |
614 |
|
ubuf, source_p->username, source_p->host, |
615 |
|
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
616 |
|
"0" : source_p->sockhost, source_p->id, source_p->info); |
636 |
– |
} |
617 |
|
else |
618 |
< |
{ |
639 |
< |
sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s", |
618 |
> |
sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s", |
619 |
|
source_p->name, source_p->hopcount+1, |
620 |
|
(unsigned long)source_p->tsinfo, |
621 |
|
ubuf, source_p->username, source_p->host, |
622 |
|
source_p->servptr->name, source_p->info); |
644 |
– |
} |
645 |
– |
} |
646 |
– |
else |
647 |
– |
{ |
648 |
– |
DLINK_FOREACH(server_node, serv_list.head) |
649 |
– |
{ |
650 |
– |
struct Client *server = server_node->data; |
651 |
– |
|
652 |
– |
if (IsCapable(server, CAP_LL) || server == client_p) |
653 |
– |
continue; |
654 |
– |
|
655 |
– |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
656 |
– |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
657 |
– |
source_p->servptr->id, |
658 |
– |
source_p->name, source_p->hopcount+1, |
659 |
– |
(unsigned long)source_p->tsinfo, |
660 |
– |
ubuf, source_p->username, source_p->host, |
661 |
– |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
662 |
– |
"0" : source_p->sockhost, source_p->id, source_p->info); |
663 |
– |
else |
664 |
– |
sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s", |
665 |
– |
source_p->name, source_p->hopcount+1, |
666 |
– |
(unsigned long)source_p->tsinfo, |
667 |
– |
ubuf, source_p->username, source_p->host, |
668 |
– |
source_p->servptr->name, source_p->info); |
669 |
– |
} |
623 |
|
} |
624 |
|
} |
625 |
|
|
1105 |
|
struct Client *target_p = ptr->data; |
1106 |
|
|
1107 |
|
if ((target_p != client_p) && (target_p != source_p)) |
1108 |
< |
{ |
1109 |
< |
if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) || |
1110 |
< |
(target_p->localClient->serverMask & |
1158 |
< |
source_p->lazyLinkClientExists)) |
1159 |
< |
sendto_one(target_p, ":%s MODE %s :%s", |
1160 |
< |
ID_or_name(source_p, target_p), |
1161 |
< |
ID_or_name(source_p, target_p), buf); |
1162 |
< |
} |
1108 |
> |
sendto_one(target_p, ":%s MODE %s :%s", |
1109 |
> |
ID_or_name(source_p, target_p), |
1110 |
> |
ID_or_name(source_p, target_p), buf); |
1111 |
|
} |
1112 |
|
} |
1113 |
|
|
1202 |
|
get_client_name(source_p, HIDE_IP), |
1203 |
|
source_p->sockhost); |
1204 |
|
|
1205 |
< |
ServerStats->is_ref++; |
1205 |
> |
++ServerStats.is_ref; |
1206 |
|
if (REJECT_HOLD_TIME > 0) |
1207 |
|
{ |
1208 |
|
sendto_one(source_p, ":%s NOTICE %s :Bad user info", |
1247 |
|
source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL| |
1248 |
|
UMODE_WALLOP|UMODE_LOCOPS); |
1249 |
|
|
1250 |
+ |
if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p)) |
1251 |
+ |
++Count.invisi; |
1252 |
+ |
if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p)) |
1253 |
+ |
--Count.invisi; |
1254 |
+ |
|
1255 |
|
assert(dlinkFind(&oper_list, source_p) == NULL); |
1256 |
|
dlinkAdd(source_p, make_dlink_node(), &oper_list); |
1257 |
|
|