#define KEY_ISSUER "issuer"
#define KEY_ISSUED "issued"
-#define IDENT_FORMAT "%s [%s@%s/%s]"
-#define IDENT_DATA(user) user->nick, user->ident, user->hostname, irc_ntoa(&user->ip)
-#define MAX_CHANNELS_WHOIS 50
+#define IDENT_FORMAT "%s [%s@%s/%s]"
+#define IDENT_DATA(user) user->nick, user->ident, user->hostname, irc_ntoa(&user->ip)
+#define MAX_CHANNELS_WHOIS 50
#define OSMSG_PART_REASON "%s has no reason."
#define OSMSG_KICK_REQUESTED "Kick requested by %s."
#define OSMSG_KILL_REQUESTED "Kill requested by %s."
{ "OSMSG_ADDED_BAN", "I have banned $b%s$b from $b%s$b." },
{ "OSMSG_NO_GLINE_CMD", "The GLINE command is not bound so you can only block with the default duration." },
{ "OSMSG_BLOCK_TRUSTED", "$b%s$b is on a trusted ip. If you really want to G-line him, use the GLINE command." },
+ { "OSMSG_BLOCK_OPER" , "G-lining $b%s$b (*@%s) would also hit the IRC operator $b%s$b." },
{ "OSMSG_GLINE_ISSUED", "G-line issued for $b%s$b." },
{ "OSMSG_GLINE_REMOVED", "G-line removed for $b%s$b." },
{ "OSMSG_GLINE_FORCE_REMOVED", "Unknown/expired G-line removed for $b%s$b." },
{ "OSMSG_CHANINFO_MANY_USERS", "%d users (\"/msg $S %s %s users\" for the list)" },
{ "OSMSG_CHANINFO_USER_COUNT", "Users (%d):" },
{ "OSMSG_CSEARCH_CHANNEL_INFO", "%s [%d users] %s %s" },
+ { "OSMSG_TRACE_MAX_CHANNELS", "You may not use the 'channel' criterion more than %d times." },
+ { "OSMSG_FORCEKICK_LOCAL", "You cannot kick $b%s$b forcefully." },
{ NULL, NULL }
};
free(ohi);
}
+#define DISCRIM_MAX_CHANS 20
+
typedef struct opservDiscrim {
- struct chanNode *channel;
- char *mask_nick, *mask_ident, *mask_host, *mask_info, *server, *reason, *accountmask;
+ struct chanNode *channels[DISCRIM_MAX_CHANS];
+ unsigned int channel_count;
+ char *mask_nick, *mask_ident, *mask_host, *mask_info, *server, *reason, *notice_target, *accountmask;
irc_in_addr_t ip_mask;
unsigned long limit;
time_t min_ts, max_ts;
unsigned int min_level, max_level, domain_depth, duration, min_clones, min_channels, max_channels;
unsigned char ip_mask_bits;
unsigned int match_opers : 1, match_trusted : 1, option_log : 1;
- unsigned int chan_req_modes : 2, chan_no_modes : 2;
+ unsigned int chan_req_modes[DISCRIM_MAX_CHANS], chan_no_modes[DISCRIM_MAX_CHANS];
int authed : 2, info_space : 2;
} *discrim_t;
opserv_free_user_alert(void *data)
{
struct opserv_user_alert *alert = data;
- if (alert->discrim->channel)
- UnlockChannel(alert->discrim->channel);
+ unsigned int i;
+ for(i = 0; i < alert->discrim->channel_count; i++)
+ UnlockChannel(alert->discrim->channels[i]);
free(alert->owner);
free(alert->text_discrim);
free(alert->split_discrim);
#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)
+#define opserv_custom_alert(chan, format...) do { if (chan) send_target_message(4 , chan , opserv , ## format); else 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.
else if ((victim = GetUserH(argv[1])))
change.args[0].u.hostmask = generate_hostmask(victim, 0);
else {
- reply("OSMSG_INVALID_IRCMASK", argv[1]);
- return 0;
+ reply("OSMSG_INVALID_IRCMASK", argv[1]);
+ return 0;
}
modcmd_chanmode_announce(&change);
reply("OSMSG_ADDED_BAN", change.args[0].u.hostmask, channel->name);
strftime(buffer, sizeof(buffer), fmt, gmtime(&channel->topic_time));
send_message_type(4, user, cmd->parent->bot, buffer, channel->topic_nick, channel->topic);
} else {
- irc_fetchtopic(cmd->parent->bot, channel->name);
- reply("OSMSG_CHANINFO_TOPIC_UNKNOWN");
+ irc_fetchtopic(cmd->parent->bot, channel->name);
+ reply("OSMSG_CHANINFO_TOPIC_UNKNOWN");
}
if (channel->banlist.used) {
- reply("OSMSG_CHANINFO_BAN_COUNT", channel->banlist.used);
+ reply("OSMSG_CHANINFO_BAN_COUNT", channel->banlist.used);
fmt = user_find_message(user, "OSMSG_CHANINFO_BAN");
- for (n = 0; n < channel->banlist.used; n++) {
- ban = channel->banlist.list[n];
- strftime(buffer, sizeof(buffer), fmt, localtime(&ban->set));
- send_message_type(4, user, cmd->parent->bot, buffer, ban->ban, ban->who);
- }
+ for (n = 0; n < channel->banlist.used; n++) {
+ ban = channel->banlist.list[n];
+ strftime(buffer, sizeof(buffer), fmt, localtime(&ban->set));
+ send_message_type(4, user, cmd->parent->bot, buffer, ban->ban, ban->who);
+ }
}
if ((argc < 2) && (channel->members.used >= 50)) {
/* early out unless they ask for users */
}
}
for (n=0; n<channel->members.used; n++) {
- moden = channel->members.list[n];
- if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == MODE_VOICE)
+ moden = channel->members.list[n];
+ if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == MODE_VOICE)
send_message_type(4, user, cmd->parent->bot, " +%s (%s@%s)", moden->user->nick, moden->user->ident, moden->user->hostname);
}
for (n=0; n<channel->members.used; n++) {
- moden = channel->members.list[n];
- if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == 0)
+ moden = channel->members.list[n];
+ if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == 0)
send_message_type(4, user, cmd->parent->bot, " %s (%s@%s)", moden->user->nick, moden->user->ident, moden->user->hostname);
}
return 1;
char *reason, *message;
if (!IsChannelName(argv[1])) {
- reply("OSMSG_NEED_CHANNEL", argv[0]);
- return 0;
+ reply("OSMSG_NEED_CHANNEL", argv[0]);
+ return 0;
}
reason = dict_find(opserv_chan_warn, argv[1], NULL);
if (reason) {
{
if ((argc < 2) || !IsChannelName(argv[1])) {
reply("OSMSG_NEED_CHANNEL", argv[0]);
- return 0;
+ return 0;
}
if (!dict_remove(opserv_chan_warn, argv[1])) {
reply("OSMSG_WARN_NOEXIST", argv[1]);
struct mod_chanmode change;
if (!channel->modes) {
- reply("OSMSG_NO_CHANNEL_MODES", channel->name);
+ reply("OSMSG_NO_CHANNEL_MODES", channel->name);
return 0;
}
mod_chanmode_init(&change);
for (arg = 1, count = 0; arg < argc; ++arg) {
struct userNode *victim = GetUserH(argv[arg]);
struct modeNode *mn;
- if (!victim || IsService(victim)
+ if (!victim || IsService(victim)
|| !(mn = GetUserMode(channel, victim))
|| !(mn->modes & MODE_CHANOP))
continue;
change = mod_chanmode_alloc(channel->members.used);
for (ii = count = 0; ii < channel->members.used; ++ii) {
- struct modeNode *mn = channel->members.list[ii];
- if (IsService(mn->user) || !(mn->modes & MODE_CHANOP))
+ struct modeNode *mn = channel->members.list[ii];
+ if (IsService(mn->user) || !(mn->modes & MODE_CHANOP))
continue;
change->args[count].mode = MODE_REMOVE | MODE_CHANOP;
change->args[count++].u.member = mn;
extern char *services_config;
if (conf_read(services_config))
- reply("OSMSG_REHASH_COMPLETE");
+ reply("OSMSG_REHASH_COMPLETE");
else
- reply("OSMSG_REHASH_FAILED");
+ reply("OSMSG_REHASH_FAILED");
return 1;
}
target = unsplit_string(argv+1, argc-1, NULL);
if (!strcmp(cManager.uplink->name, target)) {
- reply("OSMSG_CURRENT_UPLINK", cManager.uplink->name);
- return 0;
+ reply("OSMSG_CURRENT_UPLINK", cManager.uplink->name);
+ return 0;
}
uplink = uplink_find(target);
if (!uplink) {
- reply("OSMSG_INVALID_UPLINK", target);
- return 0;
+ reply("OSMSG_INVALID_UPLINK", target);
+ return 0;
}
if (uplink->flags & UPLINK_UNAVAILABLE) {
reply("OSMSG_UPLINK_DISABLED", uplink->name);
char *reason;
unsigned long duration = 0;
unsigned int offset = 2;
+ unsigned int nn;
struct svccmd *gline_cmd;
target = GetUserH(argv[1]);
reply("OSMSG_BLOCK_TRUSTED", target->nick);
return 0;
}
+
+ for(nn = 0; nn < curr_opers.used; nn++) {
+ if(memcmp(&curr_opers.list[nn]->ip, &target->ip, sizeof(irc_in_addr_t)) == 0) {
+ reply("OSMSG_BLOCK_OPER", target->nick, irc_ntoa(&target->ip), curr_opers.list[nn]->nick);
+ return 0;
+ }
+ }
+
if(argc > 2 && (duration = ParseInterval(argv[2]))) {
offset = 3;
}
if(duration && duration != opserv_conf.block_gline_duration) {
- // We require more access when the duration is not the default block duration.
+ /* We require more access when the duration is not the default block duration. */
gline_cmd = dict_find(cmd->parent->commands, "gline", NULL);
if(!gline_cmd)
{
reason = unsplit_string(argv+3, argc-3, NULL);
if (!is_gline(argv[1]) && !IsChannelName(argv[1]) && (argv[1][0] != '&')) {
- reply("MSG_INVALID_GLINE", argv[1]);
- return 0;
+ reply("MSG_INVALID_GLINE", argv[1]);
+ return 0;
}
if (!argv[1][strspn(argv[1], "#&*?@.")] && (strlen(argv[1]) < 10)) {
reply("OSMSG_STUPID_GLINE", argv[1]);
if (!maxlen)
maxlen = MAX_LINE_SIZE;
for (n=count=0; n<target->channels.used; n++) {
- mn = target->channels.list[n];
- here_len = strlen(mn->channel->name);
- if ((count + here_len + 4) > maxlen) {
- buff[count] = 0;
+ mn = target->channels.list[n];
+ here_len = strlen(mn->channel->name);
+ if ((count + here_len + 4) > maxlen) {
+ buff[count] = 0;
send_message(tell, opserv, message, buff);
- count = 0;
- }
- if (mn->modes & MODE_CHANOP)
+ count = 0;
+ }
+ if (mn->modes & MODE_CHANOP)
buff[count++] = '@';
- if (mn->modes & MODE_VOICE)
+ if (mn->modes & MODE_VOICE)
buff[count++] = '+';
- memcpy(buff+count, mn->channel->name, here_len);
- count += here_len;
- buff[count++] = ' ';
+ memcpy(buff+count, mn->channel->name, here_len);
+ count += here_len;
+ buff[count++] = ' ';
}
if (count) {
- buff[count] = 0;
- send_message(tell, opserv, message, buff);
+ buff[count] = 0;
+ send_message(tell, opserv, message, buff);
}
}
struct userNode *target;
if (argc < 2) {
- target = user;
+ target = user;
} else {
- target = GetUserH(argv[1]);
- if (!target) {
- reply("MSG_NICK_UNKNOWN", argv[1]);
- return 0;
- }
+ target = GetUserH(argv[1]);
+ if (!target) {
+ reply("MSG_NICK_UNKNOWN", argv[1]);
+ return 0;
+ }
}
if (opserv_conf.debug_channel == NULL) {
- reply("OSMSG_NO_DEBUG_CHANNEL");
- return 0;
+ reply("OSMSG_NO_DEBUG_CHANNEL");
+ return 0;
}
if (GetUserMode(opserv_conf.debug_channel, user)) {
reply("OSMSG_ALREADY_THERE", opserv_conf.debug_channel->name);
}
irc_invite(cmd->parent->bot, target, opserv_conf.debug_channel);
if (target != user)
- reply("OSMSG_INVITE_DONE", target->nick, opserv_conf.debug_channel->name);
+ reply("OSMSG_INVITE_DONE", target->nick, opserv_conf.debug_channel->name);
return 1;
}
{
struct userNode *bot = cmd->parent->bot;
- if (!IsChannelName(argv[1])) {
- reply("MSG_NOT_CHANNEL_NAME");
- return 0;
- } else if (!(channel = GetChannel(argv[1]))) {
+ if (!channel) {
+ if((argc < 2) || !IsChannelName(argv[1]))
+ {
+ reply("MSG_NOT_CHANNEL_NAME");
+ return 0;
+ }
+
channel = AddChannel(argv[1], now, NULL, NULL);
AddChannelUser(bot, channel)->modes |= MODE_CHANOP;
} else if (GetUserMode(channel, bot)) {
change.args[0].u.member = AddChannelUser(bot, channel);
modcmd_chanmode_announce(&change);
}
+
irc_fetchtopic(bot, channel->name);
reply("OSMSG_JOIN_DONE", channel->name);
return 1;
char *reason;
if (argc < 3) {
- reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
- sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
+ reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
+ sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
} else {
- reason = unsplit_string(argv+2, argc-2, NULL);
+ reason = unsplit_string(argv+2, argc-2, NULL);
}
target = GetUserH(argv[1]);
if (!target) {
- reply("MSG_NICK_UNKNOWN", argv[1]);
- return 0;
+ reply("MSG_NICK_UNKNOWN", argv[1]);
+ return 0;
}
if (!GetUserMode(channel, target)) {
- reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name);
- return 0;
+ reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name);
+ return 0;
}
KickChannelUser(target, channel, cmd->parent->bot, reason);
return 1;
}
+static MODCMD_FUNC(cmd_forcekick)
+{
+ struct userNode *target;
+ char *reason;
+
+ if (argc < 3) {
+ reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
+ sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
+ } else {
+ reason = unsplit_string(argv+2, argc-2, NULL);
+ }
+ target = GetUserH(argv[1]);
+ if (!target) {
+ reply("MSG_NICK_UNKNOWN", argv[1]);
+ return 0;
+ }
+ if (!GetUserMode(channel, target)) {
+ reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name);
+ return 0;
+ }
+ if (IsLocal(target)) {
+ reply("OSMSG_FORCEKICK_LOCAL", target->nick);
+ return 0;
+ }
+ irc_kick(cmd->parent->bot, target, channel, reason);
+ return 1;
+}
+
static MODCMD_FUNC(cmd_kickall)
{
unsigned int limit, n, inchan;
modcmd_chanmode_announce(&change);
}
if (argc < 2) {
- reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
- sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
+ reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
+ sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
} else {
- reason = unsplit_string(argv+1, argc-1, NULL);
+ reason = unsplit_string(argv+1, argc-1, NULL);
}
limit = user->handle_info->opserv_level;
for (n=channel->members.used; n>0;) {
- mn = channel->members.list[--n];
- if (IsService(mn->user)
- || (mn->user->handle_info
- && (mn->user->handle_info->opserv_level >= limit))) {
- continue;
- }
- KickChannelUser(mn->user, channel, bot, reason);
+ mn = channel->members.list[--n];
+ if (IsService(mn->user)
+ || (mn->user->handle_info
+ && (mn->user->handle_info->opserv_level >= limit))) {
+ continue;
+ }
+ KickChannelUser(mn->user, channel, bot, reason);
}
if (!inchan)
DelChannelUser(bot, channel, "My work here is done", 0);
char *mask;
if (argc == 2) {
- reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
- sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
+ reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
+ sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
} else {
- reason = unsplit_string(argv+2, argc-2, NULL);
+ reason = unsplit_string(argv+2, argc-2, NULL);
}
target = GetUserH(argv[1]);
if (!target) {
- reply("MSG_NICK_UNKNOWN", argv[1]);
- return 0;
+ reply("MSG_NICK_UNKNOWN", argv[1]);
+ return 0;
}
if (!GetUserMode(channel, target)) {
- reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name);
- return 0;
+ reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name);
+ return 0;
}
mod_chanmode_init(&change);
change.argc = 1;
modcmd_chanmode_announce(change);
mod_chanmode_free(change);
if (argc < 2) {
- reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
- sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
+ reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
+ sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
} else {
- reason = unsplit_string(argv+1, argc-1, NULL);
+ reason = unsplit_string(argv+1, argc-1, NULL);
}
/* now kick them */
limit = user->handle_info->opserv_level;
for (n=channel->members.used; n>0; ) {
- mn = channel->members.list[--n];
- if (IsService(mn->user)
- || (mn->user->handle_info
- && (mn->user->handle_info->opserv_level >= limit))) {
- continue;
- }
- KickChannelUser(mn->user, channel, bot, reason);
+ mn = channel->members.list[--n];
+ if (IsService(mn->user)
+ || (mn->user->handle_info
+ && (mn->user->handle_info->opserv_level >= limit))) {
+ continue;
+ }
+ KickChannelUser(mn->user, channel, bot, reason);
}
if (!inchan)
DelChannelUser(bot, channel, "My work here is done", 0);
{
char *reason;
- if (!IsChannelName(argv[1])) {
- reply("MSG_NOT_CHANNEL_NAME");
+ if (!GetUserMode(channel, cmd->parent->bot)) {
+ reply("OSMSG_NOT_ON_CHANNEL", cmd->parent->bot->nick, channel->name);
return 0;
}
- if ((channel = GetChannel(argv[1]))) {
- if (!GetUserMode(channel, cmd->parent->bot)) {
- reply("OSMSG_NOT_ON_CHANNEL", cmd->parent->bot->nick, channel->name);
- return 0;
- }
- reason = (argc < 3) ? "Leaving." : unsplit_string(argv+2, argc-2, NULL);
- reply("OSMSG_LEAVING", channel->name);
- DelChannelUser(cmd->parent->bot, channel, reason, 0);
- }
+ reason = (argc < 2) ? "Leaving." : unsplit_string(argv+1, argc-1, NULL);
+ reply("OSMSG_LEAVING", channel->name);
+ DelChannelUser(cmd->parent->bot, channel, reason, 0);
return 1;
}
change = mod_chanmode_alloc(channel->members.used);
for (ii = count = 0; ii < channel->members.used; ++ii) {
- struct modeNode *mn = channel->members.list[ii];
- if (mn->modes & MODE_CHANOP)
+ struct modeNode *mn = channel->members.list[ii];
+ if (mn->modes & MODE_CHANOP)
continue;
change->args[count].mode = MODE_CHANOP;
change->args[count++].u.member = mn;
}
if (count) {
change->argc = count;
- modcmd_chanmode_announce(change);
+ modcmd_chanmode_announce(change);
}
mod_chanmode_free(change);
reply("OSMSG_OPALL_DONE", channel->name);
reply("OSMSG_WHOIS_FAKEHOST", target->fakehost);
reply("OSMSG_WHOIS_IP", irc_ntoa(&target->ip));
if (target->modes) {
- bpos = 0;
+ bpos = 0;
#define buffer_cat(str) (herelen = strlen(str), memcpy(buffer+bpos, str, herelen), bpos += herelen)
- if (IsInvisible(target)) buffer[bpos++] = 'i';
- if (IsWallOp(target)) buffer[bpos++] = 'w';
- if (IsOper(target)) buffer[bpos++] = 'o';
- if (IsGlobal(target)) buffer[bpos++] = 'g';
- if (IsService(target)) buffer[bpos++] = 'k';
- if (IsDeaf(target)) buffer[bpos++] = 'd';
- if (IsNoChan(target)) buffer[bpos++] = 'n';
+ if (IsInvisible(target)) buffer[bpos++] = 'i';
+ if (IsWallOp(target)) buffer[bpos++] = 'w';
+ if (IsOper(target)) buffer[bpos++] = 'o';
+ if (IsGlobal(target)) buffer[bpos++] = 'g';
+ if (IsService(target)) buffer[bpos++] = 'k';
+ if (IsDeaf(target)) buffer[bpos++] = 'd';
+ if (IsNoChan(target)) buffer[bpos++] = 'n';
if (IsHiddenHost(target)) buffer[bpos++] = 'x';
if (IsNoIdle(target)) buffer[bpos++] = 'I';
if (IsGagged(target)) buffer_cat(" (gagged)");
- if (IsRegistering(target)) buffer_cat(" (registered account)");
- buffer[bpos] = 0;
- if (bpos > 0)
+ if (IsRegistering(target)) buffer_cat(" (registered account)");
+ buffer[bpos] = 0;
+ if (bpos > 0)
reply("OSMSG_WHOIS_MODES", buffer);
}
reply("OSMSG_WHOIS_INFO", target->info);
intervalString(buffer, now - target->timestamp, user->handle_info);
reply("OSMSG_WHOIS_NICK_AGE", buffer);
if (target->channels.used <= MAX_CHANNELS_WHOIS)
- opserv_ison(user, target, "OSMSG_WHOIS_CHANNELS");
+ opserv_ison(user, target, "OSMSG_WHOIS_CHANNELS");
else
- reply("OSMSG_WHOIS_HIDECHANS");
+ reply("OSMSG_WHOIS_HIDECHANS");
return 1;
}
change = mod_chanmode_alloc(channel->members.used);
for (ii = count = 0; ii < channel->members.used; ++ii) {
- struct modeNode *mn = channel->members.list[ii];
- if (mn->modes & (MODE_CHANOP|MODE_VOICE))
+ struct modeNode *mn = channel->members.list[ii];
+ if (mn->modes & (MODE_CHANOP|MODE_VOICE))
continue;
change->args[count].mode = MODE_VOICE;
change->args[count++].u.member = mn;
}
if (count) {
change->argc = count;
- modcmd_chanmode_announce(change);
+ modcmd_chanmode_announce(change);
}
mod_chanmode_free(change);
reply("OSMSG_CHANNEL_VOICED", channel->name);
change = mod_chanmode_alloc(channel->members.used);
for (ii = count = 0; ii < channel->members.used; ++ii) {
- struct modeNode *mn = channel->members.list[ii];
- if (!(mn->modes & MODE_VOICE))
+ struct modeNode *mn = channel->members.list[ii];
+ if (!(mn->modes & MODE_VOICE))
continue;
change->args[count].mode = MODE_REMOVE | MODE_VOICE;
change->args[count++].u.member = mn;
}
if (count) {
change->argc = count;
- modcmd_chanmode_announce(change);
+ modcmd_chanmode_announce(change);
}
mod_chanmode_free(change);
reply("OSMSG_CHANNEL_DEVOICED", channel->name);
unsigned int nn;
if (!gagList) {
- reply("OSMSG_NO_GAGS");
+ reply("OSMSG_NO_GAGS");
return 1;
}
for (nn=0, gag=gagList; gag; nn++, gag=gag->next) ;
safestrncpy(linedup, original, sizeof(linedup));
/* assume it's only valid IRC if we can parse it */
if (parse_line(linedup, 1)) {
- irc_raw(original);
- reply("OSMSG_LINE_DUMPED");
+ irc_raw(original);
+ reply("OSMSG_LINE_DUMPED");
} else
- reply("OSMSG_RAW_PARSE_ERROR");
+ reply("OSMSG_RAW_PARSE_ERROR");
return 1;
}
{
struct userNode *resv = GetUserH(nick);
if (resv) {
- if (IsService(resv)) {
- reply("MSG_SERVICE_IMMUNE", resv->nick);
- return NULL;
- }
- if (resv->handle_info
- && resv->handle_info->opserv_level > user->handle_info->opserv_level) {
- reply("OSMSG_LEVEL_TOO_LOW");
- return NULL;
- }
+ if (IsService(resv)) {
+ reply("MSG_SERVICE_IMMUNE", resv->nick);
+ return NULL;
+ }
+ if (resv->handle_info
+ && resv->handle_info->opserv_level > user->handle_info->opserv_level) {
+ reply("OSMSG_LEVEL_TOO_LOW");
+ return NULL;
+ }
}
if ((resv = AddLocalUser(nick, ident, host, desc, "+i"))) {
dict_insert(opserv_reserved_nick_dict, resv->nick, resv);
resv = opserv_add_reserve(cmd, user, argv[1], argv[2], argv[3], unsplit_string(argv+4, argc-4, NULL));
if (resv) {
- reply("OSMSG_COLLIDED_NICK", resv->nick);
- return 1;
+ reply("OSMSG_COLLIDED_NICK", resv->nick);
+ return 1;
} else {
reply("OSMSG_CLONE_FAILED", argv[1]);
- return 0;
+ return 0;
}
}
resv = opserv_add_reserve(cmd, user, argv[1], argv[2], argv[3], unsplit_string(argv+4, argc-4, NULL));
if (resv) {
- resv->modes |= FLAGS_PERSISTENT;
- reply("OSMSG_RESERVED_NICK", resv->nick);
- return 1;
+ resv->modes |= FLAGS_PERSISTENT;
+ reply("OSMSG_RESERVED_NICK", resv->nick);
+ return 1;
} else {
reply("OSMSG_CLONE_FAILED", argv[1]);
- return 0;
+ return 0;
}
}
static MODCMD_FUNC(cmd_unreserve)
{
if (free_reserve(argv[1]))
- reply("OSMSG_NICK_UNRESERVED", argv[1]);
+ reply("OSMSG_NICK_UNRESERVED", argv[1]);
else
- reply("OSMSG_NOT_RESERVED", argv[1]);
+ reply("OSMSG_NOT_RESERVED", argv[1]);
return 1;
}
struct mod_chanmode change;
mod_chanmode_init(&change);
channel->join_flooded = 1;
- if (opserv && opserv_conf.join_flood_moderate && (channel->members.used > opserv_conf.join_flood_moderate_threshold)) {
+ if (opserv && opserv_conf.join_flood_moderate && (channel->members.used > opserv_conf.join_flood_moderate_threshold)) {
if (!GetUserMode(channel, opserv)) {
/* If we aren't in the channel, join it. */
change.args[0].mode = MODE_CHANOP;
char *userinfo;
char ident[USERLEN+1];
- if (argc < 5) {
- reply("MSG_MISSING_PARAMS", argv[1]);
- OPSERV_SYNTAX();
- return 0;
- }
- if (clone) {
- reply("OSMSG_CLONE_EXISTS", argv[2]);
- return 0;
- }
- userinfo = unsplit_string(argv+4, argc-4, NULL);
- for (i=0; argv[3][i] && (i<USERLEN); i++) {
- if (argv[3][i] == '@') {
- ident[i++] = 0;
- break;
- } else {
+ if (argc < 5) {
+ reply("MSG_MISSING_PARAMS", argv[1]);
+ OPSERV_SYNTAX();
+ return 0;
+ }
+ if (clone) {
+ reply("OSMSG_CLONE_EXISTS", argv[2]);
+ return 0;
+ }
+ userinfo = unsplit_string(argv+4, argc-4, NULL);
+ for (i=0; argv[3][i] && (i<USERLEN); i++) {
+ if (argv[3][i] == '@') {
+ ident[i++] = 0;
+ break;
+ } else {
ident[i] = argv[3][i];
}
- }
- if (!argv[3][i] || (i==USERLEN)) {
- reply("OSMSG_NOT_A_HOSTMASK");
- return 0;
- }
- if (!(clone = AddLocalUser(argv[2], ident, argv[3]+i, userinfo, "+i"))) {
+ }
+ if (!argv[3][i] || (i==USERLEN)) {
+ reply("OSMSG_NOT_A_HOSTMASK");
+ return 0;
+ }
+ if (!(clone = AddLocalUser(argv[2], ident, argv[3]+i, userinfo, "+i"))) {
reply("OSMSG_CLONE_FAILED", argv[2]);
return 0;
}
reply("OSMSG_CLONE_ADDED", clone->nick);
- return 1;
+ return 1;
}
if (!clone) {
- reply("MSG_NICK_UNKNOWN", argv[2]);
- return 0;
+ reply("MSG_NICK_UNKNOWN", argv[2]);
+ return 0;
}
if (clone->uplink != self || IsService(clone)) {
- reply("OSMSG_NOT_A_CLONE", clone->nick);
- return 0;
+ reply("OSMSG_NOT_A_CLONE", clone->nick);
+ return 0;
}
if (!irccasecmp(argv[1], "REMOVE")) {
- const char *reason;
- if (argc > 3) {
- reason = unsplit_string(argv+3, argc-3, NULL);
- } else {
- char *tmp;
- tmp = alloca(strlen(clone->nick) + strlen(OSMSG_PART_REASON));
- sprintf(tmp, OSMSG_PART_REASON, clone->nick);
- reason = tmp;
- }
- DelUser(clone, NULL, 1, reason);
- reply("OSMSG_CLONE_REMOVED", argv[2]);
- return 1;
+ const char *reason;
+ if (argc > 3) {
+ reason = unsplit_string(argv+3, argc-3, NULL);
+ } else {
+ char *tmp;
+ tmp = alloca(strlen(clone->nick) + strlen(OSMSG_PART_REASON));
+ sprintf(tmp, OSMSG_PART_REASON, clone->nick);
+ reason = tmp;
+ }
+ DelUser(clone, NULL, 1, reason);
+ reply("OSMSG_CLONE_REMOVED", argv[2]);
+ return 1;
}
if (argc < 4) {
- reply("MSG_MISSING_PARAMS", argv[1]);
- OPSERV_SYNTAX();
- return 0;
+ reply("MSG_MISSING_PARAMS", argv[1]);
+ OPSERV_SYNTAX();
+ return 0;
}
channel = GetChannel(argv[3]);
if (!irccasecmp(argv[1], "JOIN")) {
- if (!channel
- && !(channel = AddChannel(argv[3], now, NULL, NULL))) {
- reply("MSG_CHANNEL_UNKNOWN", argv[3]);
- return 0;
- }
- AddChannelUser(clone, channel);
- reply("OSMSG_CLONE_JOINED", clone->nick, channel->name);
- return 1;
+ if (!channel
+ && !(channel = AddChannel(argv[3], now, NULL, NULL))) {
+ reply("MSG_CHANNEL_UNKNOWN", argv[3]);
+ return 0;
+ }
+ AddChannelUser(clone, channel);
+ reply("OSMSG_CLONE_JOINED", clone->nick, channel->name);
+ return 1;
}
if (!irccasecmp(argv[1], "PART")) {
- if (!channel) {
- reply("MSG_CHANNEL_UNKNOWN", argv[3]);
- return 0;
- }
- if (!GetUserMode(channel, clone)) {
- reply("OSMSG_NOT_ON_CHANNEL", clone->nick, channel->name);
- return 0;
- }
- reply("OSMSG_CLONE_PARTED", clone->nick, channel->name);
- DelChannelUser(clone, channel, "Leaving.", 0);
- return 1;
+ if (!channel) {
+ reply("MSG_CHANNEL_UNKNOWN", argv[3]);
+ return 0;
+ }
+ if (!GetUserMode(channel, clone)) {
+ reply("OSMSG_NOT_ON_CHANNEL", clone->nick, channel->name);
+ return 0;
+ }
+ reply("OSMSG_CLONE_PARTED", clone->nick, channel->name);
+ DelChannelUser(clone, channel, "Leaving.", 0);
+ return 1;
}
if (!irccasecmp(argv[1], "OP")) {
struct mod_chanmode change;
- if (!channel) {
- reply("MSG_CHANNEL_UNKNOWN", argv[3]);
- return 0;
- }
+ if (!channel) {
+ reply("MSG_CHANNEL_UNKNOWN", argv[3]);
+ return 0;
+ }
mod_chanmode_init(&change);
change.argc = 1;
change.args[0].mode = MODE_CHANOP;
if (!change.args[0].u.member) {
reply("OSMSG_NOT_ON_CHANNEL", clone->nick, channel->name);
return 0;
- }
+ }
modcmd_chanmode_announce(&change);
- reply("OSMSG_OPS_GIVEN", channel->name, clone->nick);
- return 1;
+ reply("OSMSG_OPS_GIVEN", channel->name, clone->nick);
+ return 1;
}
if (argc < 5) {
- reply("MSG_MISSING_PARAMS", argv[1]);
- OPSERV_SYNTAX();
- return 0;
+ reply("MSG_MISSING_PARAMS", argv[1]);
+ OPSERV_SYNTAX();
+ return 0;
}
if (!irccasecmp(argv[1], "SAY")) {
- char *text = unsplit_string(argv+4, argc-4, NULL);
- irc_privmsg(clone, argv[3], text);
- reply("OSMSG_CLONE_SAID", clone->nick, argv[3]);
- return 1;
+ char *text = unsplit_string(argv+4, argc-4, NULL);
+ irc_privmsg(clone, argv[3], text);
+ reply("OSMSG_CLONE_SAID", clone->nick, argv[3]);
+ return 1;
}
reply("OSMSG_UNKNOWN_SUBCOMMAND", argv[1], argv[0]);
return 0;
struct userNode *reserve;
ident = database_get_data(rd->d.object, KEY_IDENT, RECDB_QSTRING);
if (!ident) {
- log_module(OS_LOG, LOG_ERROR, "Missing ident for reserve of %s", key);
- return 0;
+ log_module(OS_LOG, LOG_ERROR, "Missing ident for reserve of %s", key);
+ return 0;
}
hostname = database_get_data(rd->d.object, KEY_HOSTNAME, RECDB_QSTRING);
if (!hostname) {
- log_module(OS_LOG, LOG_ERROR, "Missing hostname for reserve of %s", key);
- return 0;
+ log_module(OS_LOG, LOG_ERROR, "Missing hostname for reserve of %s", key);
+ return 0;
}
desc = database_get_data(rd->d.object, KEY_DESC, RECDB_QSTRING);
if (!desc) {
- log_module(OS_LOG, LOG_ERROR, "Missing description for reserve of %s", key);
- return 0;
+ log_module(OS_LOG, LOG_ERROR, "Missing description for reserve of %s", key);
+ return 0;
}
if ((reserve = AddLocalUser(key, ident, hostname, desc, "+i"))) {
reserve->modes |= FLAGS_PERSISTENT;
discrim->ip_mask_bits = 0;
matched = opserv_discrim_search(discrim, func, extra);
} else {
- log_module(OS_LOG, LOG_ERROR, "Couldn't split IRC mask for gag %s!", hostmask);
+ log_module(OS_LOG, LOG_ERROR, "Couldn't split IRC mask for gag %s!", hostmask);
matched = 0;
}
free(discrim);
char *name_dup;
if (dict_find(opserv_user_alerts, name, NULL)) {
- send_message(req, opserv, "OSMSG_ALERT_EXISTS", name);
- return NULL;
+ send_message(req, opserv, "OSMSG_ALERT_EXISTS", name);
+ return NULL;
}
alert = malloc(sizeof(*alert));
alert->owner = strdup(req->handle_info ? req->handle_info->handle : req->nick);
* max_channels would have to be checked on /part, which we do not
* yet do, and which seems of questionable value.
*/
- if (alert->discrim->channel || alert->discrim->min_channels)
+ if (alert->discrim->channel_count || alert->discrim->min_channels)
dict_insert(opserv_channel_alerts, name_dup, alert);
if (alert->discrim->mask_nick)
dict_insert(opserv_nick_based_alerts, name_dup, alert);
char *nodename;
if (argc < 2) {
- reply("OSMSG_OPTION_ROOT");
- conf_enum_root(query_keys_helper, user);
- return 1;
+ reply("OSMSG_OPTION_ROOT");
+ conf_enum_root(query_keys_helper, user);
+ return 1;
}
nodename = unsplit_string(argv+1, argc-1, NULL);
if (!(rd = conf_get_node(nodename))) {
- reply("OSMSG_UNKNOWN_OPTION", nodename);
- return 0;
+ reply("OSMSG_UNKNOWN_OPTION", nodename);
+ return 0;
}
if (rd->type == RECDB_QSTRING)
- reply("OSMSG_OPTION_IS", nodename, rd->d.qstring);
+ reply("OSMSG_OPTION_IS", nodename, rd->d.qstring);
else if (rd->type == RECDB_STRING_LIST) {
- reply("OSMSG_OPTION_LIST", nodename);
- if (rd->d.slist->used)
- for (i=0; i<rd->d.slist->used; i++)
- send_message_type(4, user, cmd->parent->bot, "$b%s$b", rd->d.slist->list[i]);
- else
- reply("OSMSG_OPTION_LIST_EMPTY");
+ reply("OSMSG_OPTION_LIST", nodename);
+ if (rd->d.slist->used)
+ for (i=0; i<rd->d.slist->used; i++)
+ send_message_type(4, user, cmd->parent->bot, "$b%s$b", rd->d.slist->list[i]);
+ else
+ reply("OSMSG_OPTION_LIST_EMPTY");
} else if (rd->type == RECDB_OBJECT) {
- reply("OSMSG_OPTION_KEYS", nodename);
- dict_foreach(rd->d.object, query_keys_helper, user);
+ reply("OSMSG_OPTION_KEYS", nodename);
+ dict_foreach(rd->d.object, query_keys_helper, user);
}
return 1;
invent a syntax for it. -Zoot */
if (!(rd = conf_get_node(argv[1]))) {
- reply("OSMSG_SET_NOT_SET", argv[1]);
- return 0;
+ reply("OSMSG_SET_NOT_SET", argv[1]);
+ return 0;
}
if (rd->type != RECDB_QSTRING) {
- reply("OSMSG_SET_BAD_TYPE", argv[1]);
- return 0;
+ reply("OSMSG_SET_BAD_TYPE", argv[1]);
+ return 0;
}
free(rd->d.qstring);
send_message(user, opserv, "MSG_MISSING_PARAMS", argv[i]);
goto fail;
}
- if (irccasecmp(argv[i], "mask") == 0) {
- if (!is_ircmask(argv[++i])) {
- send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]);
- goto fail;
- }
- if (!split_ircmask(argv[i],
+ if (irccasecmp(argv[i], "mask") == 0) {
+ if (!is_ircmask(argv[++i])) {
+ send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]);
+ goto fail;
+ }
+ if (!split_ircmask(argv[i],
&discrim->mask_nick,
&discrim->mask_ident,
&discrim->mask_host)) {
- send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]);
- goto fail;
- }
- } else if (irccasecmp(argv[i], "nick") == 0) {
- discrim->mask_nick = argv[++i];
- } else if (irccasecmp(argv[i], "ident") == 0) {
- discrim->mask_ident = argv[++i];
- } else if (irccasecmp(argv[i], "host") == 0) {
- discrim->mask_host = argv[++i];
- } else if (irccasecmp(argv[i], "info") == 0) {
- discrim->mask_info = argv[++i];
- } else if (irccasecmp(argv[i], "server") == 0) {
- discrim->server = argv[++i];
- } else if (irccasecmp(argv[i], "ip") == 0) {
+ send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]);
+ goto fail;
+ }
+ } else if (irccasecmp(argv[i], "nick") == 0) {
+ discrim->mask_nick = argv[++i];
+ } else if (irccasecmp(argv[i], "ident") == 0) {
+ discrim->mask_ident = argv[++i];
+ } else if (irccasecmp(argv[i], "host") == 0) {
+ discrim->mask_host = argv[++i];
+ } else if (irccasecmp(argv[i], "info") == 0) {
+ discrim->mask_info = argv[++i];
+ } else if (irccasecmp(argv[i], "server") == 0) {
+ discrim->server = argv[++i];
+ } else if (irccasecmp(argv[i], "ip") == 0) {
j = irc_pton(&discrim->ip_mask, &discrim->ip_mask_bits, argv[++i]);
if (!j) {
send_message(user, opserv, "OSMSG_BAD_IP", argv[i]);
goto fail;
}
- } else if (irccasecmp(argv[i], "account") == 0) {
- if (discrim->authed == 0) {
- send_message(user, opserv, "OSMSG_ACCOUNTMASK_AUTHED");
- goto fail;
- }
- discrim->accountmask = argv[++i];
- discrim->authed = 1;
- } else if (irccasecmp(argv[i], "authed") == 0) {
- i++; /* true_string and false_string are macros! */
- if (true_string(argv[i])) {
- discrim->authed = 1;
- } else if (false_string(argv[i])) {
- if (discrim->accountmask) {
+ } else if (irccasecmp(argv[i], "account") == 0) {
+ if (discrim->authed == 0) {
send_message(user, opserv, "OSMSG_ACCOUNTMASK_AUTHED");
goto fail;
}
- discrim->authed = 0;
- } else {
- send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]);
- goto fail;
- }
- } else if (irccasecmp(argv[i], "info_space") == 0) {
- /* XXX: A hack because you can't check explicitly for a space through
- * any other means */
- i++;
- if (true_string(argv[i])) {
- discrim->info_space = 1;
- } else if (false_string(argv[i])) {
- discrim->info_space = 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) {
+ discrim->accountmask = argv[++i];
+ discrim->authed = 1;
+ } else if (irccasecmp(argv[i], "authed") == 0) {
+ i++; /* true_string and false_string are macros! */
+ if (true_string(argv[i])) {
+ discrim->authed = 1;
+ } else if (false_string(argv[i])) {
+ if (discrim->accountmask) {
+ send_message(user, opserv, "OSMSG_ACCOUNTMASK_AUTHED");
+ goto fail;
+ }
+ discrim->authed = 0;
+ } else {
+ send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]);
+ goto fail;
+ }
+ } else if (irccasecmp(argv[i], "info_space") == 0) {
+ /* XXX: A hack because you can't check explicitly for a space through
+ * any other means */
+ i++;
+ if (true_string(argv[i])) {
+ discrim->info_space = 1;
+ } else if (false_string(argv[i])) {
+ discrim->info_space = 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) {
+ if(discrim->channel_count == DISCRIM_MAX_CHANS)
+ {
+ send_message(user, opserv, "OSMSG_TRACE_MAX_CHANNELS", DISCRIM_MAX_CHANS);
+ goto fail;
+ }
+
for (j=0, i++; ; j++) {
switch (argv[i][j]) {
case '#':
goto find_channel;
case '-':
- discrim->chan_no_modes |= MODE_CHANOP | MODE_VOICE;
+ discrim->chan_no_modes[discrim->channel_count] |= MODE_CHANOP | MODE_VOICE;
break;
case '+':
- discrim->chan_req_modes |= MODE_VOICE;
- discrim->chan_no_modes |= MODE_CHANOP;
+ discrim->chan_req_modes[discrim->channel_count] |= MODE_VOICE;
+ discrim->chan_no_modes[discrim->channel_count] |= MODE_CHANOP;
break;
case '@':
- discrim->chan_req_modes |= MODE_CHANOP;
+ discrim->chan_req_modes[discrim->channel_count] |= MODE_CHANOP;
break;
case '\0':
send_message(user, opserv, "MSG_NOT_CHANNEL_NAME");
goto fail;
}
}
- find_channel:
- discrim->chan_no_modes &= ~discrim->chan_req_modes;
- if (!(discrim->channel = GetChannel(argv[i]+j))) {
+ find_channel:
+ discrim->chan_no_modes[discrim->channel_count] &= ~discrim->chan_req_modes[discrim->channel_count];
+ if (!(discrim->channels[discrim->channel_count] = GetChannel(argv[i]+j))) {
/* secretly "allow_channel" now means "if a channel name is
* specified, require that it currently exist" */
if (allow_channel) {
send_message(user, opserv, "MSG_CHANNEL_UNKNOWN", argv[i]);
goto fail;
} else {
- discrim->channel = AddChannel(argv[i]+j, now, NULL, NULL);
+ discrim->channels[discrim->channel_count] = AddChannel(argv[i]+j, now, NULL, NULL);
}
- }
- LockChannel(discrim->channel);
+ }
+ LockChannel(discrim->channels[discrim->channel_count]);
+ discrim->channel_count++;
} else if (irccasecmp(argv[i], "numchannels") == 0) {
discrim->min_channels = discrim->max_channels = strtoul(argv[++i], NULL, 10);
- } else if (irccasecmp(argv[i], "limit") == 0) {
- discrim->limit = strtoul(argv[++i], NULL, 10);
+ } else if (irccasecmp(argv[i], "limit") == 0) {
+ discrim->limit = strtoul(argv[++i], NULL, 10);
} else if (irccasecmp(argv[i], "reason") == 0) {
discrim->reason = strdup(unsplit_string(argv+i+1, argc-i-1, NULL));
i = argc;
+ } else if (irccasecmp(argv[i], "notice_target") == 0 || irccasecmp(argv[i], "target") == 0) {
+ if (!IsChannelName(argv[i + 1])) {
+ send_message(user, opserv, "MSG_NOT_CHANNEL_NAME");
+ goto fail;
+ }
+ discrim->notice_target = argv[++i];
} else if (irccasecmp(argv[i], "last") == 0) {
discrim->min_ts = now - ParseInterval(argv[++i]);
} else if ((irccasecmp(argv[i], "linked") == 0)
}
if (discrim->mask_nick && !strcmp(discrim->mask_nick, "*")) {
- discrim->mask_nick = 0;
+ discrim->mask_nick = 0;
}
if (discrim->mask_ident && !strcmp(discrim->mask_ident, "*")) {
discrim->mask_ident = 0;
}
if (discrim->mask_info && !strcmp(discrim->mask_info, "*")) {
- discrim->mask_info = 0;
+ discrim->mask_info = 0;
}
if (discrim->mask_host && !discrim->mask_host[strspn(discrim->mask_host, "*.")]) {
discrim->mask_host = 0;
static int
discrim_match(discrim_t discrim, struct userNode *user)
{
- unsigned int access;
+ unsigned int access, i;
if ((user->timestamp < discrim->min_ts)
|| (user->timestamp > discrim->max_ts)
|| (discrim->ip_mask_bits && !irc_check_mask(&user->ip, &discrim->ip_mask, discrim->ip_mask_bits))
)
return 0;
- if (discrim->channel && !GetUserMode(discrim->channel, user))
- return 0;
+ for(i = 0; i < discrim->channel_count; i++)
+ if (!GetUserMode(discrim->channels[i], user))
+ return 0;
access = user->handle_info ? user->handle_info->opserv_level : 0;
if ((access < discrim->min_level)
|| (access > discrim->max_level)) {
static unsigned int
opserv_discrim_search(discrim_t discrim, discrim_search_func dsf, void *data)
{
- unsigned int nn, count;
+ unsigned int nn, count, match;
struct userList matched;
userList_init(&matched);
/* Try most optimized search methods first */
- if (discrim->channel) {
- for (nn=0;
- (nn < discrim->channel->members.used)
- && (matched.used < discrim->limit);
- nn++) {
- struct modeNode *mn = discrim->channel->members.list[nn];
- if (((mn->modes & discrim->chan_req_modes) != discrim->chan_req_modes)
- || ((mn->modes & discrim->chan_no_modes) != 0)) {
+ if (discrim->channel_count)
+ {
+ for (nn=0; (nn < discrim->channels[0]->members.used)
+ && (matched.used < discrim->limit);
+ nn++) {
+ struct modeNode *mn = discrim->channels[0]->members.list[nn];
+
+ if (((mn->modes & discrim->chan_req_modes[0]) != discrim->chan_req_modes[0])
+ || ((mn->modes & discrim->chan_no_modes[0]) != 0)) {
continue;
}
- if (discrim_match(discrim, mn->user)) {
- userList_append(&matched, mn->user);
+
+ if ((match = discrim_match(discrim, mn->user)))
+ {
+ unsigned int i;
+
+ for (i = 1; i < discrim->channel_count; i++) {
+ struct modeNode *mn2 = GetUserMode(discrim->channels[i], mn->user);
+
+ if (((mn2->modes & discrim->chan_req_modes[i]) != discrim->chan_req_modes[i])
+ || ((mn2->modes & discrim->chan_no_modes[i]) != 0)) {
+ match = 0;
+ break;
+ }
+ }
+
+ if (match)
+ userList_append(&matched, mn->user);
}
}
} else if (discrim->ip_mask_bits == 128) {
log_module(OS_LOG, LOG_INFO, " %s!%s@%s", user->nick, user->ident, user->hostname);
}
if (dsf(user, data)) {
- /* If a search function returns true, it ran into a
- problem. Stop going through the list. */
- break;
- }
+ /* If a search function returns true, it ran into a
+ problem. Stop going through the list. */
+ break;
+ }
}
if (discrim->option_log) {
log_module(OS_LOG, LOG_INFO, "End of matching users.");
}
static int
-is_oper_victim(struct userNode *user, struct userNode *target, int match_opers)
+is_oper_victim(struct userNode *user, struct userNode *target, int match_opers, int check_ip)
{
- return !(IsService(target)
- || (!match_opers && IsOper(target))
- || (target->handle_info
- && target->handle_info->opserv_level > user->handle_info->opserv_level));
+ unsigned char is_victim;
+ unsigned int nn;
+
+ is_victim = !(IsService(target)
+ || (!match_opers && IsOper(target))
+ || (target->handle_info
+ && target->handle_info->opserv_level > user->handle_info->opserv_level));
+
+ /* If we don't need an ip check or want to hit opers or the the "cheap" check already disqualified the target, we are done. */
+ if (!check_ip || match_opers || !is_victim)
+ return is_victim;
+
+ for(nn = 0; nn < curr_opers.used; nn++) {
+ if(memcmp(&curr_opers.list[nn]->ip, &target->ip, sizeof(irc_in_addr_t)) == 0)
+ return 0;
+ }
+
+ return 1;
}
static int
{
struct discrim_and_source *das = extra;
- if (is_oper_victim(das->source, match, das->discrim->match_opers) && is_trust_victim(match, das->discrim->match_trusted)) {
+ if (is_oper_victim(das->source, match, das->discrim->match_opers, 1) && is_trust_victim(match, das->discrim->match_trusted)) {
opserv_block(match, das->source->handle_info->handle, das->discrim->reason, das->discrim->duration);
}
{
struct discrim_and_source *das = extra;
- if (is_oper_victim(das->source, match, das->discrim->match_opers) && is_trust_victim(match, das->discrim->match_trusted)) {
- char *reason;
+ if (is_oper_victim(das->source, match, das->discrim->match_opers, 0) && is_trust_victim(match, das->discrim->match_trusted)) {
+ char *reason;
if (das->discrim->reason) {
reason = das->discrim->reason;
} else {
{
struct discrim_and_source *das = extra;
- if (is_oper_victim(das->source, match, das->discrim->match_opers) && is_trust_victim(match, das->discrim->match_trusted)) {
+ if (is_oper_victim(das->source, match, das->discrim->match_opers, 1) && is_trust_victim(match, das->discrim->match_trusted)) {
char *reason, *mask;
int masksize;
if (das->discrim->reason) {
reason = alloca(strlen(OSMSG_GAG_REQUESTED)+strlen(das->source->nick)+1);
sprintf(reason, OSMSG_GAG_REQUESTED, das->source->nick);
}
- masksize = 5+strlen(match->hostname);
- mask = alloca(masksize);
+ masksize = 5+strlen(match->hostname);
+ mask = alloca(masksize);
snprintf(mask, masksize, "*!*@%s", match->hostname);
- if (!is_gagged(mask)) {
+ if (!is_gagged(mask)) {
gag_create(mask, das->source->handle_info->handle, reason,
das->discrim->duration ? (now + das->discrim->duration) : 0);
}
{
struct discrim_and_source das;
discrim_search_func action;
- unsigned int matches;
+ unsigned int matches, i;
struct svccmd *subcmd;
char buf[MAXLEN];
sprintf(buf, "trace %s", argv[1]);
if (!(subcmd = dict_find(cmd->parent->commands, buf, NULL))) {
- reply("OSMSG_BAD_ACTION", argv[1]);
+ reply("OSMSG_BAD_ACTION", argv[1]);
return 0;
}
if (!svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, SVCCMD_NOISY))
else if (!irccasecmp(argv[1], "gag"))
action = trace_gag_func;
else {
- reply("OSMSG_BAD_ACTION", argv[1]);
- return 0;
+ reply("OSMSG_BAD_ACTION", argv[1]);
+ return 0;
}
if (user->handle_info->opserv_level < subcmd->min_opserv_level) {
return 0;
if (action == trace_print_func)
- reply("OSMSG_USER_SEARCH_RESULTS");
+ reply("OSMSG_USER_SEARCH_RESULTS");
else if (action == trace_count_func)
- das.discrim->limit = INT_MAX;
+ das.discrim->limit = INT_MAX;
else if ((action == trace_gline_func) && !das.discrim->duration)
das.discrim->duration = opserv_conf.block_gline_duration;
else if (action == trace_domains_func) {
dict_foreach(das.dict, opserv_show_hostinfo, &das);
if (matches)
- reply("MSG_MATCH_COUNT", matches);
+ reply("MSG_MATCH_COUNT", matches);
else
- reply("MSG_NO_MATCHES");
+ reply("MSG_NO_MATCHES");
- if (das.discrim->channel)
- UnlockChannel(das.discrim->channel);
+ for (i = 0; i < das.discrim->channel_count; i++)
+ UnlockChannel(das.discrim->channels[i]);
free(das.discrim->reason);
free(das.discrim);
dict_delete(das.dict);
discrim->max_ts = (1ul << (CHAR_BIT * sizeof(time_t) - 1)) - 1;
for (i = 0; i < argc; i++) {
- /* Assume all criteria require arguments. */
- if (i == (argc - 1)) {
- send_message(user, opserv, "MSG_MISSING_PARAMS", argv[i]);
- return NULL;
- }
-
- if (!irccasecmp(argv[i], "name"))
- discrim->name = argv[++i];
- else if (!irccasecmp(argv[i], "topic"))
- discrim->topic = argv[++i];
- else if (!irccasecmp(argv[i], "users")) {
- const char *cmp = argv[++i];
+ /* Assume all criteria require arguments. */
+ if (i == (argc - 1)) {
+ send_message(user, opserv, "MSG_MISSING_PARAMS", argv[i]);
+ return NULL;
+ }
+
+ if (!irccasecmp(argv[i], "name"))
+ discrim->name = argv[++i];
+ else if (!irccasecmp(argv[i], "topic"))
+ discrim->topic = argv[++i];
+ else if (!irccasecmp(argv[i], "users")) {
+ const char *cmp = argv[++i];
if (cmp[0] == '<') {
if (cmp[1] == '=')
discrim->max_users = strtoul(cmp+2, NULL, 0);
} else {
discrim->min_users = strtoul(cmp, NULL, 0);
}
- } else if (!irccasecmp(argv[i], "timestamp")) {
- const char *cmp = argv[++i];
+ } else if (!irccasecmp(argv[i], "timestamp")) {
+ const char *cmp = argv[++i];
if (cmp[0] == '<') {
if (cmp[1] == '=')
discrim->max_ts = smart_parse_time(cmp+2);
} else {
discrim->min_ts = smart_parse_time(cmp);
}
- } else if (!irccasecmp(argv[i], "limit")) {
- discrim->limit = strtoul(argv[++i], NULL, 10);
- } else {
- send_message(user, opserv, "MSG_INVALID_CRITERIA", argv[i]);
- goto fail;
- }
+ } else if (!irccasecmp(argv[i], "limit")) {
+ discrim->limit = strtoul(argv[++i], NULL, 10);
+ } else {
+ send_message(user, opserv, "MSG_INVALID_CRITERIA", argv[i]);
+ goto fail;
+ }
}
if (discrim->name && !strcmp(discrim->name, "*"))
- discrim->name = 0;
+ discrim->name = 0;
if (discrim->topic && !strcmp(discrim->topic, "*"))
- discrim->topic = 0;
+ discrim->topic = 0;
return discrim;
fail:
(chan->members.used > discrim->max_users) ||
(chan->timestamp < discrim->min_ts) ||
(chan->timestamp > discrim->max_ts)) {
- return 0;
+ return 0;
}
return 1;
}
dict_iterator_t it, next;
for (it = dict_first(channels); it && count < discrim->limit ; it = next) {
- struct chanNode *chan = iter_data(it);
+ struct chanNode *chan = iter_data(it);
- /* Hold on to the next channel in case we decide to
- add actions that destructively modify the channel. */
- next = iter_next(it);
- if ((chan->members.used > 0) && cdiscrim_match(discrim, chan)) {
- dsf(chan, data);
- count++;
- }
+ /* Hold on to the next channel in case we decide to
+ add actions that destructively modify the channel. */
+ next = iter_next(it);
+ if ((chan->members.used > 0) && cdiscrim_match(discrim, chan)) {
+ dsf(chan, data);
+ count++;
+ }
}
return count;
char buf[MAXLEN];
if (!irccasecmp(argv[1], "count"))
- action = channel_count;
+ action = channel_count;
else if (!irccasecmp(argv[1], "print"))
- action = channel_print;
+ action = channel_print;
else {
- reply("OSMSG_BAD_ACTION", argv[1]);
- return 0;
+ reply("OSMSG_BAD_ACTION", argv[1]);
+ return 0;
}
sprintf(buf, "%s %s", argv[0], argv[0]);
discrim = opserv_cdiscrim_create(user, argc - 2, argv + 2);
if (!discrim)
- return 0;
+ return 0;
if (action == channel_print)
- reply("OSMSG_CHANNEL_SEARCH_RESULTS");
+ reply("OSMSG_CHANNEL_SEARCH_RESULTS");
else if (action == channel_count)
- discrim->limit = INT_MAX;
+ discrim->limit = INT_MAX;
matches = opserv_cdiscrim_search(discrim, action, user);
if (matches)
- reply("MSG_MATCH_COUNT", matches);
+ reply("MSG_MATCH_COUNT", matches);
else
- reply("MSG_NO_MATCHES");
+ reply("MSG_NO_MATCHES");
free(discrim);
return 1;
log_module(OS_LOG, LOG_ERROR, "Invalid reaction type %d for alert %s.", alert->reaction, key);
/* fall through to REACT_NOTICE case */
case REACT_NOTICE:
- opserv_alert("Alert $b%s$b triggered by user $b%s$b!%s@%s (%s).", key, user->nick, user->ident, user->hostname, alert->discrim->reason);
+ opserv_custom_alert(alert->discrim->notice_target, "Alert $b%s$b triggered by user $b%s$b!%s@%s (%s).", key, user->nick, user->ident, user->hostname, alert->discrim->reason);
break;
}
return 0;
matches = log_entry_search(discrim, log_report_entry, &report);
if (matches)
- reply("MSG_MATCH_COUNT", matches);
+ reply("MSG_MATCH_COUNT", matches);
else
- reply("MSG_NO_MATCHES");
+ reply("MSG_NO_MATCHES");
free(discrim);
return 1;
reason = unsplit_string(argv + 3, argc - 3, NULL);
if (!is_ircmask(argv[1])) {
- reply("OSMSG_INVALID_IRCMASK", argv[1]);
+ reply("OSMSG_INVALID_IRCMASK", argv[1]);
return 0;
}
for (gag = gagList; gag; gag = gag->next)
- if (match_ircglobs(gag->mask, argv[1]))
+ if (match_ircglobs(gag->mask, argv[1]))
break;
if (gag) {
- reply("OSMSG_REDUNDANT_GAG", argv[1]);
- return 0;
+ reply("OSMSG_REDUNDANT_GAG", argv[1]);
+ return 0;
}
duration = ParseInterval(argv[2]);
gagged = gag_create(argv[1], user->handle_info->handle, reason, (duration?now+duration:0));
if (gagged)
- reply("OSMSG_GAG_APPLIED", argv[1], gagged);
+ reply("OSMSG_GAG_APPLIED", argv[1], gagged);
else
- reply("OSMSG_GAG_ADDED", argv[1]);
+ reply("OSMSG_GAG_ADDED", argv[1]);
return 1;
}
unsigned int ungagged;
for (gag = gagList; gag; gag = gag->next)
- if (!strcmp(gag->mask, argv[1]))
+ if (!strcmp(gag->mask, argv[1]))
break;
if (!gag) {
- reply("OSMSG_GAG_NOT_FOUND", argv[1]);
- return 0;
+ reply("OSMSG_GAG_NOT_FOUND", argv[1]);
+ return 0;
}
timeq_del(gag->expires, gag_expire, gag, 0);
ungagged = gag_free(gag);
if (ungagged)
- reply("OSMSG_UNGAG_APPLIED", argv[1], ungagged);
+ reply("OSMSG_UNGAG_APPLIED", argv[1], ungagged);
else
- reply("OSMSG_UNGAG_ADDED", argv[1]);
+ reply("OSMSG_UNGAG_ADDED", argv[1]);
return 1;
}
name = argv[1];
sprintf(buf, "addalert %s", argv[2]);
if (!(subcmd = dict_find(cmd->parent->commands, buf, NULL))) {
- reply("OSMSG_UNKNOWN_REACTION", argv[2]);
- return 0;
+ reply("OSMSG_UNKNOWN_REACTION", argv[2]);
+ return 0;
}
if (!irccasecmp(argv[2], "notice"))
reaction = REACT_NOTICE;
else if (!irccasecmp(argv[2], "gline"))
reaction = REACT_GLINE;
else {
- reply("OSMSG_UNKNOWN_REACTION", argv[2]);
- return 0;
+ reply("OSMSG_UNKNOWN_REACTION", argv[2]);
+ return 0;
}
if (!svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, SVCCMD_NOISY)
|| !opserv_add_user_alert(user, name, reaction, unsplit_string(argv + 3, argc - 3, NULL)))
rd = conf_get_node(OPSERV_CONF_NAME);
if (!rd || rd->type != RECDB_OBJECT) {
- log_module(OS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", OPSERV_CONF_NAME);
- return;
+ log_module(OS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", OPSERV_CONF_NAME);
+ return;
}
conf_node = rd->d.object;
str = database_get_data(conf_node, KEY_DEBUG_CHANNEL, RECDB_QSTRING);
str2 = database_get_data(conf_node, KEY_DEBUG_CHANNEL_MODES, RECDB_QSTRING);
if (!str2)
str2 = "+tinms";
- opserv_conf.debug_channel = AddChannel(str, now, str2, NULL);
+ opserv_conf.debug_channel = AddChannel(str, now, str2, NULL);
AddChannelUser(opserv, opserv_conf.debug_channel)->modes |= MODE_CHANOP;
} else {
- opserv_conf.debug_channel = NULL;
+ opserv_conf.debug_channel = NULL;
}
str = database_get_data(conf_node, KEY_ALERT_CHANNEL, RECDB_QSTRING);
if (opserv && str) {
str2 = database_get_data(conf_node, KEY_ALERT_CHANNEL_MODES, RECDB_QSTRING);
if (!str2)
str2 = "+tns";
- opserv_conf.alert_channel = AddChannel(str, now, str2, NULL);
+ opserv_conf.alert_channel = AddChannel(str, now, str2, NULL);
AddChannelUser(opserv, opserv_conf.alert_channel)->modes |= MODE_CHANOP;
} else {
- opserv_conf.alert_channel = NULL;
+ opserv_conf.alert_channel = NULL;
}
str = database_get_data(conf_node, KEY_STAFF_AUTH_CHANNEL, RECDB_QSTRING);
if (opserv && str) {
policer_params_set(opserv_conf.join_policer_params, "size", "20");
policer_params_set(opserv_conf.join_policer_params, "drain-rate", "1");
if ((child = database_get_data(conf_node, KEY_JOIN_POLICER, RECDB_OBJECT)))
- dict_foreach(child, set_policer_param, opserv_conf.join_policer_params);
+ dict_foreach(child, set_policer_param, opserv_conf.join_policer_params);
for (it = dict_first(channels); it; it = iter_next(it)) {
struct chanNode *cNode = iter_data(it);
policer_params_set(pp, "size", "200");
policer_params_set(pp, "drain-rate", "3");
if ((child = database_get_data(conf_node, KEY_NEW_USER_POLICER, RECDB_OBJECT)))
- dict_foreach(child, set_policer_param, pp);
+ dict_foreach(child, set_policer_param, pp);
}
static void
opserv_define_func("GTRACE PRINT", NULL, 0, 0, 0);
opserv_define_func("INVITE", cmd_invite, 100, 2, 0);
opserv_define_func("INVITEME", cmd_inviteme, 100, 0, 0);
- opserv_define_func("JOIN", cmd_join, 601, 0, 2);
+ opserv_define_func("JOIN", cmd_join, 601, 1, 0);
opserv_define_func("JUMP", cmd_jump, 900, 0, 2);
opserv_define_func("JUPE", cmd_jupe, 900, 0, 4);
opserv_define_func("KICK", cmd_kick, 100, 2, 2);
+ opserv_define_func("FORCEKICK", cmd_forcekick, 800, 2, 2);
opserv_define_func("KICKALL", cmd_kickall, 400, 2, 0);
opserv_define_func("KICKBAN", cmd_kickban, 100, 2, 2);
opserv_define_func("KICKBANALL", cmd_kickbanall, 450, 2, 0);
opserv_define_func("MODE", cmd_mode, 100, 2, 2);
opserv_define_func("OP", cmd_op, 100, 2, 2);
opserv_define_func("OPALL", cmd_opall, 400, 2, 0);
- opserv_define_func("PART", cmd_part, 601, 0, 2);
+ opserv_define_func("PART", cmd_part, 601, 2, 0);
opserv_define_func("QUERY", cmd_query, 0, 0, 0);
opserv_define_func("RAW", cmd_raw, 999, 0, 2);
opserv_define_func("RECONNECT", cmd_reconnect, 900, 0, 0);