*
* This file is part of x3.
*
- * srvx is free software; you can redistribute it and/or modify
+ * x3 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
#include "saxdb.h"
#include "shun.h"
+#include <regex.h>
+
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
-#ifdef HAVE_REGEX_H
-#include <regex.h>
-#endif
+
#define OPSERV_CONF_NAME "services/opserv"
#define KEY_NICK "nick"
#define KEY_JOIN_POLICER "join_policer"
#define KEY_NEW_USER_POLICER "new_user_policer"
+#define KEY_AUTOJOIN_CHANNELS "autojoin_channels"
#define KEY_REASON "reason"
#define KEY_RESERVES "reserves"
#define KEY_IDENT "username" /* for compatibility with 1.0 DBs */
#define KEY_ISSUER "issuer"
#define KEY_ISSUED "issued"
#define KEY_ADMIN_LEVEL "admin_level"
+#define KEY_SILENT_LEVEL "silent_level"
#define IDENT_FORMAT "%s [%s@%s/%s]"
#define IDENT_DATA(user) user->nick, user->ident, user->hostname, irc_ntoa(&user->ip)
{ "OSMSG_OPALL_DONE", "Opped everyone on $b%s$b." },
{ "OSMSG_HOP_DONE", "Halfopped the requested lusers." },
{ "OSMSG_HOPALL_DONE", "Halfopped everyone on $b%s$b." },
- { "OSMSG_WHOIS_IDENT", "%s (%s@%s) from %d.%d.%d.%d" },
- { "OSMSG_WHOIS_NICK", "Nick : %s" },
- { "OSMSG_WHOIS_HOST", "Host : %s@%s" },
- { "OSMSG_WHOIS_FAKEHOST", "Fakehost: %s" },
- { "OSMSG_WHOIS_IP", "Real IP : %s" },
- { "OSMSG_WHOIS_MODES", "Modes : +%s " },
- { "OSMSG_WHOIS_INFO", "Info : %s" },
- { "OSMSG_WHOIS_NUMERIC", "Numnick : %s" },
- { "OSMSG_WHOIS_SERVER", "Server : %s" },
- { "OSMSG_WHOIS_NICK_AGE", "Nick Age: %s" },
- { "OSMSG_WHOIS_ACCOUNT", "Account : %s" },
- { "OSMSG_WHOIS_CHANNELS", "Channels: %s" },
- { "OSMSG_WHOIS_HIDECHANS", "Channel list omitted for your sanity." },
+ { "OSMSG_WHOIS_IDENT", "%s (%s@%s) from %d.%d.%d.%d" },
+ { "OSMSG_WHOIS_NICK", "Nick : %s" },
+ { "OSMSG_WHOIS_HOST", "Host : %s@%s" },
+ { "OSMSG_WHOIS_FAKEHOST", "Fakehost : %s" },
+ { "OSMSG_WHOIS_CRYPT_HOST", "Crypt Host : %s" },
+ { "OSMSG_WHOIS_CRYPT_IP", "Crypt IP : %s" },
+ { "OSMSG_WHOIS_IP", "Real IP : %s" },
+ { "OSMSG_WHOIS_MODES", "Modes : +%s " },
+ { "OSMSG_WHOIS_INFO", "Info : %s" },
+ { "OSMSG_WHOIS_NUMERIC", "Numnick : %s" },
+ { "OSMSG_WHOIS_SERVER", "Server : %s" },
+ { "OSMSG_WHOIS_NICK_AGE", "Nick Age : %s" },
+ { "OSMSG_WHOIS_ACCOUNT", "Account : %s" },
+ { "OSMSG_WHOIS_CHANNELS", "Channels : %s" },
+ { "OSMSG_WHOIS_HIDECHANS", "Channel list omitted for your sanity." },
{ "OSMSG_UNBAN_DONE", "Ban(s) removed from channel %s." },
{ "OSMSG_CHANNEL_VOICED", "All users on %s voiced." },
{ "OSMSG_CHANNEL_DEVOICED", "All voiced users on %s de-voiced." },
{ "OSMSG_CSEARCH_CHANNEL_INFO", "%s [%d users] %s %s" },
{ "OSMSG_INVALID_REGEX", "Invalid regex: %s: %s (%d)" },
{ "OSMSG_TRACK_DISABLED", "Tracking is not currently compiled into X3" },
+ { "OSMSG_MAXUSERS_RESET", "Max clients has been reset to $b%d$b" },
{ NULL, NULL }
};
static struct log_type *OS_LOG;
static unsigned int new_user_flood;
static char *level_strings[1001];
+struct string_list *autojoin_channels;
static struct {
struct chanNode *debug_channel;
unsigned long join_flood_moderate;
unsigned long join_flood_moderate_threshold;
unsigned long admin_level;
+ unsigned long silent_level;
} opserv_conf;
struct trusted_host {
int authed : 2, info_space : 2;
unsigned int intra_scmp : 2, intra_dcmp : 2;
unsigned int use_regex : 1;
+ unsigned int silent : 1;
} *discrim_t;
struct discrim_and_source {
typedef enum {
REACT_NOTICE,
REACT_KILL,
- REACT_SILENT,
+// REACT_SILENT,
REACT_GLINE,
REACT_TRACK,
REACT_SHUN
#define opserv_debug(format...) do { if (opserv_conf.debug_channel) send_channel_notice(opserv_conf.debug_channel , opserv , ## format); } while (0)
#define opserv_alert(format...) do { if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel , opserv , ## format); } while (0)
+
/* A lot of these commands are very similar to what ChanServ can do,
* but OpServ can do them even on channels that aren't registered.
*/
return 1;
}
+static MODCMD_FUNC(cmd_resetmax)
+{
+ max_clients = dict_size(clients);
+ max_clients_time = now;
+ reply("OSMSG_MAXUSERS_RESET", max_clients);
+ return 1;
+}
+
static MODCMD_FUNC(cmd_rehash)
{
extern char *services_config;
reply("OSMSG_WHOIS_HOST", target->ident, target->hostname);
if (IsFakeHost(target))
reply("OSMSG_WHOIS_FAKEHOST", target->fakehost);
+ reply("OSMSG_WHOIS_CRYPT_HOST", target->crypthost);
+ reply("OSMSG_WHOIS_CRYPT_IP", target->cryptip);
reply("OSMSG_WHOIS_IP", irc_ntoa(&target->ip));
if (target->modes) {
bpos = 0;
switch (alert->reaction) {
case REACT_NOTICE: reaction = "notice"; break;
case REACT_KILL: reaction = "kill"; break;
- case REACT_SILENT: reaction = "silent"; break;
+// case REACT_SILENT: reaction = "silent"; break;
case REACT_GLINE: reaction = "gline"; break;
case REACT_TRACK: reaction = "track"; break;
case REACT_SHUN: reaction = "shun"; break;
send_message_type(MSG_TYPE_NOXLATE, user, cmd->parent->bot,
"%u allocations in %u slabs totalling %u bytes.",
slab_alloc_count, slab_count, slab_alloc_size);
-/* send_message_type(MSG_TYPE_NOXLATE, user, cmd->parent->bot,
+ send_message_type(MSG_TYPE_NOXLATE, user, cmd->parent->bot,
"%u big allocations totalling %u bytes.",
- */
+ big_alloc_count, big_alloc_size);
return 1;
}
#endif
int add_reserved(const char *key, void *data, void *extra)
{
+ struct chanNode *chan;
struct record_data *rd = data;
const char *ident, *hostname, *desc;
+ unsigned int i;
struct userNode *reserve;
ident = database_get_data(rd->d.object, KEY_IDENT, RECDB_QSTRING);
if (!ident) {
reserve->modes |= FLAGS_PERSISTENT;
dict_insert(extra, reserve->nick, reserve);
}
+
+ if (autojoin_channels && reserve) {
+ for (i = 0; i < autojoin_channels->used; i++) {
+ chan = AddChannel(autojoin_channels->list[i], now, "+nt", NULL, NULL);
+ AddChannelUser(reserve, chan)->modes |= MODE_VOICE;
+ }
+ }
+
return 0;
}
discrim->intra_scmp = 0;
discrim->intra_dcmp = 0;
discrim->use_regex = 0;
+ discrim->silent = 0;
dupmask = strdup(hostmask);
if (split_ircmask(dupmask, &discrim->mask_nick, &discrim->mask_ident, &discrim->mask_host)) {
if (!irc_pton(&discrim->ip_mask, &discrim->ip_mask_bits, discrim->mask_host))
reaction = REACT_NOTICE;
else if (!irccasecmp(react, "kill"))
reaction = REACT_KILL;
+ /*
else if (!irccasecmp(react, "silent"))
reaction = REACT_SILENT;
+ */
else if (!irccasecmp(react, "gline"))
reaction = REACT_GLINE;
else if (!irccasecmp(react, "track"))
switch (alert->reaction) {
case REACT_NOTICE: reaction = "notice"; break;
case REACT_KILL: reaction = "kill"; break;
- case REACT_SILENT: reaction = "silent"; break;
+// case REACT_SILENT: reaction = "silent"; break;
case REACT_GLINE: reaction = "gline"; break;
case REACT_TRACK: reaction = "track"; break;
case REACT_SHUN: reaction = "shun"; break;
discrim->info_space = -1;
discrim->intra_dcmp = 0;
discrim->intra_scmp = 0;
+ discrim->use_regex = 0;
+ discrim->silent = 0;
for (i=0; i<argc; i++) {
if (irccasecmp(argv[i], "log") == 0) {
send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]);
goto fail;
}
+ } else if (irccasecmp(argv[i], "silent") == 0) {
+ i++;
+ if(!oper_has_access(user, opserv, opserv_conf.silent_level, 0)) {
+ goto fail;
+ } else if (true_string(argv[i])) {
+ discrim->silent = 1;
+ } else if (false_string(argv[i])) {
+ discrim->silent = 0;
+ } else {
+ send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]);
+ goto fail;
+ }
} else if (irccasecmp(argv[i], "duration") == 0) {
discrim->duration = ParseInterval(argv[++i]);
} else if (irccasecmp(argv[i], "channel") == 0) {
struct discrim_and_source *das = extra;
if (is_oper_victim(das->source, match, das->discrim->match_opers)) {
- opserv_block(match, das->source->handle_info->handle, das->discrim->reason, das->discrim->duration, 0);
+ opserv_block(match, das->source->handle_info->handle, das->discrim->reason, das->discrim->duration, das->discrim->silent);
}
return 0;
case REACT_KILL:
DelUser(user, opserv, 1, alert->discrim->reason);
return 1;
+/*
case REACT_SILENT:
opserv_block(user, alert->owner, alert->discrim->reason, alert->discrim->duration, 1);
return 1;
+*/
case REACT_GLINE:
- opserv_block(user, alert->owner, alert->discrim->reason, alert->discrim->duration, 0);
+ opserv_block(user, alert->owner, alert->discrim->reason, alert->discrim->duration, alert->discrim->silent);
return 1;
case REACT_SHUN:
opserv_shun(user, alert->owner, alert->discrim->reason, alert->discrim->duration);
reaction = REACT_NOTICE;
else if (!irccasecmp(argv[2], "kill"))
reaction = REACT_KILL;
+/*
else if (!irccasecmp(argv[2], "silent"))
reaction = REACT_SILENT;
+*/
else if (!irccasecmp(argv[2], "gline"))
reaction = REACT_GLINE;
else if (!irccasecmp(argv[2], "track")) {
static void
opserv_conf_read(void)
{
+ struct chanNode *chan;
+ unsigned int i;
struct record_data *rd;
dict_t conf_node, child;
const char *str, *str2;
str = database_get_data(conf_node, KEY_ADMIN_LEVEL, RECDB_QSTRING);
opserv_conf.admin_level = str ? strtoul(str, NULL, 0): 800;
+ str = database_get_data(conf_node, KEY_SILENT_LEVEL, RECDB_QSTRING);
+ opserv_conf.silent_level = str ? strtoul(str, NULL, 0): 700;
+
str = database_get_data(conf_node, KEY_UNTRUSTED_MAX, RECDB_QSTRING);
opserv_conf.untrusted_max = str ? strtoul(str, NULL, 0) : 5;
str = database_get_data(conf_node, KEY_PURGE_LOCK_DELAY, RECDB_QSTRING);
str = database_get_data(conf_node, KEY_BLOCK_GLINE_DURATION, RECDB_QSTRING);
opserv_conf.block_gline_duration = str ? ParseInterval(str) : 3600;
+ free_string_list(autojoin_channels);
+ autojoin_channels = database_get_data(conf_node, KEY_AUTOJOIN_CHANNELS, RECDB_STRING_LIST);
+
+ if(autojoin_channels)
+ autojoin_channels = string_list_copy(autojoin_channels);
+
+ if (autojoin_channels && opserv) {
+ for (i = 0; i < autojoin_channels->used; i++) {
+ chan = AddChannel(autojoin_channels->list[i], now, "+nt", NULL, NULL);
+ AddChannelUser(opserv, chan)->modes |= MODE_CHANOP;
+ }
+ }
+
str = database_get_data(conf_node, KEY_BLOCK_SHUN_DURATION, RECDB_QSTRING);
opserv_conf.block_shun_duration = str ? ParseInterval(str) : 3600;
opserv_define_func("REFRESHS", cmd_refreshs, 600, 0, 0);
opserv_define_func("REHASH", cmd_rehash, 900, 0, 0);
opserv_define_func("REOPEN", cmd_reopen, 900, 0, 0);
+ opserv_define_func("RESETMAX", cmd_resetmax, 900, 0, 0);
opserv_define_func("RESERVE", cmd_reserve, 800, 0, 5);
opserv_define_func("RESTART", cmd_restart, 900, 0, 2);
opserv_define_func("SET", cmd_set, 900, 0, 3);