ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_undline.c
Revision: 8828
Committed: Sat Feb 2 16:49:32 2019 UTC (5 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 5930 byte(s)
Log Message:
- conf_connect_allowed, find_conf_by_address, find_address_conf, find_dline_conf: drop the aftype argument

File Contents

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

Properties

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