ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_svsmode.c
Revision: 2511
Committed: Sun Oct 27 18:56:53 2013 UTC (12 years, 8 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/trunk/modules/m_svsmode.c
File size: 5938 byte(s)
Log Message:
- Added usermode +W. Users connected via a webirc gateway get this
  mode set by servers.
- /WHOIS now shows whether a client is connected via a webirc
  gateway

File Contents

# User Rev Content
1 michael 1159 /*
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 michael 1160 * \version $Id$
26 michael 1159 */
27    
28     #include "stdinc.h"
29     #include "client.h"
30     #include "ircd.h"
31     #include "s_serv.h"
32     #include "send.h"
33     #include "channel_mode.h"
34     #include "parse.h"
35     #include "modules.h"
36     #include "irc_string.h"
37     #include "s_user.h"
38 michael 1309 #include "conf.h"
39 michael 1159
40    
41 michael 1221 /*! \brief SVSMODE command handler (called by services)
42 michael 1159 *
43     * \param client_p Pointer to allocated Client struct with physical connection
44     * to this server, i.e. with an open socket connected.
45     * \param source_p Pointer to allocated Client struct from which the message
46     * originally comes from. This can be a local or remote client.
47     * \param parc Integer holding the number of supplied arguments.
48     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
49     * pointers.
50     * \note Valid arguments for this command are:
51     * - parv[0] = sender prefix
52     * - parv[1] = nickname
53 michael 2055 * - parv[2] = TS (or mode, depending on svs version)
54     * - parv[3] = mode (or services id if old svs version)
55     * - parv[4] = optional argument (services id)
56 michael 1159 */
57     static void
58     ms_svsmode(struct Client *client_p, struct Client *source_p,
59     int parc, char *parv[])
60     {
61     struct Client *target_p = NULL;
62     int what = MODE_ADD;
63 michael 2056 unsigned int flag = 0, setmodes = 0;
64 michael 2503 const char *m = NULL, *modes = NULL, *extarg = NULL;
65 michael 1159 time_t ts = 0;
66    
67 michael 1221 if (!HasFlag(source_p, FLAGS_SERVICE))
68 michael 1159 return;
69    
70 michael 2055 if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-')))
71     {
72     ts = atol(parv[2]);
73     modes = parv[3];
74     extarg = (parc > 4) ? parv[4] : NULL;
75     }
76     else
77     {
78     modes = parv[2];
79     extarg = (parc > 3) ? parv[3] : NULL;
80     }
81    
82 michael 1159 if ((target_p = find_person(client_p, parv[1])) == NULL)
83     return;
84    
85 michael 2055 if (ts && (ts != target_p->tsinfo))
86 michael 1159 return;
87    
88 michael 2056 setmodes = target_p->umodes;
89 michael 1809
90 michael 2055 for (m = modes; *m; ++m)
91 michael 1159 {
92     switch (*m)
93     {
94     case '+':
95     what = MODE_ADD;
96     break;
97     case '-':
98     what = MODE_DEL;
99     break;
100 michael 1163
101     case 'd':
102 michael 2055 if (!EmptyString(extarg))
103 michael 1559 strlcpy(target_p->svid, extarg, sizeof(target_p->svid));
104 michael 1163 break;
105    
106 michael 2056 case 'x':
107 michael 2137 if (!EmptyString(extarg) && valid_hostname(extarg))
108 michael 2145 user_set_hostmask(target_p, extarg, what);
109 michael 2056 break;
110    
111 michael 1159 case 'o':
112 michael 1219 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
113 michael 1159 {
114     ClearOper(target_p);
115     Count.oper--;
116    
117     if (MyConnect(target_p))
118     {
119     dlink_node *dm = NULL;
120    
121 michael 1632 detach_conf(target_p, CONF_OPER);
122 michael 1219 ClrOFlag(target_p);
123 michael 1159 DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
124    
125     if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
126     free_dlink_node(dm);
127     }
128     }
129    
130     break;
131    
132 michael 1163 case 'i':
133     if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
134     {
135     AddUMode(target_p, UMODE_INVISIBLE);
136     ++Count.invisi;
137     }
138    
139     if (what == MODE_DEL && HasUMode(target_p, UMODE_INVISIBLE))
140     {
141     DelUMode(target_p, UMODE_INVISIBLE);
142     --Count.invisi;
143     }
144    
145     break;
146    
147 michael 2246 case 'S': /* Only servers may set +S in a burst */
148 michael 2511 case 'W': /* Only servers may set +W in a burst */
149 michael 2246 break;
150    
151 michael 1159 default:
152     if ((flag = user_modes[(unsigned char)*m]))
153 michael 2022 {
154     if (what == MODE_ADD)
155     AddUMode(target_p, flag);
156     else
157     DelUMode(target_p, flag);
158     }
159    
160 michael 1159 break;
161     }
162     }
163    
164     if (extarg)
165     {
166 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
167 michael 1159 ":%s SVSMODE %s %lu %s %s", ID(source_p),
168 michael 2055 ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg);
169 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
170 michael 1159 ":%s SVSMODE %s %lu %s %s", source_p->name,
171 michael 2055 target_p->name, (unsigned long)target_p->tsinfo, modes, extarg);
172 michael 1159 }
173     else
174     {
175 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
176 michael 1159 ":%s SVSMODE %s %lu %s", ID(source_p),
177 michael 2055 ID(target_p), (unsigned long)target_p->tsinfo, modes);
178 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
179 michael 1159 ":%s SVSMODE %s %lu %s", source_p->name,
180 michael 2055 target_p->name, (unsigned long)target_p->tsinfo, modes);
181 michael 1159 }
182    
183 michael 2056 if (MyConnect(target_p) && (setmodes != target_p->umodes))
184 michael 1159 {
185     char modebuf[IRCD_BUFSIZE];
186    
187 michael 2056 send_umode(target_p, target_p, setmodes, 0xffffffff, modebuf);
188 michael 1159 }
189     }
190 michael 1230
191     static struct Message svsmode_msgtab = {
192 michael 2055 "SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
193 michael 1230 {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore}
194     };
195    
196     static void
197     module_init(void)
198     {
199     mod_add_cmd(&svsmode_msgtab);
200     }
201    
202     static void
203     module_exit(void)
204     {
205     mod_del_cmd(&svsmode_msgtab);
206     }
207    
208     struct module module_entry = {
209     .node = { NULL, NULL, NULL },
210     .name = NULL,
211     .version = "$Revision$",
212     .handle = NULL,
213     .modinit = module_init,
214     .modexit = module_exit,
215     .flags = 0
216     };

Properties

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