2 * ircd-ratbox: A slightly useful ircd.
3 * m_webirc.c: Makes CGI:IRC users appear as coming from their real host
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2006 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * $Id: m_webirc.c 3458 2007-05-18 19:51:22Z jilles $
28 * user = "webirc@<cgiirc ip>"; # if identd used, put ident username instead
29 * password = "<password>"; # encryption possible
34 * encrypted - password is encrypted (recommended)
35 * kline_exempt - klines on the cgiirc ip are ignored
36 * dlines are checked on the cgiirc ip (of course).
37 * k/d/x lines, auth blocks, user limits, etc are checked using the
39 * The password should be specified unencrypted in webirc_password in
44 #include "client.h" /* client struct */
47 #include "send.h" /* sendto_one */
48 #include "numeric.h" /* ERR_xxx */
49 #include "ircd.h" /* me */
58 static int mr_webirc(struct Client
*, struct Client
*, int, const char **);
60 struct Message webirc_msgtab
= {
61 "WEBIRC", 0, 0, 0, MFLG_SLOW
| MFLG_UNREG
,
62 {{mr_webirc
, 5}, mg_reg
, mg_ignore
, mg_ignore
, mg_ignore
, mg_reg
}
65 mapi_clist_av1 webirc_clist
[] = { &webirc_msgtab
, NULL
};
66 DECLARE_MODULE_AV1(webirc
, NULL
, NULL
, webirc_clist
, NULL
, NULL
, "$Revision: 20702 $");
69 * mr_webirc - webirc message handler
71 * parv[2] = fake username (we ignore this)
72 * parv[3] = fake hostname
76 mr_webirc(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
78 struct ConfItem
*aconf
;
80 struct rb_sockaddr_storage addr
;
82 if ((!strchr(parv
[4], '.') && !strchr(parv
[4], ':')) ||
83 strlen(parv
[4]) + (*parv
[4] == ':') >=
84 sizeof(source_p
->sockhost
))
86 sendto_one(source_p
, "NOTICE * :Invalid IP");
90 aconf
= find_address_conf(client_p
->host
, client_p
->sockhost
,
91 IsGotId(client_p
) ? client_p
->username
: "webirc",
92 IsGotId(client_p
) ? client_p
->username
: "webirc",
93 (struct sockaddr
*) &client_p
->localClient
->ip
,
94 client_p
->localClient
->ip
.ss_family
, NULL
);
95 if (aconf
== NULL
|| !(aconf
->status
& CONF_CLIENT
))
97 if (!IsConfDoSpoofIp(aconf
) || irccmp(aconf
->info
.name
, "webirc."))
100 sendto_one(source_p
, "NOTICE * :Not a CGI:IRC auth block");
103 if (EmptyString(aconf
->passwd
))
105 sendto_one(source_p
, "NOTICE * :CGI:IRC auth blocks must have a password");
109 if (EmptyString(parv
[1]))
111 else if (IsConfEncrypted(aconf
))
112 encr
= rb_crypt(parv
[1], aconf
->passwd
);
116 if (encr
== NULL
|| strcmp(encr
, aconf
->passwd
))
118 sendto_one(source_p
, "NOTICE * :CGI:IRC password incorrect");
122 if (rb_inet_pton_sock(parv
[4], (struct sockaddr
*)&addr
) <= 0)
124 sendto_one(source_p
, "NOTICE * :Invalid IP");
130 source_p
->sockhost
[0] = '0';
131 rb_strlcpy(source_p
->sockhost
+ 1, parv
[4],
132 sizeof(source_p
->sockhost
) - 1);
135 rb_strlcpy(source_p
->sockhost
, parv
[4],
136 sizeof(source_p
->sockhost
));
138 if(strlen(parv
[3]) <= HOSTLEN
)
139 rb_strlcpy(source_p
->host
, parv
[3], sizeof(source_p
->host
));
141 rb_strlcpy(source_p
->host
, source_p
->sockhost
, sizeof(source_p
->host
));
143 source_p
->localClient
->ip
= addr
;
145 /* Check dlines now, klines will be checked on registration */
146 if((aconf
= find_dline((struct sockaddr
*)&source_p
->localClient
->ip
,
147 source_p
->localClient
->ip
.ss_family
)))
149 if(!(aconf
->status
& CONF_EXEMPTDLINE
))
151 exit_client(client_p
, source_p
, &me
, "D-lined");
156 sendto_one(source_p
, "NOTICE * :CGI:IRC host/IP set to %s %s", parv
[3], parv
[4]);