ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_webirc.c
Revision: 6313
Committed: Sat Aug 1 18:03:39 2015 UTC (10 years ago) by michael
Content type: text/x-csrc
File size: 4513 byte(s)
Log Message:
- Make use of the *Flag() macros in some more places

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2012-2015 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_webirc.c
23 * \brief Includes required functions for processing the WEBIRC command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "ircd.h"
31 #include "send.h"
32 #include "irc_string.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "conf.h"
36 #include "hostmask.h"
37 #include "user.h"
38
39
40 /*! \brief WEBIRC 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] = password
50 * - parv[2] = fake username (we ignore this)
51 * - parv[3] = fake hostname
52 * - parv[4] = fake ip
53 */
54 static int
55 mr_webirc(struct Client *source_p, int parc, char *parv[])
56 {
57 struct MaskItem *conf = NULL;
58 struct addrinfo hints, *res;
59
60 assert(MyConnect(source_p));
61
62 if (!valid_hostname(parv[3]))
63 {
64 sendto_one_notice(source_p, &me, ":WEBIRC: Invalid hostname");
65 return 0;
66 }
67
68 conf = find_address_conf(source_p->host,
69 HasFlag(source_p, FLAGS_GOTID) ? source_p->username : "webirc",
70 &source_p->connection->ip,
71 source_p->connection->aftype, parv[1]);
72 if (conf == NULL || !IsConfClient(conf))
73 return 0;
74
75 if (!IsConfWebIRC(conf))
76 {
77 sendto_one_notice(source_p, &me, ":Not a WEBIRC auth {} block");
78 return 0;
79 }
80
81 if (EmptyString(conf->passwd))
82 {
83 sendto_one_notice(source_p, &me, ":WEBIRC auth {} blocks must have a password");
84 return 0;
85 }
86
87 if (!match_conf_password(parv[1], conf))
88 {
89 sendto_one_notice(source_p, &me, ":WEBIRC password incorrect");
90 return 0;
91 }
92
93 memset(&hints, 0, sizeof(hints));
94
95 hints.ai_family = AF_UNSPEC;
96 hints.ai_socktype = SOCK_STREAM;
97 hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
98
99 if (getaddrinfo(parv[4], NULL, &hints, &res))
100 {
101 sendto_one_notice(source_p, &me, ":Invalid WEBIRC IP %s", parv[4]);
102 return 0;
103 }
104
105 assert(res);
106
107 memcpy(&source_p->connection->ip, res->ai_addr, res->ai_addrlen);
108 source_p->connection->ip.ss_len = res->ai_addrlen;
109 source_p->connection->ip.ss.ss_family = res->ai_family;
110 source_p->connection->aftype = res->ai_family;
111 freeaddrinfo(res);
112
113 strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
114 strlcpy(source_p->host, parv[3], sizeof(source_p->host));
115
116 /* Check dlines now, k-lines will be checked on registration */
117 if ((conf = find_dline_conf(&source_p->connection->ip,
118 source_p->connection->aftype)))
119 {
120 if (!(conf->type == CONF_EXEMPT))
121 {
122 exit_client(source_p, "D-lined");
123 return 0;
124 }
125 }
126
127 AddUMode(source_p, UMODE_WEBIRC);
128 sendto_one_notice(source_p, &me, ":WEBIRC host/IP set to %s %s",
129 parv[3], parv[4]);
130 return 0;
131 }
132
133 static struct Message webirc_msgtab =
134 {
135 .cmd = "WEBIRC",
136 .args_min = 5,
137 .args_max = MAXPARA,
138 .handlers[UNREGISTERED_HANDLER] = mr_webirc,
139 .handlers[CLIENT_HANDLER] = m_registered,
140 .handlers[SERVER_HANDLER] = m_ignore,
141 .handlers[ENCAP_HANDLER] = m_ignore,
142 .handlers[OPER_HANDLER] = m_registered
143 };
144
145 static void
146 module_init(void)
147 {
148 mod_add_cmd(&webirc_msgtab);
149 }
150
151 static void
152 module_exit(void)
153 {
154 mod_del_cmd(&webirc_msgtab);
155 }
156
157 struct module module_entry =
158 {
159 .version = "$Revision$",
160 .modinit = module_init,
161 .modexit = module_exit,
162 };

Properties

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