ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_webirc.c
Revision: 3110
Committed: Thu Mar 6 20:33:17 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4070 byte(s)
Log Message:
- Added sendto_one_notice()

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2012-2014 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
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 "s_user.h"
38
39
40 /*
41 * mr_webirc
42 * parv[0] = command
43 * parv[1] = password
44 * parv[2] = fake username (we ignore this)
45 * parv[3] = fake hostname
46 * parv[4] = fake ip
47 */
48 static int
49 mr_webirc(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
50 {
51 struct MaskItem *conf = NULL;
52 struct addrinfo hints, *res;
53
54 assert(source_p == client_p);
55
56 if (!valid_hostname(parv[3]))
57 {
58 sendto_one_notice(source_p, &me, ":CGI:IRC: Invalid hostname");
59 return 0;
60 }
61
62 conf = find_address_conf(source_p->host,
63 IsGotId(source_p) ? source_p->username : "webirc",
64 &source_p->localClient->ip,
65 source_p->localClient->aftype, parv[1]);
66 if (conf == NULL || !IsConfClient(conf))
67 return 0;
68
69 if (!IsConfWebIRC(conf))
70 {
71 sendto_one_notice(source_p, &me, ":Not a CGI:IRC auth block");
72 return 0;
73 }
74
75 if (EmptyString(conf->passwd))
76 {
77 sendto_one_notice(source_p, &me, ":CGI:IRC auth blocks must have a password");
78 return 0;
79 }
80
81 if (!match_conf_password(parv[1], conf))
82 {
83 sendto_one_notice(source_p, &me, ":CGI:IRC password incorrect");
84 return 0;
85 }
86
87 memset(&hints, 0, sizeof(hints));
88
89 hints.ai_family = AF_UNSPEC;
90 hints.ai_socktype = SOCK_STREAM;
91 hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
92
93 if (getaddrinfo(parv[4], NULL, &hints, &res))
94 {
95 sendto_one_notice(source_p, &me, ":Invalid CGI:IRC IP %s", parv[4]);
96 return 0;
97 }
98
99 assert(res != NULL);
100
101 memcpy(&source_p->localClient->ip, res->ai_addr, res->ai_addrlen);
102 source_p->localClient->ip.ss_len = res->ai_addrlen;
103 source_p->localClient->ip.ss.ss_family = res->ai_family;
104 source_p->localClient->aftype = res->ai_family;
105 freeaddrinfo(res);
106
107 strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
108 strlcpy(source_p->host, parv[3], sizeof(source_p->host));
109
110 /* Check dlines now, k/glines will be checked on registration */
111 if ((conf = find_dline_conf(&client_p->localClient->ip,
112 client_p->localClient->aftype)))
113 {
114 if (!(conf->type == CONF_EXEMPT))
115 {
116 exit_client(client_p, &me, "D-lined");
117 return 0;
118 }
119 }
120
121 AddUMode(source_p, UMODE_WEBIRC);
122 sendto_one_notice(source_p, &me, ":CGI:IRC host/IP set to %s %s",
123 parv[3], parv[4]);
124 return 0;
125 }
126
127 static struct Message webirc_msgtab =
128 {
129 "WEBIRC", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
130 { mr_webirc, m_registered, m_ignore, m_ignore, m_registered, m_ignore }
131 };
132
133 static void
134 module_init(void)
135 {
136 mod_add_cmd(&webirc_msgtab);
137 }
138
139 static void
140 module_exit(void)
141 {
142 mod_del_cmd(&webirc_msgtab);
143 }
144
145 struct module module_entry =
146 {
147 .node = { NULL, NULL, NULL },
148 .name = NULL,
149 .version = "$Revision$",
150 .handle = NULL,
151 .modinit = module_init,
152 .modexit = module_exit,
153 .flags = 0
154 };

Properties

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