ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_away.c
Revision: 5012
Committed: Tue Dec 9 17:14:05 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 5110 byte(s)
Log Message:
- m_away.c:m_away(): don't let /AWAY end the client's flood grace period. Depending
  on the configuration, some clients instantly set them away right after connecting.
  AWAY is rate limited anyways.


File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
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 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_away.c
23     * \brief Includes required functions for processing the AWAY command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "send.h"
33     #include "parse.h"
34     #include "modules.h"
35 michael 1309 #include "conf.h"
36 michael 3347 #include "server.h"
37     #include "user.h"
38 adx 30
39    
40 michael 3300 /*! \brief AWAY command handler
41     *
42     * \param source_p Pointer to allocated Client struct from which the message
43     * originally comes from. This can be a local or remote client.
44     * \param parc Integer holding the number of supplied arguments.
45     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
46     * pointers.
47     * \note Valid arguments for this command are:
48     * - parv[0] = command
49     * - parv[1] = away message
50 adx 30 */
51 michael 2820 static int
52 michael 3156 m_away(struct Client *source_p, int parc, char *parv[])
53 adx 30 {
54     if (parc < 2 || EmptyString(parv[1]))
55     {
56     /* Marking as not away */
57 michael 1483 if (source_p->away[0])
58 adx 30 {
59 michael 1734 source_p->away[0] = '\0';
60 michael 3874
61     /* We now send this only if they were away before --is */
62 michael 4963 sendto_server(source_p, 0, 0, ":%s AWAY", source_p->id);
63 michael 3874 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY",
64 michael 1734 source_p->name, source_p->username,
65     source_p->host);
66 adx 30 }
67    
68 michael 3109 sendto_one_numeric(source_p, &me, RPL_UNAWAY);
69 michael 2820 return 0;
70 adx 30 }
71    
72 michael 4589 if ((source_p->connection->away.last_attempt + ConfigGeneral.away_time) < CurrentTime)
73     source_p->connection->away.count = 0;
74 michael 4314
75 michael 4589 if (source_p->connection->away.count > ConfigGeneral.away_count)
76 michael 1484 {
77 michael 4314 sendto_one_numeric(source_p, &me, ERR_TOOMANYAWAY);
78 michael 2820 return 0;
79 michael 1484 }
80    
81 michael 4589 source_p->connection->away.last_attempt = CurrentTime;
82     source_p->connection->away.count++;
83 michael 1734
84 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
85 adx 30
86 michael 4314 sendto_one_numeric(source_p, &me, RPL_NOWAWAY);
87 michael 3874 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY :%s",
88 michael 1734 source_p->name, source_p->username,
89     source_p->host, source_p->away);
90 michael 4963 sendto_server(source_p, 0, 0, ":%s AWAY :%s",
91 michael 3186 source_p->id, source_p->away);
92 michael 2820 return 0;
93 adx 30 }
94    
95 michael 3300 /*! \brief AWAY command handler
96     *
97     * \param source_p Pointer to allocated Client struct from which the message
98     * originally comes from. This can be a local or remote client.
99     * \param parc Integer holding the number of supplied arguments.
100     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
101     * pointers.
102     * \note Valid arguments for this command are:
103     * - parv[0] = command
104     * - parv[1] = away message
105     */
106 michael 2820 static int
107 michael 3156 ms_away(struct Client *source_p, int parc, char *parv[])
108 adx 30 {
109     if (parc < 2 || EmptyString(parv[1]))
110     {
111     /* Marking as not away */
112 michael 1483 if (source_p->away[0])
113 adx 30 {
114 michael 1734 source_p->away[0] = '\0';
115 michael 3874
116     /* We now send this only if they were away before --is */
117 michael 4963 sendto_server(source_p, 0, 0, ":%s AWAY", source_p->id);
118 michael 3874 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY",
119 michael 1734 source_p->name, source_p->username,
120     source_p->host);
121 adx 30 }
122    
123 michael 2820 return 0;
124 adx 30 }
125    
126 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
127 adx 30
128 michael 3874 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY :%s",
129 michael 1734 source_p->name, source_p->username,
130     source_p->host, source_p->away);
131 michael 4963 sendto_server(source_p, 0, 0, ":%s AWAY :%s",
132 michael 3186 source_p->id, source_p->away);
133 michael 2820 return 0;
134 adx 30 }
135 michael 1230
136 michael 2820 static struct Message away_msgtab =
137     {
138 michael 4546 "AWAY", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
139 michael 1449 { m_unregistered, m_away, ms_away, m_ignore, m_away, m_ignore }
140 michael 1230 };
141    
142     static void
143     module_init(void)
144     {
145     mod_add_cmd(&away_msgtab);
146     add_isupport("AWAYLEN", NULL, AWAYLEN);
147     }
148    
149     static void
150     module_exit(void)
151     {
152     mod_del_cmd(&away_msgtab);
153     delete_isupport("AWAYLEN");
154     }
155    
156 michael 2820 struct module module_entry =
157     {
158 michael 1230 .node = { NULL, NULL, NULL },
159     .name = NULL,
160     .version = "$Revision$",
161     .handle = NULL,
162     .modinit = module_init,
163     .modexit = module_exit,
164     .flags = 0
165     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision