ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svsmode.c
Revision: 2246
Committed: Sun Jun 16 10:48:39 2013 UTC (13 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 5913 byte(s)
Log Message:
- Add usermode 'S' (client is connecte via SSL/TLS).
  Allows services to keep track of what users are connected via SSL,
  and allows to see ssl-status of remote clients in a /whois.

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 *
4 * Copyright (C) 1999 by the Bahamut Development Team.
5 * Copyright (C) 2011 by the Hybrid Development Team.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 */
22
23 /*! \file m_svsmode.c
24 * \brief Includes required functions for processing the SVSMODE command.
25 * \version $Id$
26 */
27
28 #include "stdinc.h"
29 #include "client.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "s_serv.h"
33 #include "send.h"
34 #include "channel_mode.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "irc_string.h"
38 #include "s_user.h"
39 #include "conf.h"
40 #include "hook.h"
41
42
43 /*! \brief SVSMODE command handler (called by services)
44 *
45 * \param client_p Pointer to allocated Client struct with physical connection
46 * to this server, i.e. with an open socket connected.
47 * \param source_p Pointer to allocated Client struct from which the message
48 * originally comes from. This can be a local or remote client.
49 * \param parc Integer holding the number of supplied arguments.
50 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
51 * pointers.
52 * \note Valid arguments for this command are:
53 * - parv[0] = sender prefix
54 * - parv[1] = nickname
55 * - parv[2] = TS (or mode, depending on svs version)
56 * - parv[3] = mode (or services id if old svs version)
57 * - parv[4] = optional argument (services id)
58 */
59 static void
60 ms_svsmode(struct Client *client_p, struct Client *source_p,
61 int parc, char *parv[])
62 {
63 struct Client *target_p = NULL;
64 int what = MODE_ADD;
65 unsigned int flag = 0, setmodes = 0;
66 char *m = NULL, *modes = NULL, *extarg = NULL;
67 time_t ts = 0;
68
69 if (!HasFlag(source_p, FLAGS_SERVICE))
70 return;
71
72 if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-')))
73 {
74 ts = atol(parv[2]);
75 modes = parv[3];
76 extarg = (parc > 4) ? parv[4] : NULL;
77 }
78 else
79 {
80 modes = parv[2];
81 extarg = (parc > 3) ? parv[3] : NULL;
82 }
83
84 if ((target_p = find_person(client_p, parv[1])) == NULL)
85 return;
86
87 if (ts && (ts != target_p->tsinfo))
88 return;
89
90 setmodes = target_p->umodes;
91
92 for (m = modes; *m; ++m)
93 {
94 switch (*m)
95 {
96 case '+':
97 what = MODE_ADD;
98 break;
99 case '-':
100 what = MODE_DEL;
101 break;
102
103 case 'd':
104 if (!EmptyString(extarg))
105 strlcpy(target_p->svid, extarg, sizeof(target_p->svid));
106 break;
107
108 case 'x':
109 if (!EmptyString(extarg) && valid_hostname(extarg))
110 user_set_hostmask(target_p, extarg, what);
111 break;
112
113 case 'o':
114 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
115 {
116 ClearOper(target_p);
117 Count.oper--;
118
119 if (MyConnect(target_p))
120 {
121 dlink_node *dm = NULL;
122
123 detach_conf(target_p, CONF_OPER);
124 ClrOFlag(target_p);
125 DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
126
127 if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
128 free_dlink_node(dm);
129 }
130 }
131
132 break;
133
134 case 'i':
135 if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
136 {
137 AddUMode(target_p, UMODE_INVISIBLE);
138 ++Count.invisi;
139 }
140
141 if (what == MODE_DEL && HasUMode(target_p, UMODE_INVISIBLE))
142 {
143 DelUMode(target_p, UMODE_INVISIBLE);
144 --Count.invisi;
145 }
146
147 break;
148
149 case 'S': /* Only servers may set +S in a burst */
150 break;
151
152 default:
153 if ((flag = user_modes[(unsigned char)*m]))
154 {
155 if (what == MODE_ADD)
156 AddUMode(target_p, flag);
157 else
158 DelUMode(target_p, flag);
159 }
160
161 break;
162 }
163 }
164
165 if (extarg)
166 {
167 sendto_server(client_p, CAP_TS6, NOCAPS,
168 ":%s SVSMODE %s %lu %s %s", ID(source_p),
169 ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg);
170 sendto_server(client_p, NOCAPS, CAP_TS6,
171 ":%s SVSMODE %s %lu %s %s", source_p->name,
172 target_p->name, (unsigned long)target_p->tsinfo, modes, extarg);
173 }
174 else
175 {
176 sendto_server(client_p, CAP_TS6, NOCAPS,
177 ":%s SVSMODE %s %lu %s", ID(source_p),
178 ID(target_p), (unsigned long)target_p->tsinfo, modes);
179 sendto_server(client_p, NOCAPS, CAP_TS6,
180 ":%s SVSMODE %s %lu %s", source_p->name,
181 target_p->name, (unsigned long)target_p->tsinfo, modes);
182 }
183
184 if (MyConnect(target_p) && (setmodes != target_p->umodes))
185 {
186 char modebuf[IRCD_BUFSIZE];
187
188 send_umode(target_p, target_p, setmodes, 0xffffffff, modebuf);
189 }
190 }
191
192 static struct Message svsmode_msgtab = {
193 "SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
194 {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore}
195 };
196
197 static void
198 module_init(void)
199 {
200 mod_add_cmd(&svsmode_msgtab);
201 }
202
203 static void
204 module_exit(void)
205 {
206 mod_del_cmd(&svsmode_msgtab);
207 }
208
209 struct module module_entry = {
210 .node = { NULL, NULL, NULL },
211 .name = NULL,
212 .version = "$Revision$",
213 .handle = NULL,
214 .modinit = module_init,
215 .modexit = module_exit,
216 .flags = 0
217 };

Properties

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