| 53 |
|
#include "listener.h" |
| 54 |
|
#include "irc_res.h" |
| 55 |
|
#include "userhost.h" |
| 56 |
+ |
#include "watch.h" |
| 57 |
|
|
| 58 |
|
dlink_list listing_client_list = { NULL, NULL, 0 }; |
| 59 |
|
/* Pointer to beginning of Client list */ |
| 697 |
|
void |
| 698 |
|
free_exited_clients(void) |
| 699 |
|
{ |
| 700 |
< |
dlink_node *ptr, *next; |
| 700 |
< |
struct Client *target_p; |
| 700 |
> |
dlink_node *ptr = NULL, *next = NULL; |
| 701 |
|
|
| 702 |
|
DLINK_FOREACH_SAFE(ptr, next, dead_list.head) |
| 703 |
|
{ |
| 704 |
< |
target_p = ptr->data; |
| 705 |
< |
|
| 706 |
< |
if (ptr->data == NULL) |
| 707 |
< |
{ |
| 708 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 709 |
< |
"Warning: null client on dead_list!"); |
| 710 |
< |
dlinkDelete(ptr, &dead_list); |
| 711 |
< |
free_dlink_node(ptr); |
| 712 |
< |
continue; |
| 713 |
< |
} |
| 714 |
< |
|
| 715 |
< |
free_client(target_p); |
| 704 |
> |
free_client(ptr->data); |
| 705 |
|
dlinkDelete(ptr, &dead_list); |
| 706 |
|
free_dlink_node(ptr); |
| 707 |
|
} |
| 722 |
|
|
| 723 |
|
if (IsServer(source_p)) |
| 724 |
|
{ |
| 725 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->servers); |
| 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); |
| 740 |
– |
|
| 741 |
– |
if (!MyConnect(source_p)) |
| 742 |
– |
{ |
| 743 |
– |
source_p->from->serv->dep_servers--; |
| 744 |
– |
assert(source_p->from->serv->dep_servers > 0); |
| 745 |
– |
} |
| 729 |
|
} |
| 730 |
|
else if (IsClient(source_p)) |
| 731 |
|
{ |
| 732 |
|
if (source_p->servptr->serv != NULL) |
| 733 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->users); |
| 733 |
> |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list); |
| 734 |
|
|
| 735 |
|
/* If a person is on a channel, send a QUIT notice |
| 736 |
|
** to every client (person) on the same channel (so |
| 743 |
|
DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head) |
| 744 |
|
remove_user_from_channel(lp->data); |
| 745 |
|
|
| 763 |
– |
/* Clean up allow lists */ |
| 764 |
– |
del_all_accepts(source_p); |
| 746 |
|
add_history(source_p, 0); |
| 747 |
|
off_history(source_p); |
| 748 |
|
|
| 749 |
< |
if (!MyConnect(source_p)) |
| 750 |
< |
{ |
| 751 |
< |
source_p->from->serv->dep_users--; |
| 771 |
< |
assert(source_p->from->serv->dep_users >= 0); |
| 772 |
< |
} |
| 773 |
< |
else |
| 749 |
> |
watch_check_hash(source_p, RPL_LOGOFF); |
| 750 |
> |
|
| 751 |
> |
if (MyConnect(source_p)) |
| 752 |
|
{ |
| 753 |
|
/* Clean up invitefield */ |
| 754 |
|
DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head) |
| 755 |
|
del_invite(lp->data, source_p); |
| 756 |
+ |
|
| 757 |
+ |
del_all_accepts(source_p); |
| 758 |
|
} |
| 759 |
|
} |
| 760 |
|
|
| 811 |
|
* hidden behind fakename. If so, send out the QUITs -adx |
| 812 |
|
*/ |
| 813 |
|
if (hidden || !IsCapable(to, CAP_QS)) |
| 814 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head) |
| 814 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
| 815 |
|
{ |
| 816 |
|
target_p = ptr->data; |
| 817 |
|
sendto_one(to, ":%s QUIT :%s", target_p->name, splitstr); |
| 818 |
|
} |
| 819 |
|
|
| 820 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head) |
| 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); |
| 823 |
|
|
| 841 |
|
{ |
| 842 |
|
dlink_node *ptr, *next; |
| 843 |
|
|
| 844 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head) |
| 844 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
| 845 |
|
exit_one_client(ptr->data, quitmsg); |
| 846 |
|
|
| 847 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head) |
| 847 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head) |
| 848 |
|
{ |
| 849 |
|
recurse_remove_clients(ptr->data, quitmsg); |
| 850 |
|
exit_one_client(ptr->data, quitmsg); |
| 851 |
|
} |
| 872 |
– |
|
| 873 |
– |
assert(source_p->serv->dep_servers == 1); |
| 874 |
– |
assert(source_p->serv->dep_users == 0); |
| 852 |
|
} |
| 853 |
|
|
| 854 |
|
/* |
| 943 |
|
if (source_p->localClient->list_task != NULL) |
| 944 |
|
free_list_task(source_p->localClient->list_task, source_p); |
| 945 |
|
|
| 946 |
+ |
watch_del_watch_list(source_p); |
| 947 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, "Client exiting: %s (%s@%s) [%s] [%s]", |
| 948 |
|
source_p->name, source_p->username, source_p->host, comment, |
| 949 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
| 972 |
|
} |
| 973 |
|
|
| 974 |
|
if (IsServer(source_p)) |
| 997 |
– |
{ |
| 975 |
|
Count.myserver--; |
| 999 |
– |
if (ServerInfo.hub) |
| 1000 |
– |
remove_lazylink_flags(source_p->localClient->serverMask); |
| 1001 |
– |
else |
| 1002 |
– |
uplink = NULL; |
| 1003 |
– |
} |
| 976 |
|
} |
| 977 |
|
|
| 978 |
|
log_user_exit(source_p); |
| 1012 |
|
assert(source_p->serv != NULL && source_p->servptr != NULL); |
| 1013 |
|
|
| 1014 |
|
if (ConfigServerHide.hide_servers) |
| 1015 |
< |
/* set netsplit message to "*.net *.split" to still show |
| 1015 |
> |
/* |
| 1016 |
> |
* Set netsplit message to "*.net *.split" to still show |
| 1017 |
|
* that its a split, but hide the servers splitting |
| 1018 |
|
*/ |
| 1019 |
|
strcpy(splitstr, "*.net *.split"); |
| 1038 |
|
} |
| 1039 |
|
else if (IsClient(source_p) && !IsKilled(source_p)) |
| 1040 |
|
{ |
| 1041 |
< |
sendto_server(from->from, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS, |
| 1041 |
> |
sendto_server(from->from, NULL, CAP_TS6, NOCAPS, |
| 1042 |
|
":%s QUIT :%s", ID(source_p), comment); |
| 1043 |
< |
sendto_server(from->from, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS, |
| 1043 |
> |
sendto_server(from->from, NULL, NOCAPS, CAP_TS6, |
| 1044 |
|
":%s QUIT :%s", source_p->name, comment); |
| 1045 |
|
} |
| 1046 |
|
|
| 1177 |
|
|
| 1178 |
|
/* |
| 1179 |
|
* accept processing, this adds a form of "caller ID" to ircd |
| 1180 |
< |
* |
| 1180 |
> |
* |
| 1181 |
|
* If a client puts themselves into "caller ID only" mode, |
| 1182 |
< |
* only clients that match a client pointer they have put on |
| 1182 |
> |
* only clients that match a client pointer they have put on |
| 1183 |
|
* the accept list will be allowed to message them. |
| 1184 |
|
* |
| 1185 |
< |
* [ source.on_allow_list ] -> [ target1 ] -> [ target2 ] |
| 1213 |
< |
* |
| 1214 |
< |
* [target.allow_list] -> [ source1 ] -> [source2 ] |
| 1215 |
< |
* |
| 1216 |
< |
* i.e. a target will have a link list of source pointers it will allow |
| 1217 |
< |
* each source client then has a back pointer pointing back |
| 1218 |
< |
* to the client that has it on its accept list. |
| 1219 |
< |
* This allows for exit_one_client to remove these now bogus entries |
| 1220 |
< |
* from any client having an accept on them. |
| 1185 |
> |
* Diane Bruce, "Dianora" db@db.net |
| 1186 |
|
*/ |
| 1187 |
|
|
| 1188 |
< |
/* accept_message() |
| 1189 |
< |
* |
| 1225 |
< |
* inputs - pointer to source client |
| 1226 |
< |
* - pointer to target client |
| 1227 |
< |
* output - 1 if accept this message 0 if not |
| 1228 |
< |
* side effects - See if source is on target's allow list |
| 1229 |
< |
*/ |
| 1230 |
< |
int |
| 1231 |
< |
accept_message(struct Client *source, struct Client *target) |
| 1188 |
> |
void |
| 1189 |
> |
del_accept(struct split_nuh_item *accept_p, struct Client *client_p) |
| 1190 |
|
{ |
| 1191 |
< |
dlink_node *ptr; |
| 1191 |
> |
dlinkDelete(&accept_p->node, &client_p->localClient->acceptlist); |
| 1192 |
|
|
| 1193 |
< |
DLINK_FOREACH(ptr, target->allow_list.head) |
| 1194 |
< |
{ |
| 1195 |
< |
struct Client *target_p = ptr->data; |
| 1193 |
> |
MyFree(accept_p->nickptr); |
| 1194 |
> |
MyFree(accept_p->userptr); |
| 1195 |
> |
MyFree(accept_p->hostptr); |
| 1196 |
> |
MyFree(accept_p); |
| 1197 |
> |
} |
| 1198 |
|
|
| 1199 |
< |
if (source == target_p) |
| 1200 |
< |
return (1); |
| 1201 |
< |
} |
| 1199 |
> |
struct split_nuh_item * |
| 1200 |
> |
find_accept(const char *nick, const char *user, |
| 1201 |
> |
const char *host, struct Client *client_p, int do_match) |
| 1202 |
> |
{ |
| 1203 |
> |
dlink_node *ptr = NULL; |
| 1204 |
> |
/* XXX We wouldn't need that if match() would return 0 on match */ |
| 1205 |
> |
int (*cmpfunc)(const char *, const char *) = do_match ? match : irccmp; |
| 1206 |
|
|
| 1207 |
< |
if (IsSoftCallerId(target)) |
| 1207 |
> |
DLINK_FOREACH(ptr, client_p->localClient->acceptlist.head) |
| 1208 |
|
{ |
| 1209 |
< |
DLINK_FOREACH(ptr, target->channel.head) |
| 1210 |
< |
if (IsMember(source, ((struct Membership *)ptr->data)->chptr)) |
| 1211 |
< |
return (1); |
| 1209 |
> |
struct split_nuh_item *accept_p = ptr->data; |
| 1210 |
> |
|
| 1211 |
> |
if (cmpfunc(accept_p->nickptr, nick) == do_match && |
| 1212 |
> |
cmpfunc(accept_p->userptr, user) == do_match && |
| 1213 |
> |
cmpfunc(accept_p->hostptr, host) == do_match) |
| 1214 |
> |
return accept_p; |
| 1215 |
|
} |
| 1216 |
|
|
| 1217 |
< |
return (0); |
| 1217 |
> |
return NULL; |
| 1218 |
|
} |
| 1219 |
|
|
| 1220 |
< |
/* del_from_accept() |
| 1254 |
< |
* |
| 1255 |
< |
* inputs - pointer to source client |
| 1256 |
< |
* - pointer to target client |
| 1257 |
< |
* output - NONE |
| 1258 |
< |
* side effects - Delete's source pointer to targets allow list |
| 1220 |
> |
/* accept_message() |
| 1221 |
|
* |
| 1222 |
< |
* Walk through the target's accept list, remove if source is found, |
| 1223 |
< |
* Then walk through the source's on_accept_list remove target if found. |
| 1222 |
> |
* inputs - pointer to source client |
| 1223 |
> |
* - pointer to target client |
| 1224 |
> |
* output - 1 if accept this message 0 if not |
| 1225 |
> |
* side effects - See if source is on target's allow list |
| 1226 |
|
*/ |
| 1227 |
< |
void |
| 1228 |
< |
del_from_accept(struct Client *source, struct Client *target) |
| 1227 |
> |
int |
| 1228 |
> |
accept_message(struct Client *source, |
| 1229 |
> |
struct Client *target) |
| 1230 |
|
{ |
| 1231 |
< |
dlink_node *ptr; |
| 1267 |
< |
dlink_node *ptr2; |
| 1268 |
< |
dlink_node *next_ptr; |
| 1269 |
< |
dlink_node *next_ptr2; |
| 1270 |
< |
struct Client *target_p; |
| 1231 |
> |
dlink_node *ptr = NULL; |
| 1232 |
|
|
| 1233 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, target->allow_list.head) |
| 1234 |
< |
{ |
| 1235 |
< |
target_p = ptr->data; |
| 1233 |
> |
if (source == target || find_accept(source->name, source->username, |
| 1234 |
> |
source->host, target, 1)) |
| 1235 |
> |
return 1; |
| 1236 |
|
|
| 1237 |
< |
if (source == target_p) |
| 1238 |
< |
{ |
| 1239 |
< |
dlinkDelete(ptr, &target->allow_list); |
| 1240 |
< |
free_dlink_node(ptr); |
| 1280 |
< |
|
| 1281 |
< |
DLINK_FOREACH_SAFE(ptr2, next_ptr2, source->on_allow_list.head) |
| 1282 |
< |
{ |
| 1283 |
< |
target_p = ptr2->data; |
| 1237 |
> |
if (IsSoftCallerId(target)) |
| 1238 |
> |
DLINK_FOREACH(ptr, target->channel.head) |
| 1239 |
> |
if (IsMember(source, ((struct Membership *)ptr->data)->chptr)) |
| 1240 |
> |
return 1; |
| 1241 |
|
|
| 1242 |
< |
if (target == target_p) |
| 1286 |
< |
{ |
| 1287 |
< |
dlinkDelete(ptr2, &source->on_allow_list); |
| 1288 |
< |
free_dlink_node(ptr2); |
| 1289 |
< |
} |
| 1290 |
< |
} |
| 1291 |
< |
} |
| 1292 |
< |
} |
| 1242 |
> |
return 0; |
| 1243 |
|
} |
| 1244 |
|
|
| 1245 |
|
/* del_all_accepts() |
| 1246 |
|
* |
| 1247 |
< |
* inputs - pointer to exiting client |
| 1248 |
< |
* output - NONE |
| 1249 |
< |
* side effects - Walk through given clients allow_list and on_allow_list |
| 1300 |
< |
* remove all references to this client |
| 1247 |
> |
* inputs - pointer to exiting client |
| 1248 |
> |
* output - NONE |
| 1249 |
> |
* side effects - Walk through given clients acceptlist and remove all entries |
| 1250 |
|
*/ |
| 1251 |
|
void |
| 1252 |
|
del_all_accepts(struct Client *client_p) |
| 1253 |
|
{ |
| 1254 |
< |
dlink_node *ptr, *next_ptr; |
| 1306 |
< |
|
| 1307 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->allow_list.head) |
| 1308 |
< |
del_from_accept(ptr->data, client_p); |
| 1309 |
< |
|
| 1310 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) |
| 1311 |
< |
del_from_accept(client_p, ptr->data); |
| 1312 |
< |
} |
| 1313 |
< |
|
| 1314 |
< |
/* del_all_their_accepts() |
| 1315 |
< |
* |
| 1316 |
< |
* inputs - pointer to exiting client |
| 1317 |
< |
* output - NONE |
| 1318 |
< |
* side effects - Walk through given clients on_allow_list |
| 1319 |
< |
* remove all references to this client, |
| 1320 |
< |
* allow this client to keep their own allow_list |
| 1321 |
< |
*/ |
| 1322 |
< |
void |
| 1323 |
< |
del_all_their_accepts(struct Client *client_p) |
| 1324 |
< |
{ |
| 1325 |
< |
dlink_node *ptr, *next_ptr; |
| 1254 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
| 1255 |
|
|
| 1256 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) |
| 1257 |
< |
del_from_accept(client_p, ptr->data); |
| 1256 |
> |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head) |
| 1257 |
> |
del_accept(ptr->data, client_p); |
| 1258 |
|
} |
| 1259 |
|
|
| 1260 |
|
/* set_initial_nick() |
| 1287 |
|
/* fd_desc is long enough */ |
| 1288 |
|
fd_note(&client_p->localClient->fd, "Nick: %s", nick); |
| 1289 |
|
|
| 1361 |
– |
/* They have the nick they want now.. */ |
| 1362 |
– |
client_p->llname[0] = '\0'; |
| 1363 |
– |
|
| 1290 |
|
if (!source_p->localClient->registration) |
| 1291 |
|
{ |
| 1292 |
|
strlcpy(buf, source_p->username, sizeof(buf)); |
| 1314 |
|
void |
| 1315 |
|
change_local_nick(struct Client *client_p, struct Client *source_p, const char *nick) |
| 1316 |
|
{ |
| 1317 |
+ |
int samenick = 0; |
| 1318 |
+ |
|
| 1319 |
+ |
assert(source_p->name[0] && !EmptyString(nick)); |
| 1320 |
+ |
|
| 1321 |
|
/* |
| 1322 |
< |
** Client just changing his/her nick. If he/she is |
| 1323 |
< |
** on a channel, send note of change to all clients |
| 1324 |
< |
** on that channel. Propagate notice to other servers. |
| 1325 |
< |
*/ |
| 1322 |
> |
* Client just changing his/her nick. If he/she is |
| 1323 |
> |
* on a channel, send note of change to all clients |
| 1324 |
> |
* on that channel. Propagate notice to other servers. |
| 1325 |
> |
*/ |
| 1326 |
|
if ((source_p->localClient->last_nick_change + |
| 1327 |
|
ConfigFileEntry.max_nick_time) < CurrentTime) |
| 1328 |
|
source_p->localClient->number_of_nick_changes = 0; |
| 1335 |
|
!ConfigFileEntry.anti_nick_flood || |
| 1336 |
|
(IsOper(source_p) && ConfigFileEntry.no_oper_flood)) |
| 1337 |
|
{ |
| 1338 |
< |
if (irccmp(source_p->name, nick)) |
| 1338 |
> |
samenick = !irccmp(source_p->name, nick); |
| 1339 |
> |
|
| 1340 |
> |
if (!samenick) |
| 1341 |
|
{ |
| 1410 |
– |
/* |
| 1411 |
– |
* Make sure everyone that has this client on its accept list |
| 1412 |
– |
* loses that reference. |
| 1413 |
– |
*/ |
| 1414 |
– |
del_all_their_accepts(source_p); |
| 1342 |
|
source_p->tsinfo = CurrentTime; |
| 1343 |
|
clear_ban_cache_client(source_p); |
| 1344 |
+ |
watch_check_hash(source_p, RPL_LOGOFF); |
| 1345 |
|
} |
| 1346 |
|
|
| 1347 |
|
/* XXX - the format of this notice should eventually be changed |
| 1354 |
|
source_p->host, nick); |
| 1355 |
|
add_history(source_p, 1); |
| 1356 |
|
|
| 1357 |
< |
/* |
| 1430 |
< |
* Only hubs care about lazy link nicks not being sent on yet |
| 1431 |
< |
* lazylink leafs/leafs always send their nicks up to hub, |
| 1432 |
< |
* hence must always propagate nick changes. |
| 1433 |
< |
* hubs might not propagate a nick change, if the leaf |
| 1434 |
< |
* does not know about that client yet. |
| 1435 |
< |
*/ |
| 1436 |
< |
sendto_server(client_p, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS, |
| 1357 |
> |
sendto_server(client_p, NULL, CAP_TS6, NOCAPS, |
| 1358 |
|
":%s NICK %s :%lu", |
| 1359 |
|
ID(source_p), nick, (unsigned long)source_p->tsinfo); |
| 1360 |
< |
sendto_server(client_p, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS, |
| 1360 |
> |
sendto_server(client_p, NULL, NOCAPS, CAP_TS6, |
| 1361 |
|
":%s NICK %s :%lu", |
| 1362 |
|
source_p->name, nick, (unsigned long)source_p->tsinfo); |
| 1363 |
+ |
|
| 1364 |
+ |
hash_del_client(source_p); |
| 1365 |
+ |
strcpy(source_p->name, nick); |
| 1366 |
+ |
hash_add_client(source_p); |
| 1367 |
+ |
|
| 1368 |
+ |
if (!samenick) |
| 1369 |
+ |
watch_check_hash(source_p, RPL_LOGON); |
| 1370 |
+ |
|
| 1371 |
+ |
/* fd_desc is long enough */ |
| 1372 |
+ |
fd_note(&client_p->localClient->fd, "Nick: %s", nick); |
| 1373 |
|
} |
| 1374 |
|
else |
| 1444 |
– |
{ |
| 1375 |
|
sendto_one(source_p, form_str(ERR_NICKTOOFAST), |
| 1376 |
|
me.name, source_p->name, source_p->name, |
| 1377 |
|
nick, ConfigFileEntry.max_nick_time); |
| 1448 |
– |
return; |
| 1449 |
– |
} |
| 1450 |
– |
|
| 1451 |
– |
/* Finally, add to hash */ |
| 1452 |
– |
if (source_p->name[0]) |
| 1453 |
– |
hash_del_client(source_p); |
| 1454 |
– |
|
| 1455 |
– |
strcpy(source_p->name, nick); |
| 1456 |
– |
hash_add_client(source_p); |
| 1457 |
– |
|
| 1458 |
– |
/* fd_desc is long enough */ |
| 1459 |
– |
fd_note(&client_p->localClient->fd, "Nick: %s", nick); |
| 1378 |
|
} |