ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_undline.c
Revision: 5864
Committed: Tue Apr 28 12:23:30 2015 UTC (11 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 5757 byte(s)
Log Message:
- Removed useless zero initializers from the module_entry as suggested by Adam

File Contents

# User Rev Content
1 michael 3348 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3     *
4 michael 5347 * Copyright (c) 1997-2015 ircd-hybrid development team
5 michael 3348 *
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 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 michael 3348 * USA
20     */
21    
22     /*! \file m_undline.c
23     * \brief Includes required functions for processing the UNDLINE command.
24 michael 3349 * \version $Id$
25 michael 3348 */
26    
27     #include "stdinc.h"
28     #include "list.h"
29     #include "client.h"
30     #include "irc_string.h"
31     #include "conf.h"
32     #include "ircd.h"
33     #include "hostmask.h"
34     #include "numeric.h"
35     #include "log.h"
36     #include "misc.h"
37     #include "send.h"
38     #include "server.h"
39     #include "parse.h"
40     #include "modules.h"
41     #include "conf_db.h"
42     #include "memory.h"
43    
44    
45     /* static int remove_tdline_match(const char *host, const char *user)
46     * Input: An ip to undline.
47     * Output: returns YES on success, NO if no tdline removed.
48     * Side effects: Any matching tdlines are removed.
49     */
50     static int
51 michael 5833 dline_remove(const char *host)
52 michael 3348 {
53     struct irc_ssaddr iphost, *piphost;
54     struct MaskItem *conf;
55     int t = 0;
56     int aftype = 0;
57    
58     if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
59     {
60     if (t == HM_IPV6)
61     aftype = AF_INET6;
62     else
63     aftype = AF_INET;
64 michael 4890
65 michael 3348 piphost = &iphost;
66     }
67     else
68     piphost = NULL;
69    
70     if ((conf = find_conf_by_address(host, piphost, CONF_DLINE, aftype, NULL, NULL, 0)))
71     {
72     if (IsConfDatabase(conf))
73     {
74     delete_one_address_conf(host, conf);
75     return 1;
76     }
77     }
78    
79     return 0;
80     }
81    
82 michael 5833 static void
83     dline_remove_and_notify(struct Client *source_p, const char *host)
84     {
85     if (dline_remove(host))
86     {
87     if (IsClient(source_p))
88     sendto_one_notice(source_p, &me, ":D-Line for [%s] is removed", host);
89    
90     sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
91     "%s has removed the D-Line for: [%s]",
92     get_oper_name(source_p), host);
93 michael 5836 ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
94 michael 5833 get_oper_name(source_p), host);
95     }
96     else if (IsClient(source_p))
97     sendto_one_notice(source_p, &me, ":No D-Line for [%s] found", host);
98     }
99    
100 michael 3363 /*! \brief UNDLINE command handler
101     *
102     * \param source_p Pointer to allocated Client struct from which the message
103     * originally comes from. This can be a local or remote client.
104     * \param parc Integer holding the number of supplied arguments.
105     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
106     * pointers.
107     * \note Valid arguments for this command are:
108     * - parv[0] = command
109 michael 3365 * - parv[1] = IP address
110 michael 3363 * - parv[2] = "ON"
111     * - parv[3] = target server
112     */
113 michael 3348 static int
114     mo_undline(struct Client *source_p, int parc, char *parv[])
115     {
116 michael 4049 char *addr = NULL;
117 michael 3348 char *target_server = NULL;
118    
119     if (!HasOFlag(source_p, OPER_FLAG_UNDLINE))
120     {
121     sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "undline");
122     return 0;
123     }
124    
125     if (parc < 2 || EmptyString(parv[1]))
126     {
127     sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "UNDLINE");
128     return 0;
129     }
130    
131 michael 5776 if (!parse_aline("UNDLINE", source_p, parc, parv, 0, &addr,
132     NULL, NULL, &target_server, NULL))
133 michael 3348 return 0;
134    
135 michael 3368 if (target_server)
136 michael 3348 {
137     sendto_match_servs(source_p, target_server, CAP_UNDLN,
138     "UNDLINE %s %s", target_server, addr);
139    
140 michael 3366 /* Allow ON to apply local undline as well if it matches */
141 michael 3348 if (match(target_server, me.name))
142     return 0;
143     }
144     else
145 michael 3368 cluster_a_line(source_p, "UNDLINE", CAP_UNDLN, SHARED_UNDLINE, "%s", addr);
146 michael 3348
147 michael 5833 dline_remove_and_notify(source_p, addr);
148 michael 3348 return 0;
149     }
150    
151 michael 3363 /*! \brief UNDLINE command handler
152     *
153     * \param source_p Pointer to allocated Client struct from which the message
154     * originally comes from. This can be a local or remote client.
155     * \param parc Integer holding the number of supplied arguments.
156     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
157     * pointers.
158     * \note Valid arguments for this command are:
159     * - parv[0] = command
160     * - parv[1] = target server
161 michael 3365 * - parv[2] = IP address
162 michael 3363 */
163 michael 3348 static int
164     ms_undline(struct Client *source_p, int parc, char *parv[])
165     {
166 michael 4653 const char *addr = parv[2];
167 michael 3348
168     if (parc != 3 || EmptyString(parv[2]))
169     return 0;
170    
171 michael 3368 sendto_match_servs(source_p, parv[1], CAP_UNDLN, "UNDLINE %s %s",
172 michael 3348 parv[1], parv[2]);
173    
174 michael 4639 if (match(parv[1], me.name))
175 michael 3348 return 0;
176    
177     if (HasFlag(source_p, FLAGS_SERVICE) ||
178     find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
179     source_p->username, source_p->host,
180     SHARED_UNDLINE))
181 michael 5833 dline_remove_and_notify(source_p, addr);
182 michael 4890
183 michael 3348 return 0;
184     }
185    
186     static struct Message undline_msgtab =
187     {
188 michael 4545 "UNDLINE", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
189 michael 3348 { m_unregistered, m_not_oper, ms_undline, m_ignore, mo_undline, m_ignore }
190     };
191    
192     static void
193     module_init(void)
194     {
195     mod_add_cmd(&undline_msgtab);
196 michael 5796 add_capability("UNDLN", CAP_UNDLN);
197 michael 3348 }
198    
199     static void
200     module_exit(void)
201     {
202     mod_del_cmd(&undline_msgtab);
203     delete_capability("UNDLN");
204     }
205    
206     struct module module_entry =
207     {
208 michael 3349 .version = "$Revision$",
209 michael 3348 .modinit = module_init,
210     .modexit = module_exit,
211     };

Properties

Name Value
svn:keywords Id Revision