51 |
|
#include "watch.h" |
52 |
|
|
53 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
54 |
– |
|
55 |
– |
static void user_welcome(struct Client *); |
56 |
– |
static void report_and_set_user_flags(struct Client *, const struct MaskItem *); |
57 |
– |
static int check_xline(struct Client *); |
58 |
– |
static void introduce_client(struct Client *); |
54 |
|
static const char *uid_get(void); |
55 |
|
|
56 |
|
/* Used for building up the isupport string, |
57 |
|
* used with init_isupport, add_isupport, delete_isupport |
58 |
|
*/ |
64 |
– |
|
59 |
|
struct Isupport |
60 |
|
{ |
61 |
|
dlink_node node; |
218 |
|
sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data); |
219 |
|
} |
220 |
|
|
221 |
+ |
|
222 |
+ |
/* report_and_set_user_flags() |
223 |
+ |
* |
224 |
+ |
* inputs - pointer to source_p |
225 |
+ |
* - pointer to conf for this user |
226 |
+ |
* output - NONE |
227 |
+ |
* side effects - Report to user any special flags |
228 |
+ |
* they are getting, and set them. |
229 |
+ |
*/ |
230 |
+ |
static void |
231 |
+ |
report_and_set_user_flags(struct Client *source_p, const struct MaskItem *conf) |
232 |
+ |
{ |
233 |
+ |
/* If this user is being spoofed, tell them so */ |
234 |
+ |
if (IsConfDoSpoofIp(conf)) |
235 |
+ |
sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats."); |
236 |
+ |
|
237 |
+ |
/* If this user is in the exception class, Set it "E lined" */ |
238 |
+ |
if (IsConfExemptKline(conf)) |
239 |
+ |
{ |
240 |
+ |
SetExemptKline(source_p); |
241 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats."); |
242 |
+ |
} |
243 |
+ |
|
244 |
+ |
/* |
245 |
+ |
* The else here is to make sure that G line exempt users |
246 |
+ |
* do not get noticed twice. |
247 |
+ |
*/ |
248 |
+ |
else if (IsConfExemptGline(conf)) |
249 |
+ |
{ |
250 |
+ |
SetExemptGline(source_p); |
251 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats."); |
252 |
+ |
} |
253 |
+ |
|
254 |
+ |
if (IsConfExemptResv(conf)) |
255 |
+ |
{ |
256 |
+ |
SetExemptResv(source_p); |
257 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats."); |
258 |
+ |
} |
259 |
+ |
|
260 |
+ |
/* If this user is exempt from user limits set it "F lined" */ |
261 |
+ |
if (IsConfExemptLimits(conf)) |
262 |
+ |
{ |
263 |
+ |
SetExemptLimits(source_p); |
264 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats."); |
265 |
+ |
} |
266 |
+ |
|
267 |
+ |
if (IsConfCanFlood(conf)) |
268 |
+ |
{ |
269 |
+ |
SetCanFlood(source_p); |
270 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from flood " |
271 |
+ |
"protection, aren't you fearsome."); |
272 |
+ |
} |
273 |
+ |
} |
274 |
+ |
|
275 |
+ |
/* introduce_client() |
276 |
+ |
* |
277 |
+ |
* inputs - source_p |
278 |
+ |
* output - NONE |
279 |
+ |
* side effects - This common function introduces a client to the rest |
280 |
+ |
* of the net, either from a local client connect or |
281 |
+ |
* from a remote connect. |
282 |
+ |
*/ |
283 |
+ |
static void |
284 |
+ |
introduce_client(struct Client *source_p) |
285 |
+ |
{ |
286 |
+ |
dlink_node *ptr = NULL; |
287 |
+ |
char ubuf[IRCD_BUFSIZE] = ""; |
288 |
+ |
|
289 |
+ |
if (MyClient(source_p)) |
290 |
+ |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
291 |
+ |
else |
292 |
+ |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
293 |
+ |
|
294 |
+ |
watch_check_hash(source_p, RPL_LOGON); |
295 |
+ |
|
296 |
+ |
if (ubuf[0] == '\0') |
297 |
+ |
{ |
298 |
+ |
ubuf[0] = '+'; |
299 |
+ |
ubuf[1] = '\0'; |
300 |
+ |
} |
301 |
+ |
|
302 |
+ |
DLINK_FOREACH(ptr, serv_list.head) |
303 |
+ |
{ |
304 |
+ |
struct Client *server = ptr->data; |
305 |
+ |
|
306 |
+ |
if (server == source_p->from) |
307 |
+ |
continue; |
308 |
+ |
|
309 |
+ |
if (IsCapable(server, CAP_SVS)) |
310 |
+ |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
311 |
+ |
source_p->servptr->id, |
312 |
+ |
source_p->name, source_p->hopcount+1, |
313 |
+ |
(unsigned long)source_p->tsinfo, |
314 |
+ |
ubuf, source_p->username, source_p->host, |
315 |
+ |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
316 |
+ |
"0" : source_p->sockhost, source_p->id, |
317 |
+ |
source_p->svid, |
318 |
+ |
source_p->info); |
319 |
+ |
else |
320 |
+ |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
321 |
+ |
source_p->servptr->id, |
322 |
+ |
source_p->name, source_p->hopcount+1, |
323 |
+ |
(unsigned long)source_p->tsinfo, |
324 |
+ |
ubuf, source_p->username, source_p->host, |
325 |
+ |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
326 |
+ |
"0" : source_p->sockhost, source_p->id, source_p->info); |
327 |
+ |
|
328 |
+ |
if (!EmptyString(source_p->certfp)) |
329 |
+ |
sendto_one(server, ":%s CERTFP %s", source_p->id, source_p->certfp); |
330 |
+ |
} |
331 |
+ |
} |
332 |
+ |
|
333 |
+ |
/* user_welcome() |
334 |
+ |
* |
335 |
+ |
* inputs - client pointer to client to welcome |
336 |
+ |
* output - NONE |
337 |
+ |
* side effects - |
338 |
+ |
*/ |
339 |
+ |
static void |
340 |
+ |
user_welcome(struct Client *source_p) |
341 |
+ |
{ |
342 |
+ |
#if defined(__TIME__) && defined(__DATE__) |
343 |
+ |
static const char built_date[] = __DATE__ " at " __TIME__; |
344 |
+ |
#else |
345 |
+ |
static const char built_date[] = "unknown"; |
346 |
+ |
#endif |
347 |
+ |
|
348 |
+ |
#ifdef HAVE_LIBCRYPTO |
349 |
+ |
if (HasFlag(source_p, FLAGS_SSL)) |
350 |
+ |
{ |
351 |
+ |
AddUMode(source_p, UMODE_SSL); |
352 |
+ |
sendto_one_notice(source_p, &me, ":*** Connected securely via %s", |
353 |
+ |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
354 |
+ |
} |
355 |
+ |
#endif |
356 |
+ |
|
357 |
+ |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name, |
358 |
+ |
source_p->name); |
359 |
+ |
sendto_one_numeric(source_p, &me, RPL_YOURHOST, |
360 |
+ |
get_listener_name(source_p->localClient->listener), ircd_version); |
361 |
+ |
sendto_one_numeric(source_p, &me, RPL_CREATED, built_date); |
362 |
+ |
sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
363 |
+ |
show_isupport(source_p); |
364 |
+ |
|
365 |
+ |
if (source_p->id[0]) |
366 |
+ |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
367 |
+ |
|
368 |
+ |
show_lusers(source_p); |
369 |
+ |
motd_signon(source_p); |
370 |
+ |
} |
371 |
+ |
|
372 |
+ |
/* check_xline() |
373 |
+ |
* |
374 |
+ |
* inputs - pointer to client to test |
375 |
+ |
* outupt - 1 if exiting 0 if ok |
376 |
+ |
* side effects - |
377 |
+ |
*/ |
378 |
+ |
static int |
379 |
+ |
check_xline(struct Client *source_p) |
380 |
+ |
{ |
381 |
+ |
struct MaskItem *conf = NULL; |
382 |
+ |
const char *reason = NULL; |
383 |
+ |
|
384 |
+ |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
385 |
+ |
{ |
386 |
+ |
++conf->count; |
387 |
+ |
|
388 |
+ |
if (conf->reason) |
389 |
+ |
reason = conf->reason; |
390 |
+ |
else |
391 |
+ |
reason = CONF_NOREASON; |
392 |
+ |
|
393 |
+ |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
394 |
+ |
"X-line Rejecting [%s] [%s], user %s [%s]", |
395 |
+ |
source_p->info, reason, |
396 |
+ |
get_client_name(source_p, HIDE_IP), |
397 |
+ |
source_p->sockhost); |
398 |
+ |
|
399 |
+ |
++ServerStats.is_ref; |
400 |
+ |
exit_client(source_p, "Bad user info"); |
401 |
+ |
return 1; |
402 |
+ |
} |
403 |
+ |
|
404 |
+ |
return 0; |
405 |
+ |
} |
406 |
+ |
|
407 |
|
/* |
408 |
|
** register_local_user |
409 |
|
** This function is called when both NICK and USER messages |
706 |
|
introduce_client(source_p); |
707 |
|
} |
708 |
|
|
529 |
– |
/* introduce_client() |
530 |
– |
* |
531 |
– |
* inputs - source_p |
532 |
– |
* output - NONE |
533 |
– |
* side effects - This common function introduces a client to the rest |
534 |
– |
* of the net, either from a local client connect or |
535 |
– |
* from a remote connect. |
536 |
– |
*/ |
537 |
– |
static void |
538 |
– |
introduce_client(struct Client *source_p) |
539 |
– |
{ |
540 |
– |
dlink_node *ptr = NULL; |
541 |
– |
char ubuf[IRCD_BUFSIZE] = ""; |
542 |
– |
|
543 |
– |
if (MyClient(source_p)) |
544 |
– |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
545 |
– |
else |
546 |
– |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
547 |
– |
|
548 |
– |
watch_check_hash(source_p, RPL_LOGON); |
549 |
– |
|
550 |
– |
if (ubuf[0] == '\0') |
551 |
– |
{ |
552 |
– |
ubuf[0] = '+'; |
553 |
– |
ubuf[1] = '\0'; |
554 |
– |
} |
555 |
– |
|
556 |
– |
DLINK_FOREACH(ptr, serv_list.head) |
557 |
– |
{ |
558 |
– |
struct Client *server = ptr->data; |
559 |
– |
|
560 |
– |
if (server == source_p->from) |
561 |
– |
continue; |
562 |
– |
|
563 |
– |
if (IsCapable(server, CAP_SVS)) |
564 |
– |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
565 |
– |
source_p->servptr->id, |
566 |
– |
source_p->name, source_p->hopcount+1, |
567 |
– |
(unsigned long)source_p->tsinfo, |
568 |
– |
ubuf, source_p->username, source_p->host, |
569 |
– |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
570 |
– |
"0" : source_p->sockhost, source_p->id, |
571 |
– |
source_p->svid, |
572 |
– |
source_p->info); |
573 |
– |
else |
574 |
– |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
575 |
– |
source_p->servptr->id, |
576 |
– |
source_p->name, source_p->hopcount+1, |
577 |
– |
(unsigned long)source_p->tsinfo, |
578 |
– |
ubuf, source_p->username, source_p->host, |
579 |
– |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
580 |
– |
"0" : source_p->sockhost, source_p->id, source_p->info); |
581 |
– |
|
582 |
– |
if (!EmptyString(source_p->certfp)) |
583 |
– |
sendto_one(server, ":%s CERTFP %s", source_p->id, source_p->certfp); |
584 |
– |
} |
585 |
– |
} |
586 |
– |
|
709 |
|
/* valid_hostname() |
710 |
|
* |
711 |
|
* Inputs - pointer to hostname |
814 |
|
return p - nickname <= NICKLEN; |
815 |
|
} |
816 |
|
|
695 |
– |
/* report_and_set_user_flags() |
696 |
– |
* |
697 |
– |
* inputs - pointer to source_p |
698 |
– |
* - pointer to conf for this user |
699 |
– |
* output - NONE |
700 |
– |
* side effects - Report to user any special flags |
701 |
– |
* they are getting, and set them. |
702 |
– |
*/ |
703 |
– |
static void |
704 |
– |
report_and_set_user_flags(struct Client *source_p, const struct MaskItem *conf) |
705 |
– |
{ |
706 |
– |
/* If this user is being spoofed, tell them so */ |
707 |
– |
if (IsConfDoSpoofIp(conf)) |
708 |
– |
sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats."); |
709 |
– |
|
710 |
– |
/* If this user is in the exception class, Set it "E lined" */ |
711 |
– |
if (IsConfExemptKline(conf)) |
712 |
– |
{ |
713 |
– |
SetExemptKline(source_p); |
714 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats."); |
715 |
– |
} |
716 |
– |
|
717 |
– |
/* |
718 |
– |
* The else here is to make sure that G line exempt users |
719 |
– |
* do not get noticed twice. |
720 |
– |
*/ |
721 |
– |
else if (IsConfExemptGline(conf)) |
722 |
– |
{ |
723 |
– |
SetExemptGline(source_p); |
724 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats."); |
725 |
– |
} |
726 |
– |
|
727 |
– |
if (IsConfExemptResv(conf)) |
728 |
– |
{ |
729 |
– |
SetExemptResv(source_p); |
730 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats."); |
731 |
– |
} |
732 |
– |
|
733 |
– |
/* If this user is exempt from user limits set it "F lined" */ |
734 |
– |
if (IsConfExemptLimits(conf)) |
735 |
– |
{ |
736 |
– |
SetExemptLimits(source_p); |
737 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats."); |
738 |
– |
} |
739 |
– |
|
740 |
– |
if (IsConfCanFlood(conf)) |
741 |
– |
{ |
742 |
– |
SetCanFlood(source_p); |
743 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from flood " |
744 |
– |
"protection, aren't you fearsome."); |
745 |
– |
} |
746 |
– |
} |
747 |
– |
|
817 |
|
/* set_user_mode() |
818 |
|
* |
819 |
|
* added 15/10/91 By Darren Reed. |
1131 |
|
target_p->host, target_p->away); |
1132 |
|
} |
1133 |
|
|
1065 |
– |
/* user_welcome() |
1066 |
– |
* |
1067 |
– |
* inputs - client pointer to client to welcome |
1068 |
– |
* output - NONE |
1069 |
– |
* side effects - |
1070 |
– |
*/ |
1071 |
– |
static void |
1072 |
– |
user_welcome(struct Client *source_p) |
1073 |
– |
{ |
1074 |
– |
#if defined(__TIME__) && defined(__DATE__) |
1075 |
– |
static const char built_date[] = __DATE__ " at " __TIME__; |
1076 |
– |
#else |
1077 |
– |
static const char built_date[] = "unknown"; |
1078 |
– |
#endif |
1079 |
– |
|
1080 |
– |
#ifdef HAVE_LIBCRYPTO |
1081 |
– |
if (HasFlag(source_p, FLAGS_SSL)) |
1082 |
– |
{ |
1083 |
– |
AddUMode(source_p, UMODE_SSL); |
1084 |
– |
sendto_one_notice(source_p, &me, ":*** Connected securely via %s", |
1085 |
– |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
1086 |
– |
} |
1087 |
– |
#endif |
1088 |
– |
|
1089 |
– |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name, |
1090 |
– |
source_p->name); |
1091 |
– |
sendto_one_numeric(source_p, &me, RPL_YOURHOST, |
1092 |
– |
get_listener_name(source_p->localClient->listener), ircd_version); |
1093 |
– |
sendto_one_numeric(source_p, &me, RPL_CREATED, built_date); |
1094 |
– |
sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
1095 |
– |
show_isupport(source_p); |
1096 |
– |
|
1097 |
– |
if (source_p->id[0]) |
1098 |
– |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
1099 |
– |
|
1100 |
– |
show_lusers(source_p); |
1101 |
– |
motd_signon(source_p); |
1102 |
– |
} |
1103 |
– |
|
1104 |
– |
/* check_xline() |
1105 |
– |
* |
1106 |
– |
* inputs - pointer to client to test |
1107 |
– |
* outupt - 1 if exiting 0 if ok |
1108 |
– |
* side effects - |
1109 |
– |
*/ |
1110 |
– |
static int |
1111 |
– |
check_xline(struct Client *source_p) |
1112 |
– |
{ |
1113 |
– |
struct MaskItem *conf = NULL; |
1114 |
– |
const char *reason = NULL; |
1115 |
– |
|
1116 |
– |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
1117 |
– |
{ |
1118 |
– |
++conf->count; |
1119 |
– |
|
1120 |
– |
if (conf->reason) |
1121 |
– |
reason = conf->reason; |
1122 |
– |
else |
1123 |
– |
reason = CONF_NOREASON; |
1124 |
– |
|
1125 |
– |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
1126 |
– |
"X-line Rejecting [%s] [%s], user %s [%s]", |
1127 |
– |
source_p->info, reason, |
1128 |
– |
get_client_name(source_p, HIDE_IP), |
1129 |
– |
source_p->sockhost); |
1130 |
– |
|
1131 |
– |
++ServerStats.is_ref; |
1132 |
– |
exit_client(source_p, "Bad user info"); |
1133 |
– |
return 1; |
1134 |
– |
} |
1135 |
– |
|
1136 |
– |
return 0; |
1137 |
– |
} |
1138 |
– |
|
1134 |
|
/* oper_up() |
1135 |
|
* |
1136 |
|
* inputs - pointer to given client to oper |