54 |
|
#include "msg.h" |
55 |
|
#include "watch.h" |
56 |
|
|
57 |
< |
unsigned int MaxClientCount = 1; |
58 |
< |
unsigned int MaxConnectionCount = 1; |
57 |
> |
|
58 |
|
struct Callback *entering_umode_cb = NULL; |
59 |
|
struct Callback *umode_cb = NULL; |
60 |
|
|
106 |
|
0, /* O */ |
107 |
|
0, /* P */ |
108 |
|
0, /* Q */ |
109 |
< |
0, /* R */ |
109 |
> |
UMODE_REGONLY, /* R */ |
110 |
|
0, /* S */ |
111 |
|
0, /* T */ |
112 |
|
0, /* U */ |
126 |
|
UMODE_CALLERID, /* g */ |
127 |
|
0, /* h */ |
128 |
|
UMODE_INVISIBLE, /* i */ |
129 |
< |
0, /* j */ |
129 |
> |
UMODE_REJ, /* j */ |
130 |
|
UMODE_SKILL, /* k */ |
131 |
|
UMODE_LOCOPS, /* l */ |
132 |
|
0, /* m */ |
134 |
|
UMODE_OPER, /* o */ |
135 |
|
0, /* p */ |
136 |
|
0, /* q */ |
137 |
< |
UMODE_REJ, /* r */ |
137 |
> |
UMODE_REGISTERED, /* r */ |
138 |
|
UMODE_SERVNOTICE, /* s */ |
139 |
|
0, /* t */ |
140 |
|
UMODE_UNAUTH, /* u */ |
233 |
|
|
234 |
|
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
235 |
|
sendto_one(source_p, form_str(RPL_STATSCONN), from, to, |
236 |
< |
MaxConnectionCount, MaxClientCount, Count.totalrestartcount); |
236 |
> |
Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount); |
237 |
|
|
238 |
< |
if (Count.local > MaxClientCount) |
239 |
< |
MaxClientCount = Count.local; |
238 |
> |
if (Count.local > Count.max_loc_cli) |
239 |
> |
Count.max_loc_cli = Count.local; |
240 |
|
|
241 |
< |
if ((Count.local + Count.myserver) > MaxConnectionCount) |
242 |
< |
MaxConnectionCount = Count.local + Count.myserver; |
241 |
> |
if ((Count.local + Count.myserver) > Count.max_loc_con) |
242 |
> |
Count.max_loc_con = Count.local + Count.myserver; |
243 |
|
} |
244 |
|
|
245 |
|
/* show_isupport() |
280 |
|
void |
281 |
|
register_local_user(struct Client *source_p) |
282 |
|
{ |
283 |
+ |
const char *id = NULL; |
284 |
|
const struct AccessItem *aconf = NULL; |
285 |
|
dlink_node *ptr = NULL; |
286 |
– |
dlink_node *m = NULL; |
286 |
|
|
287 |
|
assert(source_p != NULL); |
288 |
|
assert(source_p == source_p->from); |
407 |
|
sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)", |
408 |
|
source_p->name, source_p->username, source_p->host); |
409 |
|
++ServerStats.is_ref; |
410 |
< |
ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username); |
410 |
> |
snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]", |
411 |
> |
source_p->username); |
412 |
|
exit_client(source_p, &me, tmpstr2); |
413 |
|
return; |
414 |
|
} |
416 |
|
if (check_xline(source_p)) |
417 |
|
return; |
418 |
|
|
419 |
< |
if (me.id[0]) |
420 |
< |
{ |
421 |
< |
const char *id = NULL; |
422 |
< |
|
423 |
< |
while (hash_find_id((id = uid_get())) != NULL) |
424 |
< |
; |
419 |
> |
while (hash_find_id((id = uid_get())) != NULL) |
420 |
> |
; |
421 |
|
|
422 |
< |
strlcpy(source_p->id, id, sizeof(source_p->id)); |
423 |
< |
hash_add_id(source_p); |
428 |
< |
} |
422 |
> |
strlcpy(source_p->id, id, sizeof(source_p->id)); |
423 |
> |
hash_add_id(source_p); |
424 |
|
|
425 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, |
426 |
< |
"Client connecting: %s (%s@%s) [%s] {%s} [%s]", |
426 |
> |
"Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>", |
427 |
|
source_p->name, source_p->username, source_p->host, |
428 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
429 |
|
"255.255.255.255" : source_p->sockhost, |
430 |
|
get_client_class(source_p), |
431 |
< |
source_p->info); |
431 |
> |
source_p->info, source_p->id); |
432 |
|
|
433 |
|
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, |
434 |
|
"CLICONN %s %s %s %s %s %s %s 0 %s", |
437 |
|
"255.255.255.255" : source_p->sockhost, |
438 |
|
get_client_class(source_p), |
439 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
440 |
< |
"<hidden>" : source_p->client_host, |
440 |
> |
"<hidden>" : source_p->localClient->client_host, |
441 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
442 |
< |
"<hidden>" : source_p->client_server, |
442 |
> |
"<hidden>" : source_p->localClient->client_server, |
443 |
|
source_p->info); |
444 |
|
|
445 |
|
|
469 |
|
|
470 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
471 |
|
|
472 |
< |
assert(dlinkFindDelete(&unknown_list, source_p)); |
472 |
> |
assert(dlinkFind(&unknown_list, source_p)); |
473 |
|
|
474 |
< |
if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL) |
475 |
< |
{ |
481 |
< |
free_dlink_node(m); |
482 |
< |
dlinkAdd(source_p, &source_p->localClient->lclient_node, &local_client_list); |
483 |
< |
} |
474 |
> |
dlink_move_node(&source_p->localClient->lclient_node, |
475 |
> |
&unknown_list, &local_client_list); |
476 |
|
|
477 |
|
user_welcome(source_p); |
478 |
|
add_user_host(source_p->username, source_p->host, 0); |
508 |
|
/* |
509 |
|
* coming from another server, take the servers word for it |
510 |
|
*/ |
511 |
< |
source_p->servptr = find_server(server); |
511 |
> |
source_p->servptr = hash_find_server(server); |
512 |
|
|
513 |
|
/* Super GhostDetect: |
514 |
|
* If we can't find the server the user is supposed to be on, |
542 |
|
return; |
543 |
|
} |
544 |
|
|
545 |
+ |
/* |
546 |
+ |
* If the nick has been introduced by a services server, |
547 |
+ |
* make it a service as well. |
548 |
+ |
*/ |
549 |
+ |
if (IsService(source_p->servptr)) |
550 |
+ |
SetService(source_p); |
551 |
+ |
|
552 |
|
/* Increment our total user count here */ |
553 |
|
if (++Count.total > Count.max_tot) |
554 |
|
Count.max_tot = Count.total; |
683 |
|
return 1; |
684 |
|
} |
685 |
|
|
686 |
+ |
/* clean_nick_name() |
687 |
+ |
* |
688 |
+ |
* input - nickname |
689 |
+ |
* - whether it's a local nick (1) or remote (0) |
690 |
+ |
* output - none |
691 |
+ |
* side effects - walks through the nickname, returning 0 if erroneous |
692 |
+ |
*/ |
693 |
+ |
int |
694 |
+ |
valid_nickname(const char *nickname, const int local) |
695 |
+ |
{ |
696 |
+ |
const char *p = nickname; |
697 |
+ |
assert(nickname && *nickname); |
698 |
+ |
|
699 |
+ |
/* nicks can't start with a digit or - or be 0 length */ |
700 |
+ |
/* This closer duplicates behaviour of hybrid-6 */ |
701 |
+ |
if (*p == '-' || (IsDigit(*p) && local) || *p == '\0') |
702 |
+ |
return 0; |
703 |
+ |
|
704 |
+ |
for (; *p; ++p) |
705 |
+ |
if (!IsNickChar(*p)) |
706 |
+ |
return 0; |
707 |
+ |
|
708 |
+ |
return p - nickname <= (NICKLEN - 1); |
709 |
+ |
} |
710 |
+ |
|
711 |
|
/* report_and_set_user_flags() |
712 |
|
* |
713 |
|
* inputs - pointer to source_p |
780 |
|
} |
781 |
|
} |
782 |
|
|
759 |
– |
/* do_local_user() |
760 |
– |
* |
761 |
– |
* inputs - |
762 |
– |
* output - NONE |
763 |
– |
* side effects - |
764 |
– |
*/ |
765 |
– |
void |
766 |
– |
do_local_user(struct Client *source_p, |
767 |
– |
const char *username, const char *host, const char *server, |
768 |
– |
const char *realname) |
769 |
– |
{ |
770 |
– |
assert(source_p != NULL); |
771 |
– |
assert(source_p->username != username); |
772 |
– |
assert(IsUnknown(source_p)); |
773 |
– |
|
774 |
– |
source_p->localClient->registration &= ~REG_NEED_USER; |
775 |
– |
|
776 |
– |
/* |
777 |
– |
* don't take the clients word for it, ever |
778 |
– |
*/ |
779 |
– |
source_p->servptr = &me; |
780 |
– |
|
781 |
– |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
782 |
– |
|
783 |
– |
/* stash for later */ |
784 |
– |
strlcpy(source_p->client_host, host, sizeof(source_p->client_host)); |
785 |
– |
strlcpy(source_p->client_server, server, sizeof(source_p->client_server)); |
786 |
– |
|
787 |
– |
if (!IsGotId(source_p)) |
788 |
– |
strlcpy(source_p->username, username, sizeof(source_p->username)); |
789 |
– |
|
790 |
– |
if (!source_p->localClient->registration) |
791 |
– |
register_local_user(source_p); |
792 |
– |
} |
793 |
– |
|
783 |
|
/* change_simple_umode() |
784 |
|
* |
785 |
|
* this callback can be hooked to allow special handling of |
839 |
|
return; |
840 |
|
} |
841 |
|
|
842 |
< |
if (source_p != target_p || target_p->from != source_p->from) |
842 |
> |
if (source_p != target_p) |
843 |
|
{ |
844 |
|
sendto_one(source_p, form_str(ERR_USERSDONTMATCH), |
845 |
|
me.name, source_p->name); |
897 |
|
break; |
898 |
|
|
899 |
|
ClearOper(source_p); |
911 |
– |
source_p->umodes &= ~ConfigFileEntry.oper_only_umodes; |
900 |
|
Count.oper--; |
901 |
|
|
902 |
|
if (MyConnect(source_p)) |
905 |
|
|
906 |
|
detach_conf(source_p, OPER_TYPE); |
907 |
|
ClearOperFlags(source_p); |
908 |
+ |
source_p->umodes &= ~ConfigFileEntry.oper_only_umodes; |
909 |
|
|
910 |
|
if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL) |
911 |
|
free_dlink_node(dm); |
917 |
|
/* we may not get these, |
918 |
|
* but they shouldnt be in default |
919 |
|
*/ |
920 |
+ |
case 'r': |
921 |
|
case ' ' : |
922 |
|
case '\n': |
923 |
|
case '\r': |
950 |
|
sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), |
951 |
|
me.name, source_p->name); |
952 |
|
|
953 |
< |
if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p)) |
953 |
> |
if (HasUMode(source_p, UMODE_NCHANGE) && !IsOperN(source_p)) |
954 |
|
{ |
955 |
|
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
956 |
|
me.name, source_p->name); |
957 |
< |
source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */ |
957 |
> |
DelUMode(source_p, UMODE_NCHANGE); /* only tcm's really need this */ |
958 |
|
} |
959 |
|
|
960 |
|
if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) && |
1115 |
|
|
1116 |
|
if (ConfigFileEntry.short_motd) |
1117 |
|
{ |
1118 |
< |
sendto_one(source_p, "NOTICE %s :*** Notice -- motd was last changed at %s", |
1119 |
< |
source_p->name, ConfigFileEntry.motd.lastChangedDate); |
1118 |
> |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- motd was last changed at %s", |
1119 |
> |
me.name, source_p->name, ConfigFileEntry.motd.lastChangedDate); |
1120 |
|
sendto_one(source_p, |
1121 |
< |
"NOTICE %s :*** Notice -- Please read the motd if you haven't " |
1122 |
< |
"read it", source_p->name); |
1121 |
> |
":%s NOTICE %s :*** Notice -- Please read the motd if you haven't " |
1122 |
> |
"read it", me.name, source_p->name); |
1123 |
|
sendto_one(source_p, form_str(RPL_MOTDSTART), |
1124 |
|
me.name, source_p->name, me.name); |
1125 |
|
sendto_one(source_p, form_str(RPL_MOTD), |
1220 |
|
SetOFlag(source_p, oconf->port); |
1221 |
|
|
1222 |
|
if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p)) |
1223 |
< |
source_p->umodes |= UMODE_ADMIN; |
1223 |
> |
AddUMode(source_p, UMODE_ADMIN); |
1224 |
|
if (!IsOperN(source_p)) |
1225 |
< |
source_p->umodes &= ~UMODE_NCHANGE; |
1225 |
> |
DelUMode(source_p, UMODE_NCHANGE); |
1226 |
|
|
1227 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator", |
1228 |
|
source_p->name, source_p->username, source_p->host); |
1238 |
|
int |
1239 |
|
valid_sid(const char *sid) |
1240 |
|
{ |
1251 |
– |
|
1241 |
|
if (strlen(sid) == IRC_MAXSID) |
1242 |
|
if (IsDigit(*sid)) |
1243 |
|
if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2))) |
1262 |
|
|
1263 |
|
memset(new_uid, 0, sizeof(new_uid)); |
1264 |
|
|
1265 |
< |
if (ServerInfo.sid != NULL) |
1277 |
< |
{ |
1265 |
> |
if (!EmptyString(ServerInfo.sid)) |
1266 |
|
strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid)); |
1279 |
– |
strlcpy(me.id, ServerInfo.sid, sizeof(me.id)); |
1280 |
– |
|
1281 |
– |
hash_add_id(&me); |
1282 |
– |
} |
1267 |
|
|
1268 |
< |
for (i = 0; i < IRC_MAXSID; i++) |
1268 |
> |
for (i = 0; i < IRC_MAXSID; ++i) |
1269 |
|
if (new_uid[i] == '\0') |
1270 |
|
new_uid[i] = 'A'; |
1271 |
|
|