| 25 |
|
/* rewritten by jdc */ |
| 26 |
|
|
| 27 |
|
#include "stdinc.h" |
| 28 |
– |
#include "handlers.h" |
| 28 |
|
#include "client.h" |
| 29 |
|
#include "event.h" |
| 30 |
|
#include "irc_string.h" |
| 34 |
|
#include "s_bsd.h" |
| 35 |
|
#include "s_serv.h" |
| 36 |
|
#include "send.h" |
| 38 |
– |
#include "common.h" /* for NO */ |
| 37 |
|
#include "channel.h" |
| 38 |
< |
#include "s_log.h" |
| 41 |
< |
#include "s_conf.h" |
| 42 |
< |
#include "msg.h" |
| 38 |
> |
#include "conf.h" |
| 39 |
|
#include "parse.h" |
| 40 |
|
#include "modules.h" |
| 41 |
|
#include "s_user.h" |
| 42 |
+ |
#include "s_misc.h" |
| 43 |
|
|
| 44 |
|
|
| 48 |
– |
static void mo_set(struct Client *, struct Client *, int, char *[]); |
| 49 |
– |
|
| 50 |
– |
struct Message set_msgtab = { |
| 51 |
– |
"SET", 0, 0, 0, 0, MFLG_SLOW, 0, |
| 52 |
– |
{m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore} |
| 53 |
– |
}; |
| 54 |
– |
|
| 55 |
– |
void |
| 56 |
– |
_modinit(void) |
| 57 |
– |
{ |
| 58 |
– |
mod_add_cmd(&set_msgtab); |
| 59 |
– |
} |
| 60 |
– |
|
| 61 |
– |
void |
| 62 |
– |
_moddeinit(void) |
| 63 |
– |
{ |
| 64 |
– |
mod_del_cmd(&set_msgtab); |
| 65 |
– |
} |
| 66 |
– |
|
| 67 |
– |
const char *_version = "$Revision$"; |
| 68 |
– |
|
| 45 |
|
/* Structure used for the SET table itself */ |
| 46 |
|
struct SetStruct |
| 47 |
|
{ |
| 57 |
|
static void quote_autoconnall(struct Client *, int); |
| 58 |
|
static void quote_floodcount(struct Client *, int); |
| 59 |
|
static void quote_identtimeout(struct Client *, int); |
| 84 |
– |
static void quote_idletime(struct Client *, int); |
| 85 |
– |
static void quote_log(struct Client *, int); |
| 60 |
|
static void quote_max(struct Client *, int); |
| 61 |
|
static void quote_msglocale(struct Client *, char *); |
| 62 |
|
static void quote_spamnum(struct Client *, int); |
| 67 |
|
static void list_quote_commands(struct Client *); |
| 68 |
|
static void quote_jfloodtime(struct Client *, int); |
| 69 |
|
static void quote_jfloodcount(struct Client *, int); |
| 96 |
– |
static void quote_rejecttime(struct Client *, int); |
| 70 |
|
|
| 71 |
|
/* |
| 72 |
|
* If this ever needs to be expanded to more than one arg of each |
| 84 |
|
{ "AUTOCONNALL", quote_autoconnall, 0, 1 }, |
| 85 |
|
{ "FLOODCOUNT", quote_floodcount, 0, 1 }, |
| 86 |
|
{ "IDENTTIMEOUT", quote_identtimeout, 0, 1 }, |
| 114 |
– |
{ "IDLETIME", quote_idletime, 0, 1 }, |
| 115 |
– |
{ "LOG", quote_log, 0, 1 }, |
| 87 |
|
{ "MAX", quote_max, 0, 1 }, |
| 88 |
|
{ "MSGLOCALE", quote_msglocale, 1, 0 }, |
| 89 |
|
{ "SPAMNUM", quote_spamnum, 0, 1 }, |
| 93 |
|
{ "SPLITUSERS", quote_splitusers, 0, 1 }, |
| 94 |
|
{ "JFLOODTIME", quote_jfloodtime, 0, 1 }, |
| 95 |
|
{ "JFLOODCOUNT", quote_jfloodcount, 0, 1 }, |
| 125 |
– |
{ "REJECTTIME", quote_rejecttime, 0, 1 }, |
| 96 |
|
/* -------------------------------------------------------- */ |
| 97 |
|
{ NULL, NULL, 0, 0 } |
| 98 |
|
}; |
| 138 |
|
static void |
| 139 |
|
quote_autoconn(struct Client *source_p, const char *arg, int newval) |
| 140 |
|
{ |
| 171 |
– |
struct AccessItem *aconf; |
| 172 |
– |
|
| 141 |
|
if (arg != NULL) |
| 142 |
|
{ |
| 143 |
< |
struct ConfItem *conf = find_exact_name_conf(SERVER_TYPE, arg, NULL, NULL); |
| 143 |
> |
struct MaskItem *conf = find_exact_name_conf(CONF_SERVER, NULL, arg, NULL, NULL); |
| 144 |
|
|
| 145 |
|
if (conf != NULL) |
| 146 |
|
{ |
| 179 |
– |
aconf = map_to_conf(conf); |
| 147 |
|
if (newval) |
| 148 |
< |
SetConfAllowAutoConn(aconf); |
| 148 |
> |
SetConfAllowAutoConn(conf); |
| 149 |
|
else |
| 150 |
< |
ClearConfAllowAutoConn(aconf); |
| 150 |
> |
ClearConfAllowAutoConn(conf); |
| 151 |
|
|
| 152 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 152 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 153 |
|
"%s has changed AUTOCONN for %s to %i", |
| 154 |
|
get_oper_name(source_p), arg, newval); |
| 155 |
|
sendto_one(source_p, |
| 175 |
|
{ |
| 176 |
|
if (newval >= 0) |
| 177 |
|
{ |
| 178 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed AUTOCONNALL to %i", |
| 178 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 179 |
> |
"%s has changed AUTOCONNALL to %i", |
| 180 |
|
get_oper_name(source_p), newval); |
| 181 |
|
|
| 182 |
|
GlobalSetOptions.autoconn = newval; |
| 193 |
|
if (newval >= 0) |
| 194 |
|
{ |
| 195 |
|
GlobalSetOptions.floodcount = newval; |
| 196 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 196 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 197 |
|
"%s has changed FLOODCOUNT to %i", |
| 198 |
|
get_oper_name(source_p), GlobalSetOptions.floodcount); |
| 199 |
|
} |
| 206 |
|
static void |
| 207 |
|
quote_identtimeout(struct Client *source_p, int newval) |
| 208 |
|
{ |
| 209 |
< |
if (!IsAdmin(source_p)) |
| 209 |
> |
if (!HasUMode(source_p, UMODE_ADMIN)) |
| 210 |
|
{ |
| 211 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 212 |
|
me.name, source_p->name, "set"); |
| 215 |
|
|
| 216 |
|
if (newval > 0) |
| 217 |
|
{ |
| 218 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 219 |
< |
"%s has changed IDENTTIMEOUT to %d", |
| 220 |
< |
get_oper_name(source_p), newval); |
| 218 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 219 |
> |
"%s has changed IDENTTIMEOUT to %d", |
| 220 |
> |
get_oper_name(source_p), newval); |
| 221 |
|
GlobalSetOptions.ident_timeout = newval; |
| 222 |
|
} |
| 223 |
|
else |
| 224 |
|
sendto_one(source_p, ":%s NOTICE %s :IDENTTIMEOUT is currently %d", |
| 225 |
< |
me.name, source_p->name, GlobalSetOptions.ident_timeout); |
| 258 |
< |
} |
| 259 |
< |
|
| 260 |
< |
/* SET IDLETIME */ |
| 261 |
< |
static void |
| 262 |
< |
quote_idletime(struct Client *source_p, int newval) |
| 263 |
< |
{ |
| 264 |
< |
if (newval >= 0) |
| 265 |
< |
{ |
| 266 |
< |
if (newval == 0) |
| 267 |
< |
{ |
| 268 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 269 |
< |
"%s has disabled idletime checking", |
| 270 |
< |
get_oper_name(source_p)); |
| 271 |
< |
GlobalSetOptions.idletime = 0; |
| 272 |
< |
} |
| 273 |
< |
else |
| 274 |
< |
{ |
| 275 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 276 |
< |
"%s has changed IDLETIME to %i", |
| 277 |
< |
get_oper_name(source_p), newval); |
| 278 |
< |
GlobalSetOptions.idletime = (newval * 60); |
| 279 |
< |
} |
| 280 |
< |
} |
| 281 |
< |
else |
| 282 |
< |
{ |
| 283 |
< |
sendto_one(source_p, ":%s NOTICE %s :IDLETIME is currently %i", |
| 284 |
< |
me.name, source_p->name, GlobalSetOptions.idletime/60); |
| 285 |
< |
} |
| 286 |
< |
} |
| 287 |
< |
|
| 288 |
< |
/* SET LOG */ |
| 289 |
< |
static void |
| 290 |
< |
quote_log(struct Client *source_p, int newval) |
| 291 |
< |
{ |
| 292 |
< |
if (newval >= 0) |
| 293 |
< |
{ |
| 294 |
< |
if (newval < L_WARN) |
| 295 |
< |
{ |
| 296 |
< |
sendto_one(source_p, ":%s NOTICE %s :LOG must be > %d (L_WARN)", |
| 297 |
< |
me.name, source_p->name, L_WARN); |
| 298 |
< |
return; |
| 299 |
< |
} |
| 300 |
< |
|
| 301 |
< |
if (newval > L_DEBUG) |
| 302 |
< |
newval = L_DEBUG; |
| 303 |
< |
|
| 304 |
< |
set_log_level(newval); |
| 305 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed LOG level to %i (%s)", |
| 306 |
< |
get_oper_name(source_p), get_log_level(), |
| 307 |
< |
get_log_level_as_string(get_log_level())); |
| 308 |
< |
} |
| 309 |
< |
else |
| 310 |
< |
sendto_one(source_p, ":%s NOTICE %s :LOG level is currently %i (%s)", |
| 311 |
< |
me.name, source_p->name, get_log_level(), |
| 312 |
< |
get_log_level_as_string(get_log_level())); |
| 225 |
> |
me.name, source_p->name, GlobalSetOptions.ident_timeout); |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
/* SET MAX */ |
| 231 |
|
{ |
| 232 |
|
if (newval > 0) |
| 233 |
|
{ |
| 321 |
– |
recalc_fdlimit(NULL); |
| 322 |
– |
|
| 234 |
|
if (newval > MAXCLIENTS_MAX) |
| 235 |
|
{ |
| 236 |
|
sendto_one(source_p, |
| 237 |
|
":%s NOTICE %s :You cannot set MAXCLIENTS to > %d, restoring to %d", |
| 238 |
< |
me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients); |
| 238 |
> |
me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients); |
| 239 |
|
return; |
| 240 |
|
} |
| 241 |
|
|
| 242 |
|
if (newval < MAXCLIENTS_MIN) |
| 243 |
|
{ |
| 244 |
|
sendto_one(source_p, |
| 245 |
< |
":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d", |
| 246 |
< |
me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients); |
| 245 |
> |
":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d", |
| 246 |
> |
me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients); |
| 247 |
|
return; |
| 248 |
|
} |
| 249 |
|
|
| 250 |
|
ServerInfo.max_clients = newval; |
| 251 |
|
|
| 252 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 253 |
< |
"%s set new MAXCLIENTS to %d (%d current)", |
| 254 |
< |
get_oper_name(source_p), source_p->username, source_p->host, |
| 344 |
< |
ServerInfo.max_clients, Count.local); |
| 252 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 253 |
> |
"%s set new MAXCLIENTS to %d (%d current)", |
| 254 |
> |
get_oper_name(source_p), ServerInfo.max_clients, Count.local); |
| 255 |
|
} |
| 256 |
|
else |
| 257 |
|
sendto_one(source_p, ":%s NOTICE %s :Current MAXCLIENTS = %d (%d)", |
| 267 |
|
set_locale(locale); |
| 268 |
|
rebuild_isupport_message_line(); |
| 269 |
|
sendto_one(source_p, ":%s NOTICE %s :Set MSGLOCALE to '%s'", |
| 270 |
< |
me.name, source_p->name, get_locale()); |
| 270 |
> |
me.name, source_p->name, get_locale()); |
| 271 |
|
} |
| 272 |
|
else |
| 273 |
|
sendto_one(source_p, ":%s NOTICE %s :MSGLOCALE is currently '%s'", |
| 274 |
< |
me.name, source_p->name, get_locale()); |
| 274 |
> |
me.name, source_p->name, get_locale()); |
| 275 |
|
} |
| 276 |
|
|
| 277 |
|
/* SET SPAMNUM */ |
| 282 |
|
{ |
| 283 |
|
if (newval == 0) |
| 284 |
|
{ |
| 285 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 285 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 286 |
|
"%s has disabled ANTI_SPAMBOT", source_p->name); |
| 287 |
|
GlobalSetOptions.spam_num = newval; |
| 288 |
|
return; |
| 289 |
|
} |
| 290 |
|
|
| 291 |
|
GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM); |
| 292 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMNUM to %i", |
| 292 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 293 |
> |
"%s has changed SPAMNUM to %i", |
| 294 |
|
get_oper_name(source_p), GlobalSetOptions.spam_num); |
| 295 |
|
} |
| 296 |
|
else |
| 305 |
|
if (newval > 0) |
| 306 |
|
{ |
| 307 |
|
GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME); |
| 308 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i", |
| 308 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 309 |
> |
"%s has changed SPAMTIME to %i", |
| 310 |
|
get_oper_name(source_p), GlobalSetOptions.spam_time); |
| 311 |
|
} |
| 312 |
|
else |
| 348 |
|
/* OFF */ |
| 349 |
|
if (newval == 0) |
| 350 |
|
{ |
| 351 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 351 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 352 |
|
"%s is disabling splitmode", |
| 353 |
|
get_oper_name(source_p)); |
| 354 |
|
|
| 360 |
|
/* ON */ |
| 361 |
|
else if (newval == 1) |
| 362 |
|
{ |
| 363 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 363 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 364 |
|
"%s is enabling and activating splitmode", |
| 365 |
< |
get_oper_name(source_p)); |
| 366 |
< |
|
| 365 |
> |
get_oper_name(source_p)); |
| 366 |
> |
|
| 367 |
|
splitmode = 1; |
| 368 |
|
splitchecking = 0; |
| 369 |
|
|
| 373 |
|
/* AUTO */ |
| 374 |
|
else if (newval == 2) |
| 375 |
|
{ |
| 376 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 376 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 377 |
|
"%s is enabling automatic splitmode", |
| 378 |
< |
get_oper_name(source_p)); |
| 378 |
> |
get_oper_name(source_p)); |
| 379 |
|
|
| 380 |
|
splitchecking = 1; |
| 381 |
|
check_splitmode(NULL); |
| 388 |
|
*/ |
| 389 |
|
sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %s", |
| 390 |
|
me.name, source_p->name, |
| 391 |
< |
splitmode_status[(splitchecking + (splitmode * 2))]); |
| 391 |
> |
splitmode_status[(splitchecking + (splitmode * 2))]); |
| 392 |
|
} |
| 393 |
|
|
| 394 |
|
/* SET SPLITNUM */ |
| 397 |
|
{ |
| 398 |
|
if (newval >= 0) |
| 399 |
|
{ |
| 400 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 400 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 401 |
|
"%s has changed SPLITNUM to %i", |
| 402 |
< |
get_oper_name(source_p), newval); |
| 402 |
> |
get_oper_name(source_p), newval); |
| 403 |
|
split_servers = newval; |
| 404 |
|
|
| 405 |
|
if (splitchecking) |
| 416 |
|
{ |
| 417 |
|
if (newval >= 0) |
| 418 |
|
{ |
| 419 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 419 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 420 |
|
"%s has changed SPLITUSERS to %i", |
| 421 |
< |
get_oper_name(source_p), newval); |
| 421 |
> |
get_oper_name(source_p), newval); |
| 422 |
|
split_users = newval; |
| 423 |
|
|
| 424 |
|
if (splitchecking) |
| 435 |
|
{ |
| 436 |
|
if (newval >= 0) |
| 437 |
|
{ |
| 438 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 438 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 439 |
|
"%s has changed JFLOODTIME to %i", |
| 440 |
< |
get_oper_name(source_p), newval); |
| 440 |
> |
get_oper_name(source_p), newval); |
| 441 |
|
GlobalSetOptions.joinfloodtime = newval; |
| 442 |
|
} |
| 443 |
|
else |
| 451 |
|
{ |
| 452 |
|
if (newval >= 0) |
| 453 |
|
{ |
| 454 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 454 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 455 |
|
"%s has changed JFLOODCOUNT to %i", |
| 456 |
< |
get_oper_name(source_p), newval); |
| 456 |
> |
get_oper_name(source_p), newval); |
| 457 |
|
GlobalSetOptions.joinfloodcount = newval; |
| 458 |
|
} |
| 459 |
|
else |
| 461 |
|
me.name, source_p->name, GlobalSetOptions.joinfloodcount); |
| 462 |
|
} |
| 463 |
|
|
| 552 |
– |
/* SET REJECTTIME */ |
| 553 |
– |
static void |
| 554 |
– |
quote_rejecttime(struct Client *source_p, int newval) |
| 555 |
– |
{ |
| 556 |
– |
if (newval >= 0) |
| 557 |
– |
{ |
| 558 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 559 |
– |
"%s has changed REJECTTIME to %i seconds", |
| 560 |
– |
get_oper_name(source_p), newval); |
| 561 |
– |
GlobalSetOptions.rejecttime = newval; |
| 562 |
– |
} |
| 563 |
– |
else |
| 564 |
– |
sendto_one(source_p, ":%s NOTICE %s :REJECTTIME is currently %i seconds", |
| 565 |
– |
me.name, source_p->name, GlobalSetOptions.rejecttime); |
| 566 |
– |
} |
| 567 |
– |
|
| 464 |
|
/* |
| 465 |
|
* mo_set - SET command handler |
| 466 |
|
* set options while running |
| 475 |
|
const char *intarg = NULL; |
| 476 |
|
const struct SetStruct *tab = set_cmd_table; |
| 477 |
|
|
| 478 |
+ |
if (!HasOFlag(source_p, OPER_FLAG_SET)) |
| 479 |
+ |
{ |
| 480 |
+ |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 481 |
+ |
me.name, source_p->name, "set"); |
| 482 |
+ |
return; |
| 483 |
+ |
} |
| 484 |
+ |
|
| 485 |
|
if (parc > 1) |
| 486 |
|
{ |
| 487 |
|
/* |
| 538 |
|
newval = atoi(intarg); |
| 539 |
|
} |
| 540 |
|
else |
| 638 |
– |
{ |
| 541 |
|
newval = -1; |
| 640 |
– |
} |
| 542 |
|
|
| 543 |
|
if (newval < 0) |
| 544 |
|
{ |
| 585 |
|
|
| 586 |
|
list_quote_commands(source_p); |
| 587 |
|
} |
| 588 |
+ |
|
| 589 |
+ |
static struct Message set_msgtab = { |
| 590 |
+ |
"SET", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 591 |
+ |
{m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore} |
| 592 |
+ |
}; |
| 593 |
+ |
|
| 594 |
+ |
static void |
| 595 |
+ |
module_init(void) |
| 596 |
+ |
{ |
| 597 |
+ |
mod_add_cmd(&set_msgtab); |
| 598 |
+ |
} |
| 599 |
+ |
|
| 600 |
+ |
static void |
| 601 |
+ |
module_exit(void) |
| 602 |
+ |
{ |
| 603 |
+ |
mod_del_cmd(&set_msgtab); |
| 604 |
+ |
} |
| 605 |
+ |
|
| 606 |
+ |
struct module module_entry = { |
| 607 |
+ |
.node = { NULL, NULL, NULL }, |
| 608 |
+ |
.name = NULL, |
| 609 |
+ |
.version = "$Revision$", |
| 610 |
+ |
.handle = NULL, |
| 611 |
+ |
.modinit = module_init, |
| 612 |
+ |
.modexit = module_exit, |
| 613 |
+ |
.flags = 0 |
| 614 |
+ |
}; |