23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "client.h" |
28 |
|
#include "channel_mode.h" |
29 |
|
#include "common.h" |
33 |
|
#include "irc_string.h" |
34 |
|
#include "sprintf_irc.h" |
35 |
|
#include "ircd.h" |
36 |
– |
#include "list.h" |
36 |
|
#include "s_gline.h" |
37 |
|
#include "numeric.h" |
38 |
|
#include "packet.h" |
263 |
|
struct AccessItem *aconf; |
264 |
|
|
265 |
|
conf = make_conf_item(KLINE_TYPE); |
266 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
266 |
> |
aconf = map_to_conf(conf); |
267 |
|
|
268 |
|
DupString(aconf->host, client_p->host); |
269 |
|
DupString(aconf->reason, "idle exceeder"); |
556 |
|
{ |
557 |
|
if (IsServer(client_p)) |
558 |
|
{ |
559 |
< |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, |
560 |
< |
"Server %s split from %s", |
562 |
< |
client_p->name, client_p->servptr->name); |
559 |
> |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, "Server %s split from %s", |
560 |
> |
client_p->name, client_p->servptr->name); |
561 |
|
} |
562 |
|
else if (IsClient(client_p)) |
563 |
|
{ |
564 |
+ |
assert(Count.total > 0); |
565 |
|
--Count.total; |
566 |
|
if (IsOper(client_p)) |
567 |
|
--Count.oper; |
719 |
|
|
720 |
|
assert(!IsMe(source_p)); |
721 |
|
|
722 |
< |
if (IsServer(source_p)) |
724 |
< |
{ |
725 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
726 |
< |
|
727 |
< |
if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL) |
728 |
< |
free_dlink_node(lp); |
729 |
< |
} |
730 |
< |
else if (IsClient(source_p)) |
722 |
> |
if (IsClient(source_p)) |
723 |
|
{ |
724 |
|
if (source_p->servptr->serv != NULL) |
725 |
|
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list); |
726 |
|
|
727 |
< |
/* If a person is on a channel, send a QUIT notice |
728 |
< |
** to every client (person) on the same channel (so |
729 |
< |
** that the client can show the "**signoff" message). |
730 |
< |
** (Note: The notice is to the local clients *only*) |
731 |
< |
*/ |
727 |
> |
/* |
728 |
> |
* If a person is on a channel, send a QUIT notice |
729 |
> |
* to every client (person) on the same channel (so |
730 |
> |
* that the client can show the "**signoff" message). |
731 |
> |
* (Note: The notice is to the local clients *only*) |
732 |
> |
*/ |
733 |
|
sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s", |
734 |
|
source_p->name, source_p->username, |
735 |
|
source_p->host, quitmsg); |
750 |
|
del_all_accepts(source_p); |
751 |
|
} |
752 |
|
} |
753 |
+ |
else if (IsServer(source_p)) |
754 |
+ |
{ |
755 |
+ |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
756 |
+ |
|
757 |
+ |
if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL) |
758 |
+ |
free_dlink_node(lp); |
759 |
+ |
} |
760 |
|
|
761 |
|
/* Remove source_p from the client lists */ |
762 |
|
if (HasID(source_p)) |
796 |
|
static void |
797 |
|
recurse_send_quits(struct Client *original_source_p, struct Client *source_p, |
798 |
|
struct Client *from, struct Client *to, const char *comment, |
799 |
< |
const char *splitstr, const char *myname) |
799 |
> |
const char *splitstr) |
800 |
|
{ |
801 |
|
dlink_node *ptr, *next; |
802 |
|
struct Client *target_p; |
803 |
< |
int hidden = match(myname, source_p->name); |
803 |
> |
int hidden = match(me.name, source_p->name); /* XXX */ |
804 |
|
|
805 |
|
assert(to != source_p); /* should be already removed from serv_list */ |
806 |
|
|
819 |
|
|
820 |
|
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head) |
821 |
|
recurse_send_quits(original_source_p, ptr->data, from, to, |
822 |
< |
comment, splitstr, myname); |
822 |
> |
comment, splitstr); |
823 |
|
|
824 |
|
if (!hidden && ((source_p == original_source_p && to != from) || |
825 |
|
!IsCapable(to, CAP_QS))) |
860 |
|
remove_dependents(struct Client *source_p, struct Client *from, |
861 |
|
const char *comment, const char *splitstr) |
862 |
|
{ |
863 |
< |
struct Client *to; |
864 |
< |
struct ConfItem *conf; |
865 |
< |
static char myname[HOSTLEN+1]; |
866 |
< |
dlink_node *ptr; |
863 |
> |
dlink_node *ptr = NULL; |
864 |
|
|
865 |
|
DLINK_FOREACH(ptr, serv_list.head) |
866 |
< |
{ |
867 |
< |
to = ptr->data; |
871 |
< |
|
872 |
< |
if ((conf = to->serv->sconf) != NULL) |
873 |
< |
strlcpy(myname, my_name_for_link(conf), sizeof(myname)); |
874 |
< |
else |
875 |
< |
strlcpy(myname, me.name, sizeof(myname)); |
876 |
< |
recurse_send_quits(source_p, source_p, from, to, |
877 |
< |
comment, splitstr, myname); |
878 |
< |
} |
866 |
> |
recurse_send_quits(source_p, source_p, from, ptr->data, |
867 |
> |
comment, splitstr); |
868 |
|
|
869 |
|
recurse_remove_clients(source_p, splitstr); |
870 |
|
} |
890 |
|
void |
891 |
|
exit_client(struct Client *source_p, struct Client *from, const char *comment) |
892 |
|
{ |
893 |
< |
dlink_node *m; |
893 |
> |
dlink_node *m = NULL; |
894 |
|
|
895 |
|
if (MyConnect(source_p)) |
896 |
|
{ |
905 |
|
if (IsIpHash(source_p)) |
906 |
|
remove_one_ip(&source_p->localClient->ip); |
907 |
|
|
908 |
< |
delete_auth(source_p); |
908 |
> |
if (source_p->localClient->auth) |
909 |
> |
{ |
910 |
> |
delete_auth(source_p->localClient->auth); |
911 |
> |
source_p->localClient->auth = NULL; |
912 |
> |
} |
913 |
|
|
914 |
|
/* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
915 |
|
* STAT_HANDSHAKE or STAT_UNKNOWN |
924 |
|
} |
925 |
|
else if (IsClient(source_p)) |
926 |
|
{ |
927 |
+ |
assert(Count.local > 0); |
928 |
|
Count.local--; |
929 |
|
|
930 |
|
if (IsOper(source_p)) |
1251 |
|
del_accept(ptr->data, client_p); |
1252 |
|
} |
1253 |
|
|
1260 |
– |
/* set_initial_nick() |
1261 |
– |
* |
1262 |
– |
* inputs |
1263 |
– |
* output |
1264 |
– |
* side effects - |
1265 |
– |
* |
1266 |
– |
* This function is only called to set up an initially registering |
1267 |
– |
* client. |
1268 |
– |
*/ |
1269 |
– |
void |
1270 |
– |
set_initial_nick(struct Client *client_p, struct Client *source_p, |
1271 |
– |
const char *nick) |
1272 |
– |
{ |
1273 |
– |
char buf[USERLEN + 1]; |
1274 |
– |
|
1275 |
– |
/* Client setting NICK the first time */ |
1276 |
– |
|
1277 |
– |
/* This had to be copied here to avoid problems.. */ |
1278 |
– |
source_p->tsinfo = CurrentTime; |
1279 |
– |
source_p->localClient->registration &= ~REG_NEED_NICK; |
1280 |
– |
|
1281 |
– |
if (source_p->name[0]) |
1282 |
– |
hash_del_client(source_p); |
1283 |
– |
|
1284 |
– |
strlcpy(source_p->name, nick, sizeof(source_p->name)); |
1285 |
– |
hash_add_client(source_p); |
1286 |
– |
|
1287 |
– |
/* fd_desc is long enough */ |
1288 |
– |
fd_note(&client_p->localClient->fd, "Nick: %s", nick); |
1289 |
– |
|
1290 |
– |
if (!source_p->localClient->registration) |
1291 |
– |
{ |
1292 |
– |
strlcpy(buf, source_p->username, sizeof(buf)); |
1293 |
– |
|
1294 |
– |
/* |
1295 |
– |
* USER already received, now we have NICK. |
1296 |
– |
* *NOTE* For servers "NICK" *must* precede the |
1297 |
– |
* user message (giving USER before NICK is possible |
1298 |
– |
* only for local client connection!). register_user |
1299 |
– |
* may reject the client and call exit_client for it |
1300 |
– |
* --must test this and exit m_nick too!!! |
1301 |
– |
*/ |
1302 |
– |
register_local_user(client_p, source_p, nick, buf); |
1303 |
– |
} |
1304 |
– |
} |
1305 |
– |
|
1254 |
|
/* change_local_nick() |
1255 |
|
* |
1256 |
|
* inputs - pointer to server |