-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.c
66 lines (55 loc) · 1.7 KB
/
actions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Various routines to perform simple actions.
*
* Services is copyright (c) 1996-1999 Andy Church.
* E-mail: <achurch@dragonfire.net>
* This program is free but copyrighted software; see the file COPYING for
* details.
*/
#include "services.h"
/*************************************************************************/
/* Remove a user from the IRC network. `source' is the nick which should
* generate the kill, or NULL for a server-generated kill.
*/
void kill_user(const char *source, const char *user, const char *reason)
{
char *av[2];
char buf[BUFSIZE];
if (!user || !*user)
return;
if (!source || !*source)
source = ServerName;
if (!reason)
reason = "";
snprintf(buf, sizeof(buf), "%s (%s)", source, reason);
av[0] = sstrdup(user);
av[1] = buf;
#ifdef IRC_UNDERNET_P10
send_cmd(source, "D %s :%s", user, av[1]);
#else
send_cmd(source, "KILL %s :%s", user, av[1]);
#endif
do_kill(source, 2, av);
free(av[0]);
}
/*************************************************************************/
/* Note a bad password attempt for the given user. If they've used up
* their limit, toss them off.
*/
void bad_password(User *u)
{
time_t now = time(NULL);
if (!BadPassLimit)
return;
if (BadPassTimeout > 0 && u->invalid_pw_time > 0
&& u->invalid_pw_time < now - BadPassTimeout)
u->invalid_pw_count = 0;
u->invalid_pw_count++;
u->invalid_pw_time = now;
if (u->invalid_pw_count >= BadPassLimit)
#ifdef IRC_UNDERNET_P10
kill_user(NULL, u->numerico, "Demasiadas passwords inválidas");
#else
kill_user(NULL, u->nick, "Demasiadas passwords inválidas");
#endif
}
/*************************************************************************/