#include "chanserv.h"
#include "hash.h"
#include "helpfile.h"
-#include "hosthiding.h"
#include "proto-common.c"
#include "opserv.h"
#define CMD_SVSPART "SVSPART"
#define CMD_SVSQUIT "SVSQUIT"
#define CMD_SWHOIS "SWHOIS"
+#define CMD_TEMPSHUN "TEMPSHUN"
#define CMD_TIME "TIME"
#define CMD_TOPIC "TOPIC"
#define CMD_TRACE "TRACE"
#define TOK_SVSPART "SP"
#define TOK_SVSQUIT "SX"
#define TOK_SWHOIS "SW"
+#define TOK_TEMPSHUN "TS"
#define TOK_TIME "TI"
#define TOK_TOPIC "T"
#define TOK_TRACE "TR"
#define P10_SVSPART TYPE(SVSPART)
#define P10_SVSQUIT TYPE(SVSQUIT)
#define P10_SWHOIS TYPE(SWHOIS)
+#define P10_TEMPSHUN TYPE(TEMPSHUN)
#define P10_TIME TYPE(TIME)
#define P10_TOPIC TYPE(TOPIC)
#define P10_TRACE TYPE(TRACE)
}
+void
+irc_tempshun(struct userNode *from, struct userNode *target, int remove, const char *reason)
+{
+ putsock("%s " P10_TEMPSHUN " %s %s :%s", from->numeric, (remove ? "-" : "+"), target->numeric, reason);
+}
+
void
irc_part(struct userNode *who, struct chanNode *what, const char *reason)
{
if (!serv)
return 0;
- call_sasl_input_func(serv, argv[2], argv[3], argv[4], (argc>5 ? argv[5] : NULL));
+ call_sasl_input_func(serv, argv[2], argv[3], argv[4], (argc>5 ? argv[argc-1] : NULL));
return 1;
}
NickChange(user, argv[1], 1);
} else {
struct server *serv;
- struct userNode *nuser;
char modes[MAXLEN];
/* new nick */
if (argc < 9)
unsplit_string(argv+6, argc-9, modes);
else
strcpy(modes, "+");
- nuser = AddUser(serv, argv[1], argv[4], argv[5], modes, argv[argc-2], argv[argc-1], atoi(argv[3]), argv[argc-3]);
+ AddUser(serv, argv[1], argv[4], argv[5], modes, argv[argc-2], argv[argc-1], atoi(argv[3]), argv[argc-3]);
}
return 1;
}
return res;
}
-/* TODO:
+/* TODO:
* This is a stub that doesn't actually do anything. It should be completed
* so that bans on *!*@markname.* match users as it does in nefarious
*/
const char *tstr;
int type = 4;
struct userNode *target;
- /*
+ /*
* log_module(MAIN_LOG, LOG_ERROR, "DEBUG: mark, user %s, type %s, arg %s", argv[1], argv[2], argv[3]);
*/
} else
target->mark = strdup(argv[3]);
return 1;
-
+
}
else if(!strcasecmp(argv[2], "CVERSION")) {
/* CTCP VERSION mark */
target->sslfp = strdup(sslfp);
+ nickserv_do_autoauth(target);
+
return 1;
}
/* unknown type of mark */
static CMD_FUNC(cmd_topic)
{
struct chanNode *cn;
- time_t chan_ts, topic_ts;
+ time_t topic_ts;
struct userNode *user;
if (argc < 3)
if (argc == 5) { /* Asuka / Topic Bursting IRCu's */
user = GetUserH(origin);
- chan_ts = atoi(argv[2]);
topic_ts = atoi(argv[3]);
} else if (argc >= 6) { /* Nefarious 0.5.0 */
user = GetUserH(strtok(argv[2], "!"));
- chan_ts = atoi(argv[3]);
topic_ts = atoi(argv[4]);
} else { /* Regular IRCu (No Topic Bursting)*/
user = GetUserH(origin);
- chan_ts = cn->timestamp;
topic_ts = now;
}
if (argc < 2)
return 0;
- user = GetUserN(argv[1]);
+ if (strncmp(argv[1], "*", 2) == 0)
+ {
+ if (!(user = GetUserH(origin))) {
+ log_module(MAIN_LOG, LOG_ERROR, "Could not find SILENCE origin user %s", origin);
+ return 0;
+ }
+ }
+ else
+ user = GetUserN(argv[1]);
/* Sanity, go nuts if this happens */
if (!user)
{
struct privmsg_desc pd;
struct server *srv;
- int nuser = 0;
if (argc != 3)
return 0;
pd.user = GetUserH(origin);
- if(!pd.user)
- nuser = 1;
if (!pd.user || (IsGagged(pd.user) && !IsOper(pd.user))) {
}
else {
dict_insert(irc_func_dict, TOK_SVSPART, cmd_svspart);
dict_insert(irc_func_dict, CMD_SWHOIS, cmd_dummy);
dict_insert(irc_func_dict, TOK_SWHOIS, cmd_dummy);
+ dict_insert(irc_func_dict, CMD_TEMPSHUN, cmd_dummy);
+ dict_insert(irc_func_dict, TOK_TEMPSHUN, cmd_dummy);
dict_insert(irc_func_dict, CMD_WHOIS, cmd_whois);
dict_insert(irc_func_dict, TOK_WHOIS, cmd_whois);
dict_insert(irc_func_dict, CMD_GLINE, cmd_gline);
{
struct userNode *oldUser, *uNode;
unsigned int ignore_user, dummy;
- char *tstr;
- int type;
if ((strlen(numeric) < 3) || (strlen(numeric) > 5)) {
log_module(MAIN_LOG, LOG_WARNING, "AddUser(%p, %s, ...): numeric %s wrong length!", (void*)uplink, nick, numeric);
safestrncpy(uNode->numeric, numeric, sizeof(uNode->numeric));
irc_p10_pton(&uNode->ip, realip);
- tstr = conf_get_data("server/type", RECDB_QSTRING);
- type = atoi(tstr);
- if (type == 7) {
- if (irc_in_addr_is_ipv4(uNode->ip)) {
- make_virtip((char*)irc_ntoa(&uNode->ip), (char*)irc_ntoa(&uNode->ip), uNode->cryptip);
- make_virthost((char*)irc_ntoa(&uNode->ip), uNode->hostname, uNode->crypthost);
- } else if (irc_in_addr_is_ipv6(uNode->ip)) {
- make_ipv6virthost((char*)irc_ntoa(&uNode->ip), uNode->hostname, uNode->crypthost);
- }
- }
-
if (!uNode->crypthost && uNode->cryptip)
snprintf(uNode->crypthost, sizeof(uNode->crypthost), "%s", strdup(uNode->cryptip));
uNode->idle_since = timestamp;
user->uplink->clients--;
user->uplink->users[user->num_local] = NULL;
- if (IsOper(user))
+ if (IsOper(user)) {
userList_remove(&curr_opers, user);
+ if (count_opers > 0 && !IsBotM(user) && !IsService(user) && !IsHideOper(user))
+ count_opers--;
+ }
/* remove from global dictionary, but not if after a collide */
if (user == dict_find(clients, user->nick, NULL))
dict_remove(clients, user->nick);
void mod_usermode(struct userNode *user, const char *mode_change) {
int add = 1;
+ long setmodes = 0;
+ int donemodes = 0;
const char *word = mode_change;
if (!user || !mode_change)
call_user_mode_funcs(user, mode_change);
+ setmodes = user->modes;
+
while (*word != ' ' && *word) word++;
while (*word == ' ') word++;
- while (1) {
+ while (!donemodes) {
#define do_user_mode(FLAG) do { if (add) user->modes |= FLAG; else user->modes &= ~FLAG; } while (0)
switch (*mode_change++) {
- case 0: case ' ': return;
+ case 0: case ' ':
+ donemodes = 1;
+ break;
case '+': add = 1; break;
case '-': add = 0; break;
case 'o':
case 'g': do_user_mode(FLAGS_GLOBAL); break;
case 'B': do_user_mode(FLAGS_BOT); break;
case 'n': do_user_mode(FLAGS_HIDECHANS); break;
+ case 'p': do_user_mode(FLAGS_HIDECHANS); break;
case 'I': do_user_mode(FLAGS_HIDEIDLE); break;
case 'X': do_user_mode(FLAGS_XTRAOP); break;
case 'C': do_user_mode(FLAGS_CLOAKHOST);
}
#undef do_user_mode
}
+
+ // Set user mode +o
+ if (!(setmodes & FLAGS_OPER) && IsOper(user)) {
+ if (!IsBotM(user) && !IsService(user) && !IsHideOper(user))
+ count_opers++;
+ }
+
+ // Set user mode -o
+ if ((setmodes & FLAGS_OPER) && !IsOper(user)) {
+ if (count_opers > 1 && !(setmodes & FLAGS_BOT) &&
+ !(setmodes & FLAGS_SERVICE) && !(setmodes & FLAGS_HIDEOPER))
+ count_opers--;
+ }
+
+ // Set +H, +k or +B
+ if (!(setmodes & FLAGS_HIDEOPER) &&
+ !(setmodes & FLAGS_SERVICE) &&
+ !(setmodes & FLAGS_BOT) &&
+ (IsHideOper(user) || IsService(user) || IsBotM(user))) {
+ if ((setmodes & FLAGS_OPER) && IsOper(user) && count_opers > 0)
+ count_opers--;
+ }
+
+ // Set -H, -k or -B
+ if (((setmodes & FLAGS_HIDEOPER) ||
+ (setmodes & FLAGS_SERVICE) ||
+ (setmodes & FLAGS_BOT)) &&
+ !IsHideOper(user) && !IsService(user) && !IsBotM(user)) {
+ if ((setmodes & FLAGS_OPER) && IsOper(user))
+ count_opers++;
+ }
}
static int