15 |
|
* |
16 |
|
* You should have received a copy of the GNU General Public License |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
< |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
|
* USA |
20 |
|
*/ |
21 |
|
|
40 |
|
#include "log.h" |
41 |
|
#include "server.h" |
42 |
|
#include "send.h" |
43 |
– |
#include "supported.h" |
43 |
|
#include "memory.h" |
44 |
|
#include "packet.h" |
45 |
|
#include "rng_mt.h" |
126 |
|
UMODE_WALLOP, /* w */ |
127 |
|
UMODE_HIDDENHOST, /* x */ |
128 |
|
UMODE_SPY, /* y */ |
129 |
< |
UMODE_OPERWALL, /* z 0x7A */ |
129 |
> |
0, /* z 0x7A */ |
130 |
|
0,0,0,0,0, /* 0x7B - 0x7F */ |
131 |
|
|
132 |
|
/* 0x80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x8F */ |
163 |
|
{ |
164 |
|
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
165 |
|
sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi), |
166 |
< |
Count.invisi, dlink_list_length(&global_serv_list)); |
166 |
> |
Count.invisi, dlink_list_length(&global_server_list)); |
167 |
|
else |
168 |
|
sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, |
169 |
|
(Count.total - Count.invisi), Count.invisi, 1); |
174 |
|
if (dlink_list_length(&unknown_list)) |
175 |
|
sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list)); |
176 |
|
|
177 |
< |
if (dlink_list_length(&global_channel_list)) |
178 |
< |
sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list)); |
177 |
> |
if (dlink_list_length(&channel_list)) |
178 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&channel_list)); |
179 |
|
|
180 |
|
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
181 |
|
{ |
285 |
|
char ubuf[IRCD_BUFSIZE] = ""; |
286 |
|
|
287 |
|
if (MyClient(source_p)) |
288 |
< |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
288 |
> |
send_umode(source_p, source_p, 0, ubuf); |
289 |
|
else |
290 |
< |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
290 |
> |
send_umode(NULL, source_p, 0, ubuf); |
291 |
|
|
292 |
|
watch_check_hash(source_p, RPL_LOGON); |
293 |
|
|
297 |
|
ubuf[1] = '\0'; |
298 |
|
} |
299 |
|
|
300 |
< |
DLINK_FOREACH(ptr, serv_list.head) |
300 |
> |
DLINK_FOREACH(ptr, local_server_list.head) |
301 |
|
{ |
302 |
|
struct Client *server = ptr->data; |
303 |
|
|
352 |
|
} |
353 |
|
#endif |
354 |
|
|
355 |
< |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name, |
355 |
> |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ConfigServerInfo.network_name, |
356 |
|
source_p->name); |
357 |
|
sendto_one_numeric(source_p, &me, RPL_YOURHOST, |
358 |
|
get_listener_name(source_p->localClient->listener), ircd_version); |
359 |
|
sendto_one_numeric(source_p, &me, RPL_CREATED, built_date); |
360 |
|
sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
361 |
|
show_isupport(source_p); |
362 |
< |
|
364 |
< |
if (source_p->id[0]) |
365 |
< |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
362 |
> |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
363 |
|
|
364 |
|
show_lusers(source_p); |
365 |
|
motd_signon(source_p); |
417 |
|
|
418 |
|
ClearCap(source_p, CAP_TS6); |
419 |
|
|
420 |
< |
if (ConfigFileEntry.ping_cookie) |
420 |
> |
if (ConfigGeneral.ping_cookie) |
421 |
|
{ |
422 |
|
if (!IsPingSent(source_p) && !source_p->localClient->random_ping) |
423 |
|
{ |
473 |
|
source_p->username[i++] = '~'; |
474 |
|
|
475 |
|
for (; *p && i < USERLEN; ++p) |
476 |
< |
if (*p != '[') |
480 |
< |
source_p->username[i++] = *p; |
476 |
> |
source_p->username[i++] = *p; |
477 |
|
|
478 |
|
source_p->username[i] = '\0'; |
479 |
|
} |
481 |
|
/* Password check */ |
482 |
|
if (!EmptyString(conf->passwd)) |
483 |
|
{ |
484 |
< |
if (!match_conf_password(source_p->localClient->passwd, conf)) |
484 |
> |
if (!match_conf_password(source_p->localClient->password, conf)) |
485 |
|
{ |
486 |
|
++ServerStats.is_ref; |
487 |
|
|
492 |
|
} |
493 |
|
|
494 |
|
/* |
495 |
< |
* Don't free source_p->localClient->passwd here - it can be required |
495 |
> |
* Don't free source_p->localClient->password here - it can be required |
496 |
|
* by masked /stats I if there are auth{} blocks with need_password = no; |
497 |
|
* --adx |
498 |
|
*/ |
513 |
|
* probably be just a percentage of the MAXCLIENTS... |
514 |
|
* -Taner |
515 |
|
*/ |
516 |
< |
if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) || |
517 |
< |
(Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p))) |
516 |
> |
if ((Count.local >= ConfigServerInfo.max_clients + MAX_BUFFER) || |
517 |
> |
(Count.local >= ConfigServerInfo.max_clients && !IsExemptLimits(source_p))) |
518 |
|
{ |
519 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
520 |
|
"Too many clients, rejecting %s[%s].", |
549 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
550 |
|
"Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>", |
551 |
|
source_p->name, source_p->username, source_p->host, |
552 |
< |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
552 |
> |
ConfigGeneral.hide_spoof_ips && IsIPSpoof(source_p) ? |
553 |
|
"255.255.255.255" : source_p->sockhost, |
554 |
|
get_client_class(&source_p->localClient->confs), |
555 |
|
source_p->info, source_p->id); |
556 |
|
|
557 |
< |
if (ConfigFileEntry.invisible_on_connect) |
557 |
> |
if (ConfigGeneral.invisible_on_connect) |
558 |
|
{ |
559 |
|
AddUMode(source_p, UMODE_INVISIBLE); |
560 |
|
++Count.invisi; |
577 |
|
assert(source_p->servptr == &me); |
578 |
|
SetClient(source_p); |
579 |
|
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
580 |
+ |
dlinkAdd(source_p, &source_p->node, &global_client_list); |
581 |
|
|
582 |
|
assert(dlinkFind(&unknown_list, source_p)); |
583 |
|
|
602 |
|
* is introduced by a server. |
603 |
|
*/ |
604 |
|
void |
605 |
< |
register_remote_user(struct Client *source_p, const char *username, |
609 |
< |
const char *host, const char *server) |
605 |
> |
register_remote_user(struct Client *source_p) |
606 |
|
{ |
607 |
< |
struct Client *target_p = NULL; |
612 |
< |
|
613 |
< |
assert(source_p->username != username); |
614 |
< |
|
615 |
< |
strlcpy(source_p->host, host, sizeof(source_p->host)); |
616 |
< |
strlcpy(source_p->username, username, sizeof(source_p->username)); |
617 |
< |
|
618 |
< |
/* |
619 |
< |
* Coming from another server, take the servers word for it |
620 |
< |
*/ |
621 |
< |
source_p->servptr = hash_find_server(server); |
622 |
< |
|
623 |
< |
/* |
624 |
< |
* Super GhostDetect: |
625 |
< |
* If we can't find the server the user is supposed to be on, |
626 |
< |
* then simply blow the user away. -Taner |
627 |
< |
*/ |
628 |
< |
if (source_p->servptr == NULL) |
629 |
< |
{ |
630 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
631 |
< |
"No server %s for user %s[%s@%s] from %s", |
632 |
< |
server, source_p->name, source_p->username, |
633 |
< |
source_p->host, source_p->from->name); |
634 |
< |
sendto_one(source_p->from, |
635 |
< |
":%s KILL %s :%s (Ghosted, server %s doesn't exist)", |
636 |
< |
me.id, source_p->id, me.name, server); |
637 |
< |
|
638 |
< |
AddFlag(source_p, FLAGS_KILLED); |
639 |
< |
exit_client(source_p, "Ghosted Client"); |
640 |
< |
return; |
641 |
< |
} |
607 |
> |
const struct Client *target_p = NULL; |
608 |
|
|
609 |
|
if ((target_p = source_p->servptr) && target_p->from != source_p->from) |
610 |
|
{ |
635 |
|
|
636 |
|
SetClient(source_p); |
637 |
|
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
638 |
+ |
dlinkAdd(source_p, &source_p->node, &global_client_list); |
639 |
|
add_user_host(source_p->username, source_p->host, 1); |
640 |
|
SetUserHost(source_p); |
641 |
|
|
689 |
|
int |
690 |
|
valid_username(const char *username, const int local) |
691 |
|
{ |
692 |
< |
int dots = 0; |
692 |
> |
unsigned int dots = 0; |
693 |
|
const char *p = username; |
694 |
|
|
695 |
|
assert(p); |
709 |
|
{ |
710 |
|
while (*++p) |
711 |
|
{ |
712 |
< |
if (*p == '.' && ConfigFileEntry.dots_in_ident) |
712 |
> |
if (*p == '.' && ConfigGeneral.dots_in_ident) |
713 |
|
{ |
714 |
< |
if (++dots > ConfigFileEntry.dots_in_ident) |
714 |
> |
if (++dots > ConfigGeneral.dots_in_ident) |
715 |
|
return 0; |
716 |
|
if (!IsUserChar(*(p + 1))) |
717 |
|
return 0; |
727 |
|
return 0; |
728 |
|
} |
729 |
|
|
730 |
< |
return p - username <= USERLEN;; |
730 |
> |
return p - username <= USERLEN; |
731 |
|
} |
732 |
|
|
733 |
|
/* clean_nick_name() |
770 |
|
*/ |
771 |
|
void |
772 |
|
send_umode(struct Client *client_p, struct Client *source_p, |
773 |
< |
unsigned int old, unsigned int sendmask, char *umode_buf) |
773 |
> |
unsigned int old, char *umode_buf) |
774 |
|
{ |
775 |
|
char *m = umode_buf; |
776 |
|
int what = 0; |
786 |
|
if (!flag) |
787 |
|
continue; |
788 |
|
|
822 |
– |
if (MyClient(source_p) && !(flag & sendmask)) |
823 |
– |
continue; |
824 |
– |
|
789 |
|
if ((flag & old) && !HasUMode(source_p, flag)) |
790 |
|
{ |
791 |
|
if (what == MODE_DEL) |
830 |
|
{ |
831 |
|
char buf[IRCD_BUFSIZE] = ""; |
832 |
|
|
833 |
< |
send_umode(NULL, source_p, old, SEND_UMODES, buf); |
833 |
> |
send_umode(NULL, source_p, old, buf); |
834 |
|
|
835 |
|
if (buf[0]) |
836 |
|
sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s", |
837 |
|
source_p->id, source_p->id, buf); |
838 |
|
|
839 |
|
if (client_p && MyClient(client_p)) |
840 |
< |
send_umode(client_p, source_p, old, 0xffffffff, buf); |
840 |
> |
send_umode(client_p, source_p, old, buf); |
841 |
|
} |
842 |
|
|
843 |
|
void |
863 |
|
default: return; |
864 |
|
} |
865 |
|
|
866 |
< |
if (ConfigFileEntry.cycle_on_host_change) |
866 |
> |
if (ConfigGeneral.cycle_on_host_change) |
867 |
|
sendto_common_channels_local(target_p, 0, 0, ":%s!%s@%s QUIT :Changing hostname", |
868 |
|
target_p->name, target_p->username, target_p->host); |
869 |
|
|
877 |
|
|
878 |
|
if (MyClient(target_p)) |
879 |
|
{ |
880 |
< |
sendto_one_numeric(target_p, &me, RPL_NEWHOSTIS, target_p->host); |
880 |
> |
sendto_one_numeric(target_p, &me, RPL_VISIBLEHOST, target_p->host); |
881 |
|
clear_ban_cache_client(target_p); |
882 |
|
} |
883 |
|
|
884 |
< |
if (!ConfigFileEntry.cycle_on_host_change) |
884 |
> |
if (!ConfigGeneral.cycle_on_host_change) |
885 |
|
return; |
886 |
|
|
887 |
|
DLINK_FOREACH(ptr, target_p->channel.head) |
945 |
|
|
946 |
|
if (conf->modes) |
947 |
|
AddUMode(source_p, conf->modes); |
948 |
< |
else if (ConfigFileEntry.oper_umodes) |
949 |
< |
AddUMode(source_p, ConfigFileEntry.oper_umodes); |
948 |
> |
else if (ConfigGeneral.oper_umodes) |
949 |
> |
AddUMode(source_p, ConfigGeneral.oper_umodes); |
950 |
|
|
951 |
|
if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE)) |
952 |
|
++Count.invisi; |
963 |
|
|
964 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator", |
965 |
|
get_oper_name(source_p)); |
966 |
+ |
sendto_server(NULL, NOCAPS, NOCAPS, ":%s GLOBOPS :%s is now an operator", |
967 |
+ |
me.id, get_oper_name(source_p)); |
968 |
|
send_umode_out(source_p, source_p, old); |
969 |
|
sendto_one_numeric(source_p, &me, RPL_YOUREOPER); |
970 |
|
} |
996 |
|
{ |
997 |
|
memset(new_uid, 0, sizeof(new_uid)); |
998 |
|
|
999 |
< |
if (!EmptyString(ServerInfo.sid)) |
1000 |
< |
strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid)); |
999 |
> |
if (!EmptyString(ConfigServerInfo.sid)) |
1000 |
> |
strlcpy(new_uid, ConfigServerInfo.sid, sizeof(new_uid)); |
1001 |
|
|
1002 |
|
for (unsigned int i = 0; i < IRC_MAXSID; ++i) |
1003 |
|
if (new_uid[i] == '\0') |
1065 |
|
init_isupport(void) |
1066 |
|
{ |
1067 |
|
add_isupport("CALLERID", NULL, -1); |
1068 |
< |
add_isupport("CASEMAPPING", CASEMAP, -1); |
1068 |
> |
add_isupport("CASEMAPPING", "rfc1459", -1); |
1069 |
|
add_isupport("DEAF", "D", -1); |
1070 |
|
add_isupport("KICKLEN", NULL, KICKLEN); |
1071 |
|
add_isupport("MODES", NULL, MAXMODEPARAMS); |
1106 |
– |
#ifdef HALFOPS |
1072 |
|
add_isupport("PREFIX", "(ohv)@%+", -1); |
1073 |
|
add_isupport("STATUSMSG", "@%+", -1); |
1109 |
– |
#else |
1110 |
– |
add_isupport("PREFIX", "(ov)@+", -1); |
1111 |
– |
add_isupport("STATUSMSG", "@+", -1); |
1112 |
– |
#endif |
1074 |
|
add_isupport("EXCEPTS", "e", -1); |
1075 |
|
add_isupport("INVEX", "I", -1); |
1076 |
|
} |
1088 |
|
add_isupport(const char *name, const char *options, int n) |
1089 |
|
{ |
1090 |
|
dlink_node *ptr; |
1091 |
< |
struct Isupport *support; |
1091 |
> |
struct Isupport *support = NULL; |
1092 |
|
|
1093 |
|
DLINK_FOREACH(ptr, support_list.head) |
1094 |
|
{ |