| 26 |
|
*/ |
| 27 |
|
|
| 28 |
|
#include "stdinc.h" |
| 29 |
– |
#include "handlers.h" |
| 29 |
|
#include "client.h" |
| 30 |
|
#include "ircd.h" |
| 31 |
|
#include "numeric.h" |
| 33 |
– |
#include "s_conf.h" |
| 32 |
|
#include "s_serv.h" |
| 33 |
|
#include "send.h" |
| 34 |
|
#include "channel_mode.h" |
| 37 |
– |
#include "msg.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 |
|
|
| 43 |
– |
static void ms_svsmode(struct Client *, struct Client *, int, char *[]); |
| 42 |
|
|
| 43 |
< |
struct Message svsmode_msgtab = { |
| 46 |
< |
"SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0, |
| 47 |
< |
{m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore} |
| 48 |
< |
}; |
| 49 |
< |
|
| 50 |
< |
const char *_version = "$Revision$"; |
| 51 |
< |
|
| 52 |
< |
void |
| 53 |
< |
_modinit(void) |
| 54 |
< |
{ |
| 55 |
< |
mod_add_cmd(&svsmode_msgtab); |
| 56 |
< |
} |
| 57 |
< |
|
| 58 |
< |
void |
| 59 |
< |
_moddeinit(void) |
| 60 |
< |
{ |
| 61 |
< |
mod_del_cmd(&svsmode_msgtab); |
| 62 |
< |
} |
| 63 |
< |
|
| 64 |
< |
|
| 65 |
< |
/*! \brief SVSMODE command handler (called by servers or services) |
| 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. |
| 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 arguement (services id) |
| 55 |
> |
* - parv[2] = TS |
| 56 |
> |
* - parv[3] = mode |
| 57 |
> |
* - parv[4] = optional argument (services id, hostname) |
| 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 |
+ |
const char *m = NULL, *extarg = NULL; |
| 65 |
|
int what = MODE_ADD; |
| 66 |
|
unsigned int flag = 0, setflags = 0; |
| 88 |
– |
char *m = NULL, *modes = NULL, *extarg = NULL; |
| 67 |
|
time_t ts = 0; |
| 68 |
|
|
| 69 |
< |
if (!HasFlag(source_p, FLAGS_SERVICE) || (parc < 3)) |
| 69 |
> |
if (!HasFlag(source_p, FLAGS_SERVICE)) |
| 70 |
|
return; |
| 71 |
|
|
| 94 |
– |
if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-'))) |
| 95 |
– |
{ |
| 96 |
– |
ts = atol(parv[2]); |
| 97 |
– |
modes = parv[3]; |
| 98 |
– |
extarg = (parc > 4) ? parv[4] : NULL; |
| 99 |
– |
} |
| 100 |
– |
else |
| 101 |
– |
{ |
| 102 |
– |
modes = parv[2]; |
| 103 |
– |
extarg = (parc > 3) ? parv[3] : NULL; |
| 104 |
– |
} |
| 105 |
– |
|
| 72 |
|
if ((target_p = find_person(client_p, parv[1])) == NULL) |
| 73 |
|
return; |
| 74 |
|
|
| 75 |
< |
if (ts && (ts != target_p->tsinfo)) |
| 75 |
> |
if ((ts = atol(parv[2])) && (ts != target_p->tsinfo)) |
| 76 |
|
return; |
| 77 |
|
|
| 78 |
+ |
if (parc > 4 && !EmptyString(parv[4])) |
| 79 |
+ |
extarg = parv[4]; |
| 80 |
+ |
|
| 81 |
|
setflags = target_p->umodes; |
| 82 |
|
|
| 83 |
< |
for (m = modes; *m; ++m) |
| 83 |
> |
for (m = parv[3]; *m; ++m) |
| 84 |
|
{ |
| 85 |
|
switch (*m) |
| 86 |
|
{ |
| 92 |
|
break; |
| 93 |
|
|
| 94 |
|
case 'd': |
| 95 |
< |
if (extarg && IsDigit(*extarg)) |
| 96 |
< |
target_p->servicestamp = strtoul(extarg, NULL, 0); |
| 95 |
> |
if (extarg) |
| 96 |
> |
strlcpy(target_p->svid, extarg, sizeof(target_p->svid)); |
| 97 |
> |
break; |
| 98 |
> |
|
| 99 |
> |
case 'x': |
| 100 |
> |
if (what == MODE_ADD && extarg) |
| 101 |
> |
user_set_hostmask(target_p, extarg); |
| 102 |
|
break; |
| 103 |
|
|
| 104 |
|
case 'o': |
| 111 |
|
{ |
| 112 |
|
dlink_node *dm = NULL; |
| 113 |
|
|
| 114 |
< |
detach_conf(target_p, OPER_TYPE); |
| 114 |
> |
detach_conf(target_p, CONF_OPER); |
| 115 |
|
ClrOFlag(target_p); |
| 116 |
|
DelUMode(target_p, ConfigFileEntry.oper_only_umodes); |
| 117 |
|
|
| 144 |
|
break; |
| 145 |
|
default: |
| 146 |
|
if ((flag = user_modes[(unsigned char)*m])) |
| 147 |
< |
execute_callback(umode_cb, client_p, target_p, what, flag); |
| 147 |
> |
{ |
| 148 |
> |
if (what == MODE_ADD) |
| 149 |
> |
AddUMode(target_p, flag); |
| 150 |
> |
else |
| 151 |
> |
DelUMode(target_p, flag); |
| 152 |
> |
} |
| 153 |
> |
|
| 154 |
|
break; |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
if (extarg) |
| 159 |
|
{ |
| 160 |
< |
sendto_server(client_p, NULL, CAP_TS6, NOCAPS, |
| 160 |
> |
sendto_server(client_p, CAP_TS6, NOCAPS, |
| 161 |
|
":%s SVSMODE %s %lu %s %s", ID(source_p), |
| 162 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg); |
| 163 |
< |
sendto_server(client_p, NULL, NOCAPS, CAP_TS6, |
| 162 |
> |
ID(target_p), (unsigned long)target_p->tsinfo, parv[3], extarg); |
| 163 |
> |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 164 |
|
":%s SVSMODE %s %lu %s %s", source_p->name, |
| 165 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes, extarg); |
| 165 |
> |
target_p->name, (unsigned long)target_p->tsinfo, parv[3], extarg); |
| 166 |
|
} |
| 167 |
|
else |
| 168 |
|
{ |
| 169 |
< |
sendto_server(client_p, NULL, CAP_TS6, NOCAPS, |
| 169 |
> |
sendto_server(client_p, CAP_TS6, NOCAPS, |
| 170 |
|
":%s SVSMODE %s %lu %s", ID(source_p), |
| 171 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes); |
| 172 |
< |
sendto_server(client_p, NULL, NOCAPS, CAP_TS6, |
| 171 |
> |
ID(target_p), (unsigned long)target_p->tsinfo, parv[3]); |
| 172 |
> |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 173 |
|
":%s SVSMODE %s %lu %s", source_p->name, |
| 174 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes); |
| 174 |
> |
target_p->name, (unsigned long)target_p->tsinfo, parv[3]); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
if (MyConnect(target_p) && (setflags != target_p->umodes)) |
| 181 |
|
send_umode(target_p, target_p, setflags, 0xffffffff, modebuf); |
| 182 |
|
} |
| 183 |
|
} |
| 184 |
+ |
|
| 185 |
+ |
static struct Message svsmode_msgtab = { |
| 186 |
+ |
"SVSMODE", 0, 0, 4, MAXPARA, MFLG_SLOW, 0, |
| 187 |
+ |
{m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore} |
| 188 |
+ |
}; |
| 189 |
+ |
|
| 190 |
+ |
static void |
| 191 |
+ |
module_init(void) |
| 192 |
+ |
{ |
| 193 |
+ |
mod_add_cmd(&svsmode_msgtab); |
| 194 |
+ |
} |
| 195 |
+ |
|
| 196 |
+ |
static void |
| 197 |
+ |
module_exit(void) |
| 198 |
+ |
{ |
| 199 |
+ |
mod_del_cmd(&svsmode_msgtab); |
| 200 |
+ |
} |
| 201 |
+ |
|
| 202 |
+ |
struct module module_entry = { |
| 203 |
+ |
.node = { NULL, NULL, NULL }, |
| 204 |
+ |
.name = NULL, |
| 205 |
+ |
.version = "$Revision$", |
| 206 |
+ |
.handle = NULL, |
| 207 |
+ |
.modinit = module_init, |
| 208 |
+ |
.modexit = module_exit, |
| 209 |
+ |
.flags = 0 |
| 210 |
+ |
}; |