| 1 |
/* |
| 2 |
* Copyright (c) 2006 William Pitcock, et al. |
| 3 |
* Rights to this code are documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* This file contains routines to handle the OperServ SET command. |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "atheme.h" |
| 10 |
#include <limits.h> |
| 11 |
|
| 12 |
DECLARE_MODULE_V1 |
| 13 |
( |
| 14 |
"operserv/set", false, _modinit, _moddeinit, |
| 15 |
PACKAGE_STRING, |
| 16 |
VENDOR_STRING |
| 17 |
); |
| 18 |
|
| 19 |
static void os_help_set(sourceinfo_t *si, const char *subcmd); |
| 20 |
static void os_cmd_set(sourceinfo_t *si, int parc, char *parv[]); |
| 21 |
static void os_cmd_set_recontime(sourceinfo_t *si, int parc, char *parv[]); |
| 22 |
static void os_cmd_set_maxlogins(sourceinfo_t *si, int parc, char *parv[]); |
| 23 |
static void os_cmd_set_maxnicks(sourceinfo_t *si, int parc, char *parv[]); |
| 24 |
static void os_cmd_set_maxusers(sourceinfo_t *si, int parc, char *parv[]); |
| 25 |
static void os_cmd_set_maxchans(sourceinfo_t *si, int parc, char *parv[]); |
| 26 |
static void os_cmd_set_mdlimit(sourceinfo_t *si, int parc, char *parv[]); |
| 27 |
static void os_cmd_set_klinetime(sourceinfo_t *si, int parc, char *parv[]); |
| 28 |
static void os_cmd_set_commitinterval(sourceinfo_t *si, int parc, char *parv[]); |
| 29 |
static void os_cmd_set_chanexpire(sourceinfo_t *si, int parc, char *parv[]); |
| 30 |
static void os_cmd_set_maxchanacs(sourceinfo_t *si, int parc, char *parv[]); |
| 31 |
static void os_cmd_set_maxfounders(sourceinfo_t *si, int parc, char *parv[]); |
| 32 |
static void os_cmd_set_akicktime(sourceinfo_t *si, int parc, char *parv[]); |
| 33 |
static void os_cmd_set_spam(sourceinfo_t *si, int parc, char *parv[]); |
| 34 |
static void os_cmd_set_nickexpire(sourceinfo_t *si, int parc, char *parv[]); |
| 35 |
static void os_cmd_set_enforceprefix(sourceinfo_t *si, int parc, char *parv[]); |
| 36 |
|
| 37 |
command_t os_set = { "SET", N_("Sets various control flags."), PRIV_ADMIN, 2, os_cmd_set, { .func = os_help_set } }; |
| 38 |
command_t os_set_recontime = { "RECONTIME", N_("Changes IRCd reconnect delay."), AC_NONE, 1, os_cmd_set_recontime, { .path = "oservice/set_recontime" } }; |
| 39 |
command_t os_set_maxlogins = { "MAXLOGINS", N_("Changes the maximum number of users that may be logged in to one account."), AC_NONE, 1, os_cmd_set_maxlogins, { .path = "oservice/set_maxlogins" } }; |
| 40 |
command_t os_set_maxnicks = { "MAXNICKS", N_("Changes the maximum number of nicks that one account may own."), AC_NONE, 1, os_cmd_set_maxnicks, { .path = "oservice/set_maxnicks" } }; |
| 41 |
command_t os_set_maxusers = { "MAXUSERS", N_("Changes the maximum number of accounts that one email address may have registered."), AC_NONE, 1, os_cmd_set_maxusers, { .path = "oservice/set_maxusers" } }; |
| 42 |
command_t os_set_maxchans = { "MAXCHANS", N_("Changes the maximum number of channels one account may own."), AC_NONE, 1, os_cmd_set_maxchans, { .path = "oservice/set_maxchans" } }; |
| 43 |
command_t os_set_mdlimit = { "MDLIMIT", N_("Sets the maximum amount of metadata one channel or account may have."), AC_NONE, 1, os_cmd_set_mdlimit, { .path = "oservice/set_mdlimit" } }; |
| 44 |
command_t os_set_klinetime = { "KLINETIME", N_("Sets the default KLINE/AKILL time."), AC_NONE, 1, os_cmd_set_klinetime, { .path = "oservice/set_klinetime" } }; |
| 45 |
command_t os_set_commitinterval = { "COMMITINTERVAL", N_("Changes how often the database is written to disk."), AC_NONE, 1, os_cmd_set_commitinterval, { .path = "oservice/set_commitinterval" } }; |
| 46 |
command_t os_set_chanexpire = { "CHANEXPIRE", N_("Sets when unused channels expire."), AC_NONE, 1, os_cmd_set_chanexpire, { .path = "oservice/set_chanexpire" } }; |
| 47 |
command_t os_set_maxchanacs = { "MAXCHANACS", N_("Changes the maximum number of channel access list entries per channel."), AC_NONE, 1, os_cmd_set_maxchanacs, { .path = "oservice/set_maxchanacs" } }; |
| 48 |
command_t os_set_maxfounders = { "MAXFOUNDERS", N_("Sets the maximum number of founders per channel."), AC_NONE, 1, os_cmd_set_maxfounders, { .path = "oservice/set_maxfounders" } }; |
| 49 |
command_t os_set_akicktime = { "AKICKTIME", N_("Sets the default AKICK time."), AC_NONE, 1, os_cmd_set_akicktime, { .path = "oservice/set_akicktime" } }; |
| 50 |
command_t os_set_spam = { "SPAM", N_("Changes whether service spams unregistered users on connect."), AC_NONE, 1, os_cmd_set_spam, { .path = "oservice/set_spam" } }; |
| 51 |
command_t os_set_nickexpire = { "NICKEXPIRE", N_("Sets when unused nicks and accounts expire."), AC_NONE, 1, os_cmd_set_nickexpire, { .path = "oservice/set_nickexpire" } }; |
| 52 |
command_t os_set_enforceprefix = { "ENFORCEPREFIX", N_("Changes the prefix to use when changing the user's nick on enforcement."), AC_NONE, 1, os_cmd_set_enforceprefix, { .path = "oservice/set_enforceprefix" } }; |
| 53 |
|
| 54 |
mowgli_patricia_t *os_set_cmdtree; |
| 55 |
|
| 56 |
/* HELP SET */ |
| 57 |
static void os_help_set(sourceinfo_t *si, const char *subcmd) |
| 58 |
{ |
| 59 |
if (!subcmd) |
| 60 |
{ |
| 61 |
command_success_nodata(si, _("***** \2%s Help\2 *****"), si->service->nick); |
| 62 |
command_success_nodata(si, _("Help for \2SET\2:")); |
| 63 |
command_success_nodata(si, " "); |
| 64 |
command_success_nodata(si, _("SET allows you to set various control flags\n" |
| 65 |
"for services that changes the way certain\n" |
| 66 |
"operations are performed.")); |
| 67 |
command_success_nodata(si, _("Note that all settings will be reset to the values\n" |
| 68 |
"in the configuration file on rehash or services restart.")); |
| 69 |
command_success_nodata(si, " "); |
| 70 |
command_help(si, os_set_cmdtree); |
| 71 |
command_success_nodata(si, " "); |
| 72 |
command_success_nodata(si, _("For more information, use \2/msg %s HELP SET \37command\37\2."), si->service->nick); |
| 73 |
command_success_nodata(si, _("***** \2End of Help\2 *****")); |
| 74 |
} |
| 75 |
else |
| 76 |
help_display_as_subcmd(si, si->service, "SET", subcmd, os_set_cmdtree); |
| 77 |
} |
| 78 |
|
| 79 |
/* SET <setting> <parameters> */ |
| 80 |
static void os_cmd_set(sourceinfo_t *si, int parc, char *parv[]) |
| 81 |
{ |
| 82 |
char *setting = parv[0]; |
| 83 |
command_t *c; |
| 84 |
|
| 85 |
if (setting == NULL) |
| 86 |
{ |
| 87 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "SET"); |
| 88 |
command_fail(si, fault_needmoreparams, _("Syntax: SET <setting> <parameters>")); |
| 89 |
return; |
| 90 |
} |
| 91 |
|
| 92 |
/* take the command through the hash table */ |
| 93 |
if ((c = command_find(os_set_cmdtree, setting))) |
| 94 |
{ |
| 95 |
command_exec(si->service, si, c, parc - 1, parv + 1); |
| 96 |
} |
| 97 |
else |
| 98 |
{ |
| 99 |
command_fail(si, fault_badparams, _("Invalid set command. Use \2/%s%s HELP SET\2 for a command listing."), (ircd->uses_rcommand == false) ? "msg " : "", si->service->nick); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
static void os_cmd_set_recontime(sourceinfo_t *si, int parc, char *parv[]) |
| 104 |
{ |
| 105 |
char *recontime = parv[0]; |
| 106 |
|
| 107 |
if (!recontime) |
| 108 |
{ |
| 109 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "RECONTIME"); |
| 110 |
command_fail(si, fault_needmoreparams, _("Syntax: SET RECONTIME <seconds>")); |
| 111 |
return; |
| 112 |
} |
| 113 |
|
| 114 |
int value = atoi(recontime); |
| 115 |
|
| 116 |
if (value < 0) |
| 117 |
{ |
| 118 |
command_fail(si, fault_badparams, _("RECONTIME must be a positive integer, %s is invalid"), recontime); |
| 119 |
return; |
| 120 |
} |
| 121 |
else |
| 122 |
{ |
| 123 |
me.recontime = value; |
| 124 |
command_success_nodata(si, "RECONTIME has been successfully set to %s seconds.", recontime); |
| 125 |
logcommand(si, CMDLOG_ADMIN, "SET:RECONTIME: \2%s\2", recontime); |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
static void os_cmd_set_maxlogins(sourceinfo_t *si, int parc, char *parv[]) |
| 130 |
{ |
| 131 |
char *logins = parv[0]; |
| 132 |
|
| 133 |
if (!logins) |
| 134 |
{ |
| 135 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MAXLOGINS"); |
| 136 |
command_fail(si, fault_needmoreparams, _("Syntax: SET MAXLOGINS <value>")); |
| 137 |
return; |
| 138 |
} |
| 139 |
|
| 140 |
int value = atoi(logins); |
| 141 |
|
| 142 |
if (value < 3 || value > INT_MAX) |
| 143 |
{ |
| 144 |
command_fail(si, fault_badparams, _("%s is invalid for MAXLOGINS value."), logins); |
| 145 |
return; |
| 146 |
} |
| 147 |
else |
| 148 |
{ |
| 149 |
me.maxlogins = value; |
| 150 |
command_success_nodata(si, "MAXLOGINS has been successfully set to %s.", logins); |
| 151 |
logcommand(si, CMDLOG_ADMIN, "SET:MAXLOGINS: \2%s\2", logins); |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
static void os_cmd_set_maxusers(sourceinfo_t *si, int parc, char *parv[]) |
| 156 |
{ |
| 157 |
char *users = parv[0]; |
| 158 |
|
| 159 |
if (!users) |
| 160 |
{ |
| 161 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MAXUSERS"); |
| 162 |
command_fail(si, fault_needmoreparams, _("Syntax: SET MAXUSERS <value>")); |
| 163 |
return; |
| 164 |
} |
| 165 |
|
| 166 |
int value = atoi(users); |
| 167 |
|
| 168 |
if (value < 0 || value > INT_MAX) |
| 169 |
{ |
| 170 |
command_fail(si, fault_badparams, _("%s is invalid for MAXUSERS value."), users); |
| 171 |
return; |
| 172 |
} |
| 173 |
else |
| 174 |
{ |
| 175 |
me.maxusers = value; |
| 176 |
command_success_nodata(si, "MAXUSERS has been successfully set to %s.", users); |
| 177 |
logcommand(si, CMDLOG_ADMIN, "SET:MAXUSERS: \2%s\2", users); |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
static void os_cmd_set_maxnicks(sourceinfo_t *si, int parc, char *parv[]) |
| 182 |
{ |
| 183 |
char *nicks = parv[0]; |
| 184 |
|
| 185 |
if (!nicks) |
| 186 |
{ |
| 187 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MAXNICKS"); |
| 188 |
command_fail(si, fault_needmoreparams, _("Syntax: SET MAXNICKS <value>")); |
| 189 |
return; |
| 190 |
} |
| 191 |
|
| 192 |
int value = atoi(nicks); |
| 193 |
|
| 194 |
if (value < 1 || value > INT_MAX) |
| 195 |
{ |
| 196 |
command_fail(si, fault_badparams, _("%s is invalid for MAXNICKS value."), nicks); |
| 197 |
return; |
| 198 |
} |
| 199 |
else |
| 200 |
{ |
| 201 |
nicksvs.maxnicks = value; |
| 202 |
command_success_nodata(si, "MAXNICKS has been successfully set to %s.", nicks); |
| 203 |
logcommand(si, CMDLOG_ADMIN, "SET:MAXNICKS: \2%s\2", nicks); |
| 204 |
} |
| 205 |
} |
| 206 |
|
| 207 |
static void os_cmd_set_maxchans(sourceinfo_t *si, int parc, char *parv[]) |
| 208 |
{ |
| 209 |
char *chans = parv[0]; |
| 210 |
|
| 211 |
if (!chans) |
| 212 |
{ |
| 213 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MAXCHANS"); |
| 214 |
command_fail(si, fault_needmoreparams, _("Syntax: SET MAXCHANS <value>")); |
| 215 |
return; |
| 216 |
} |
| 217 |
|
| 218 |
int value = atoi(chans); |
| 219 |
|
| 220 |
if (value < 1 || value > INT_MAX) |
| 221 |
{ |
| 222 |
command_fail(si, fault_badparams, _("%s is invalid for MAXCHANS value."), chans); |
| 223 |
return; |
| 224 |
} |
| 225 |
else |
| 226 |
{ |
| 227 |
chansvs.maxchans = value; |
| 228 |
command_success_nodata(si, "MAXCHANS has been successfully set to %s.", chans); |
| 229 |
logcommand(si, CMDLOG_ADMIN, "SET:MAXCHANS: \2%s\2", chans); |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
static void os_cmd_set_mdlimit(sourceinfo_t *si, int parc, char *parv[]) |
| 234 |
{ |
| 235 |
char *limit = parv[0]; |
| 236 |
|
| 237 |
if (!limit) |
| 238 |
{ |
| 239 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MDLIMIT"); |
| 240 |
command_fail(si, fault_needmoreparams, _("Syntax: SET MDLIMIT <value>")); |
| 241 |
return; |
| 242 |
} |
| 243 |
|
| 244 |
int value = atoi(limit); |
| 245 |
|
| 246 |
if (value < 1 || value > INT_MAX) |
| 247 |
{ |
| 248 |
command_fail(si, fault_badparams, _("%s is invalid for MDLIMIT value."), limit); |
| 249 |
return; |
| 250 |
} |
| 251 |
else |
| 252 |
{ |
| 253 |
me.mdlimit = value; |
| 254 |
command_success_nodata(si, "MDLIMIT has been successfully set to %s.", limit); |
| 255 |
logcommand(si, CMDLOG_ADMIN, "SET:MDLIMIT: \2%s\2", limit); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
static void os_cmd_set_klinetime(sourceinfo_t *si, int parc, char *parv[]) |
| 260 |
{ |
| 261 |
char *days = parv[0]; |
| 262 |
|
| 263 |
if (!days) |
| 264 |
{ |
| 265 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "KLINETIME"); |
| 266 |
command_fail(si, fault_needmoreparams, _("Syntax: SET KLINETIME <days>")); |
| 267 |
return; |
| 268 |
} |
| 269 |
|
| 270 |
int value = atoi(days); |
| 271 |
|
| 272 |
if (value < 0) |
| 273 |
{ |
| 274 |
command_fail(si, fault_badparams, _("KLINETIME must be a positive integer, %s is invalid"), days); |
| 275 |
return; |
| 276 |
} |
| 277 |
else |
| 278 |
{ |
| 279 |
unsigned int realvalue = value * 24 * 60 * 60; |
| 280 |
config_options.kline_time = realvalue; |
| 281 |
command_success_nodata(si, "KLINETIME has been successfully set to %s days.", days); |
| 282 |
logcommand(si, CMDLOG_ADMIN, "SET:KLINETIME: \2%s\2", days); |
| 283 |
} |
| 284 |
} |
| 285 |
|
| 286 |
static void os_cmd_set_commitinterval(sourceinfo_t *si, int parc, char *parv[]) |
| 287 |
{ |
| 288 |
char *minutes = parv[0]; |
| 289 |
|
| 290 |
if (!minutes) |
| 291 |
{ |
| 292 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "COMMITINTERVAL"); |
| 293 |
command_fail(si, fault_needmoreparams, _("Syntax: SET COMMITINTERVAL <minutes>")); |
| 294 |
return; |
| 295 |
} |
| 296 |
|
| 297 |
int value = atoi(minutes); |
| 298 |
|
| 299 |
if (value < 0) |
| 300 |
{ |
| 301 |
command_fail(si, fault_badparams, _("COMMITINTERVAL must be a positive integer, %s is invalid"), minutes); |
| 302 |
return; |
| 303 |
} |
| 304 |
else |
| 305 |
{ |
| 306 |
unsigned int realvalue = value * 60; |
| 307 |
config_options.commit_interval = realvalue; |
| 308 |
command_success_nodata(si, "COMMITINTERVAL has been successfully set to %s minutes.", minutes); |
| 309 |
logcommand(si, CMDLOG_ADMIN, "SET:COMMITINTERVAL: \2%s\2", minutes); |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
static void os_cmd_set_chanexpire(sourceinfo_t *si, int parc, char *parv[]) |
| 314 |
{ |
| 315 |
char *days = parv[0]; |
| 316 |
|
| 317 |
if (!days) |
| 318 |
{ |
| 319 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "CHANEXPIRE"); |
| 320 |
command_fail(si, fault_needmoreparams, _("Syntax: SET CHANEXPIRE <days>")); |
| 321 |
return; |
| 322 |
} |
| 323 |
|
| 324 |
int value = atoi(days); |
| 325 |
|
| 326 |
if (value < 0) |
| 327 |
{ |
| 328 |
command_fail(si, fault_badparams, _("CHANEXPIRE must be a positive integer, %s is invalid"), days); |
| 329 |
return; |
| 330 |
} |
| 331 |
else |
| 332 |
{ |
| 333 |
unsigned int realvalue = value * 24 * 60 * 60; |
| 334 |
chansvs.expiry = realvalue; |
| 335 |
command_success_nodata(si, "CHANEXPIRE has been successfully set to %s days.", days); |
| 336 |
logcommand(si, CMDLOG_ADMIN, "SET:CHANEXPIRE: \2%s\2", days); |
| 337 |
} |
| 338 |
} |
| 339 |
|
| 340 |
static void os_cmd_set_maxchanacs(sourceinfo_t *si, int parc, char *parv[]) |
| 341 |
{ |
| 342 |
char *chanacs = parv[0]; |
| 343 |
|
| 344 |
if (!chanacs) |
| 345 |
{ |
| 346 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MAXCHANACS"); |
| 347 |
command_fail(si, fault_needmoreparams, _("Syntax: SET MAXCHANACS <value>")); |
| 348 |
return; |
| 349 |
} |
| 350 |
|
| 351 |
int value = atoi(chanacs); |
| 352 |
|
| 353 |
if (value < 0 || value > INT_MAX) |
| 354 |
{ |
| 355 |
command_fail(si, fault_badparams, _("%s is invalid for MAXCHANACS value."), chanacs); |
| 356 |
return; |
| 357 |
} |
| 358 |
else |
| 359 |
{ |
| 360 |
chansvs.maxchanacs = value; |
| 361 |
command_success_nodata(si, "MAXCHANACS has been successfully set to %s.", chanacs); |
| 362 |
logcommand(si, CMDLOG_ADMIN, "SET:MAXCHANACS: \2%s\2", chanacs); |
| 363 |
} |
| 364 |
} |
| 365 |
|
| 366 |
static void os_cmd_set_maxfounders(sourceinfo_t *si, int parc, char *parv[]) |
| 367 |
{ |
| 368 |
char *founders = parv[0]; |
| 369 |
|
| 370 |
if (!founders) |
| 371 |
{ |
| 372 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MAXFOUNDERS"); |
| 373 |
command_fail(si, fault_needmoreparams, _("Syntax: SET MAXFOUNDERS <value>")); |
| 374 |
return; |
| 375 |
} |
| 376 |
|
| 377 |
int value = atoi(founders); |
| 378 |
|
| 379 |
/* Yes, I know how arbitrary the high value is, this is what it is in confprocess.c |
| 380 |
* (I rounded it down though) -- JD |
| 381 |
*/ |
| 382 |
if (value < 1 || value > 41) |
| 383 |
{ |
| 384 |
command_fail(si, fault_badparams, _("%s is invalid for MAXFOUNDERS value."), founders); |
| 385 |
return; |
| 386 |
} |
| 387 |
else |
| 388 |
{ |
| 389 |
chansvs.maxfounders = value; |
| 390 |
command_success_nodata(si, "MAXFOUNDERS has been successfully set to %s.", founders); |
| 391 |
logcommand(si, CMDLOG_ADMIN, "SET:MAXFOUNDERS: \2%s\2", founders); |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
static void os_cmd_set_akicktime(sourceinfo_t *si, int parc, char *parv[]) |
| 396 |
{ |
| 397 |
char *minutes = parv[0]; |
| 398 |
|
| 399 |
if (!minutes) |
| 400 |
{ |
| 401 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "AKICKTIME"); |
| 402 |
command_fail(si, fault_needmoreparams, _("Syntax: SET AKICKTIME <minutes>")); |
| 403 |
return; |
| 404 |
} |
| 405 |
|
| 406 |
int value = atoi(minutes); |
| 407 |
|
| 408 |
if (value < 0) |
| 409 |
{ |
| 410 |
command_fail(si, fault_badparams, _("AKICKTIME must be a positive integer, %s is invalid"), minutes); |
| 411 |
return; |
| 412 |
} |
| 413 |
else |
| 414 |
{ |
| 415 |
unsigned int realvalue = value * 60; |
| 416 |
chansvs.akick_time = realvalue; |
| 417 |
command_success_nodata(si, "AKICKTIME has been successfully set to %s minutes.", minutes); |
| 418 |
logcommand(si, CMDLOG_ADMIN, "SET:AKICKTIME: \2%s\2", minutes); |
| 419 |
} |
| 420 |
} |
| 421 |
|
| 422 |
static void os_cmd_set_spam(sourceinfo_t *si, int parc, char *parv[]) |
| 423 |
{ |
| 424 |
char *spam = parv[0]; |
| 425 |
|
| 426 |
if (!spam) |
| 427 |
{ |
| 428 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "SPAM"); |
| 429 |
command_fail(si, fault_needmoreparams, _("Syntax: SET SPAM <TRUE|FALSE>")); |
| 430 |
return; |
| 431 |
} |
| 432 |
|
| 433 |
if (!strcasecmp("TRUE", spam) || !strcasecmp("ON", spam)) |
| 434 |
{ |
| 435 |
if (nicksvs.spam) |
| 436 |
{ |
| 437 |
command_fail(si, fault_badparams, _("SPAM directive is already set to %s."), spam); |
| 438 |
return; |
| 439 |
} |
| 440 |
|
| 441 |
nicksvs.spam = true; |
| 442 |
command_success_nodata(si, _("SPAM directive has been successfully set to %s."), spam); |
| 443 |
logcommand(si, CMDLOG_ADMIN, "SET:SPAM:TRUE"); |
| 444 |
return; |
| 445 |
} |
| 446 |
else if (!strcasecmp("FALSE", spam) || !strcasecmp("OFF", spam)) |
| 447 |
{ |
| 448 |
if (!nicksvs.spam) |
| 449 |
{ |
| 450 |
command_fail(si, fault_badparams, _("SPAM directive is already set to %s."), spam); |
| 451 |
return; |
| 452 |
} |
| 453 |
|
| 454 |
nicksvs.spam = false; |
| 455 |
command_success_nodata(si, _("SPAM directive has been successfully set to %s."), spam); |
| 456 |
logcommand(si, CMDLOG_ADMIN, "SET:SPAM:FALSE"); |
| 457 |
return; |
| 458 |
} |
| 459 |
else |
| 460 |
{ |
| 461 |
command_fail(si, fault_badparams, STR_INVALID_PARAMS, "SPAM"); |
| 462 |
return; |
| 463 |
} |
| 464 |
} |
| 465 |
|
| 466 |
static void os_cmd_set_nickexpire(sourceinfo_t *si, int parc, char *parv[]) |
| 467 |
{ |
| 468 |
char *days = parv[0]; |
| 469 |
|
| 470 |
if (!days) |
| 471 |
{ |
| 472 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "NICKEXPIRE"); |
| 473 |
command_fail(si, fault_needmoreparams, _("Syntax: SET NICKEXPIRE <days>")); |
| 474 |
return; |
| 475 |
} |
| 476 |
|
| 477 |
int value = atoi(days); |
| 478 |
|
| 479 |
if (value < 0) |
| 480 |
{ |
| 481 |
command_fail(si, fault_badparams, _("NICKEXPIRE must be a positive integer, %s is invalid"), days); |
| 482 |
return; |
| 483 |
} |
| 484 |
else |
| 485 |
{ |
| 486 |
unsigned int realvalue = value * 24 * 60 * 60; |
| 487 |
nicksvs.expiry = realvalue; |
| 488 |
command_success_nodata(si, "NICKEXPIRE has been successfully set to %s days.", days); |
| 489 |
logcommand(si, CMDLOG_ADMIN, "SET:NICKEXPIRE: \2%s\2", days); |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
static void os_cmd_set_enforceprefix(sourceinfo_t *si, int parc, char *parv[]) |
| 494 |
{ |
| 495 |
char *prefix = parv[0]; |
| 496 |
|
| 497 |
if (!prefix) |
| 498 |
{ |
| 499 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "ENFORCEPREFIX"); |
| 500 |
command_fail(si, fault_needmoreparams, _("Syntax: SET ENFORCEPREFIX <prefix>")); |
| 501 |
return; |
| 502 |
} |
| 503 |
|
| 504 |
nicksvs.enforce_prefix = sstrdup(prefix); |
| 505 |
command_success_nodata(si, "ENFORCEPREFIX has been successfully set to %s.", prefix); |
| 506 |
logcommand(si, CMDLOG_ADMIN, "SET:ENFORCEPREFIX: \2%s\2", prefix); |
| 507 |
} |
| 508 |
|
| 509 |
void _modinit(module_t *m) |
| 510 |
{ |
| 511 |
service_named_bind_command("operserv", &os_set); |
| 512 |
|
| 513 |
os_set_cmdtree = mowgli_patricia_create(strcasecanon); |
| 514 |
command_add(&os_set_recontime, os_set_cmdtree); |
| 515 |
command_add(&os_set_maxlogins, os_set_cmdtree); |
| 516 |
command_add(&os_set_maxnicks, os_set_cmdtree); |
| 517 |
command_add(&os_set_maxusers, os_set_cmdtree); |
| 518 |
command_add(&os_set_maxchans, os_set_cmdtree); |
| 519 |
command_add(&os_set_mdlimit, os_set_cmdtree); |
| 520 |
command_add(&os_set_klinetime, os_set_cmdtree); |
| 521 |
command_add(&os_set_commitinterval, os_set_cmdtree); |
| 522 |
command_add(&os_set_chanexpire, os_set_cmdtree); |
| 523 |
command_add(&os_set_maxchanacs, os_set_cmdtree); |
| 524 |
command_add(&os_set_maxfounders, os_set_cmdtree); |
| 525 |
command_add(&os_set_akicktime, os_set_cmdtree); |
| 526 |
command_add(&os_set_spam, os_set_cmdtree); |
| 527 |
command_add(&os_set_nickexpire, os_set_cmdtree); |
| 528 |
command_add(&os_set_enforceprefix, os_set_cmdtree); |
| 529 |
} |
| 530 |
|
| 531 |
void _moddeinit(module_unload_intent_t intent) |
| 532 |
{ |
| 533 |
service_named_unbind_command("operserv", &os_set); |
| 534 |
command_delete(&os_set_recontime, os_set_cmdtree); |
| 535 |
command_delete(&os_set_maxlogins, os_set_cmdtree); |
| 536 |
command_delete(&os_set_maxnicks, os_set_cmdtree); |
| 537 |
command_delete(&os_set_maxusers, os_set_cmdtree); |
| 538 |
command_delete(&os_set_maxchans, os_set_cmdtree); |
| 539 |
command_delete(&os_set_mdlimit, os_set_cmdtree); |
| 540 |
command_delete(&os_set_klinetime, os_set_cmdtree); |
| 541 |
command_delete(&os_set_commitinterval, os_set_cmdtree); |
| 542 |
command_delete(&os_set_chanexpire, os_set_cmdtree); |
| 543 |
command_delete(&os_set_maxchanacs, os_set_cmdtree); |
| 544 |
command_delete(&os_set_maxfounders, os_set_cmdtree); |
| 545 |
command_delete(&os_set_akicktime, os_set_cmdtree); |
| 546 |
command_delete(&os_set_spam, os_set_cmdtree); |
| 547 |
command_delete(&os_set_nickexpire, os_set_cmdtree); |
| 548 |
command_delete(&os_set_enforceprefix, os_set_cmdtree); |
| 549 |
mowgli_patricia_destroy(os_set_cmdtree, NULL, NULL); |
| 550 |
} |
| 551 |
|
| 552 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
| 553 |
* vim:ts=8 |
| 554 |
* vim:sw=8 |
| 555 |
* vim:noexpandtab |
| 556 |
*/ |