1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 14:16:37 +02:00

Missed OCDing over src/protocol/*, plus fixed a minor lack of braces and fixed Config to work in an out-of-source build.

This commit is contained in:
Naram Qashat
2010-06-29 08:21:20 -04:00
parent 950cfcd31e
commit de1bf10690
10 changed files with 733 additions and 831 deletions
+1 -1
View File
@@ -205,7 +205,7 @@ if [ ! "$NO_INTRO" ] ; then
clear
;;
esac
. src/version.sh
. $SOURCE_DIR/src/version.sh
if [ -d .git ] ; then
VERSION=`git describe --tags`
echo "#define VERSION_BUILD `echo "$VERSION" | cut -d'-' -f2`" > include/version.h
-1
View File
@@ -175,4 +175,3 @@ void BotInfo::Part(Channel *c, const std::string &reason)
ircdproto->SendPart(this, c, !reason.empty() ? reason.c_str() : "");
c->DeleteUser(this);
}
+2
View File
@@ -141,7 +141,9 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, co
ret = c->Execute(u, params);
if (ret == MOD_CONT)
{
FOREACH_MOD(I_OnPostCommand, OnPostCommand(u, c->service, c->name.c_str(), params));
}
}
/**
+2 -6
View File
@@ -16,17 +16,13 @@ std::vector<Module *> ModuleManager::EventHandlers[I_END];
void ModuleManager::LoadModuleList(std::list<std::string> &ModuleList)
{
for (std::list<std::string>::iterator it = ModuleList.begin(), it_end = ModuleList.end(); it != it_end; ++it)
{
ModuleManager::LoadModule(*it, NULL);
}
}
void ModuleManager::LoadModuleList(std::list<ci::string> &ModuleList)
{
for (std::list<ci::string>::iterator it = ModuleList.begin(), it_end = ModuleList.end(); it != it_end; ++it)
{
ModuleManager::LoadModule(*it, NULL);
}
}
/**
@@ -284,7 +280,7 @@ void ModuleManager::DeleteModule(Module *m)
{
if (!m || !m->handle)
return;
const char *err;
void (*destroy_func)(Module *m);
@@ -307,7 +303,7 @@ void ModuleManager::DeleteModule(Module *m)
if (dlclose(handle))
Alog() << dlerror();
}
if (!filename.empty())
DeleteFile(filename.c_str());
}
+73 -76
View File
@@ -17,41 +17,41 @@
#include "modules.h"
IRCDVar myIrcd[] = {
{"Bahamut 1.8.x", /* ircd name */
"+", /* Modes used by pseudoclients */
2, /* Chan Max Symbols */
"+o", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
0, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
3, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
0, /* TS Topic Forward */
0, /* TS Topci Backward */
1, /* Chan SQlines */
1, /* Quit on Kill */
1, /* SVSMODE unban */
0, /* Reverse */
0, /* vidents */
1, /* svshold */
1, /* time stamp on mode */
1, /* NICKIP */
0, /* O:LINE */
1, /* UMODE */
0, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
0, /* p10 */
0, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
{"Bahamut 1.8.x", /* ircd name */
"+", /* Modes used by pseudoclients */
2, /* Chan Max Symbols */
"+o", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
0, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
3, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
0, /* TS Topic Forward */
0, /* TS Topci Backward */
1, /* Chan SQlines */
1, /* Quit on Kill */
1, /* SVSMODE unban */
0, /* Reverse */
0, /* vidents */
1, /* svshold */
1, /* time stamp on mode */
1, /* NICKIP */
0, /* O:LINE */
1, /* UMODE */
0, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
0, /* p10 */
0, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
6, /* Max number of modes we can send per line */
}
,
@@ -85,24 +85,22 @@ void bahamut_cmd_pass(const char *pass)
/* CAPAB */
void bahamut_cmd_capab()
{
send_cmd(NULL,
"CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
send_cmd(NULL, "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
}
/* this avoids "undefined symbol" messages of those whom try to load mods that
call on this function */
void bahamut_cmd_chghost(const char *nick, const char *vhost)
{
Alog(LOG_DEBUG) << "This IRCD does not support vhosting";
Alog(LOG_DEBUG) << "This IRCD does not support vhosting";
}
class BahamutIRCdProto : public IRCDProto
{
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
if (!buf)
return;
if (Capab.HasFlag(CAPAB_TSMODE))
send_cmd(source->nick, "MODE %s 0 %s", dest->name.c_str(), buf);
else
@@ -111,7 +109,8 @@ class BahamutIRCdProto : public IRCDProto
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(bi ? bi->nick : Config.ServerName, "SVSMODE %s %ld %s", u->nick.c_str(), static_cast<long>(u->timestamp), buf);
}
@@ -136,8 +135,10 @@ class BahamutIRCdProto : public IRCDProto
/* SVSMODE channel modes */
void SendSVSModeChan(Channel *c, const char *mode, const char *nick)
{
if (nick) send_cmd(Config.ServerName, "SVSMODE %s %s %s", c->name.c_str(), mode, nick);
else send_cmd(Config.ServerName, "SVSMODE %s %s", c->name.c_str(), mode);
if (nick)
send_cmd(Config.ServerName, "SVSMODE %s %s %s", c->name.c_str(), mode, nick);
else
send_cmd(Config.ServerName, "SVSMODE %s %s", c->name.c_str(), mode);
}
/* SQLINE */
@@ -210,7 +211,8 @@ class BahamutIRCdProto : public IRCDProto
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - time(NULL);
if (timeleft > 172800) timeleft = 172800;
if (timeleft > 172800)
timeleft = 172800;
send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", x->GetHost().c_str(), x->GetUser().c_str(), static_cast<int>(timeleft), x->By.c_str(), static_cast<long>(time(NULL)), x->Reason.c_str());
}
@@ -241,14 +243,17 @@ class BahamutIRCdProto : public IRCDProto
void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(NULL, "NOTICE @%s :%s", dest->name.c_str(), buf);
}
void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
{
if (buf) send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
else send_cmd(source->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
if (buf)
send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
else
send_cmd(source->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
}
void SendClientIntroduction(const std::string &nick, const std::string &user, const std::string &host, const std::string &real, const char *modes, const std::string &uid)
@@ -299,10 +304,8 @@ class BahamutIRCdProto : public IRCDProto
u->SetMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d %s", svidbuf);
}
} ircd_proto;
/* EVENT: SJOIN */
int anope_event_sjoin(const char *source, int ac, const char **av)
{
@@ -353,11 +356,11 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */
else
keep_their_modes = false;
/* Mark the channel as syncing */
if (was_created)
c->SetFlag(CH_SYNCING);
/* If we need to keep their modes, and this SJOIN string contains modes */
if (keep_their_modes && ac >= 4)
{
@@ -372,9 +375,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
{
User *u = finduser(source);
if (!u)
{
Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << source << " on " << c->name;
}
else
{
EventReturn MOD_RESULT;
@@ -436,10 +437,8 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Update their status internally on the channel
* This will enforce secureops etc on the user
*/
for (std::list<ChannelMode *>::iterator it = Status.begin(); it != Status.end(); ++it)
{
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it)
c->SetModeInternal(*it, buf);
}
/* Now set whatever modes this user is allowed to have on the channel */
chan_set_correct_modes(u, c, 1);
@@ -494,11 +493,11 @@ int anope_event_nick(const char *source, int ac, const char **av)
{
User *user;
if (ac != 2) {
user = do_nick(source, av[0], av[4], av[5], av[6], av[9],
strtoul(av[2], NULL, 10), strtoul(av[8], NULL, 0),
NULL, NULL);
if (user) {
if (ac != 2)
{
user = do_nick(source, av[0], av[4], av[5], av[6], av[9], strtoul(av[2], NULL, 10), strtoul(av[8], NULL, 0), NULL, NULL);
if (user)
{
/* Check to see if the user should be identified because their
* services id matches the one in their nickcore
*/
@@ -506,10 +505,9 @@ int anope_event_nick(const char *source, int ac, const char **av)
UserSetInternalModes(user, 1, &av[3]);
}
} else {
do_nick(source, av[0], NULL, NULL, NULL, NULL,
strtoul(av[1], NULL, 10), 0, NULL, NULL);
}
else
do_nick(source, av[0], NULL, NULL, NULL, NULL, strtoul(av[1], NULL, 10), 0, NULL, NULL);
return MOD_CONT;
}
@@ -600,9 +598,8 @@ int anope_event_part(const char *source, int ac, const char **av)
int anope_event_whois(const char *source, int ac, const char **av)
{
if (source && ac >= 1) {
if (source && ac >= 1)
m_whois(source, av[0]);
}
return MOD_CONT;
}
@@ -636,11 +633,10 @@ int anope_event_mode(const char *source, int ac, const char **av)
if (ac < 2)
return MOD_CONT;
if (*av[0] == '#' || *av[0] == '&') {
if (*av[0] == '#' || *av[0] == '&')
do_cmode(source, ac, av);
} else {
else
do_umode(source, ac, av);
}
return MOD_CONT;
}
@@ -675,9 +671,8 @@ int anope_event_join(const char *source, int ac, const char **av)
/* EVENT: MOTD */
int anope_event_motd(const char *source, int ac, const char **av)
{
if (!source) {
if (!source)
return MOD_CONT;
}
m_motd(source);
return MOD_CONT;
@@ -685,9 +680,8 @@ int anope_event_motd(const char *source, int ac, const char **av)
int anope_event_away(const char *source, int ac, const char **av)
{
if (!source) {
if (!source)
return MOD_CONT;
}
m_away(source, (ac ? av[0] : NULL));
return MOD_CONT;
}
@@ -711,9 +705,12 @@ int anope_event_burst(const char *source, int ac, const char **av)
{
Server *s = Server::Find(source ? source : "");
if (!ac) {
if (!ac)
{
/* for future use - start burst */
} else {
}
else
{
/* If we found a server with the given source, that one just
* finished bursting. If there was no source, then our uplink
* server finished bursting. -GD
+153 -175
View File
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
/*************************************************************************/
@@ -18,13 +16,13 @@
#include "hashcomp.h"
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
#endif
#ifdef _WIN32
#include <winsock.h>
# include <winsock.h>
int inet_aton(const char *name, struct in_addr *addr)
{
uint32 a = inet_addr(name);
@@ -34,63 +32,58 @@ int inet_aton(const char *name, struct in_addr *addr)
#endif
IRCDVar myIrcd[] = {
{"InspIRCd 1.1", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
4, /* Number of server args */
0, /* Join 2 Set */
1, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
1, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
0, /* p10 */
1, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
{"InspIRCd 1.1", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
4, /* Number of server args */
0, /* Join 2 Set */
1, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
1, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
0, /* p10 */
1, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
}
,
{NULL}
};
static int has_servicesmod = 0;
static int has_globopsmod = 0;
static int has_svsholdmod = 0;
static int has_chghostmod = 0;
static int has_chgidentmod = 0;
static int has_messagefloodmod = 0;
static int has_banexceptionmod = 0;
static int has_inviteexceptionmod = 0;
static int has_hidechansmod = 0;
static bool has_servicesmod = false;
static bool has_globopsmod = false;
static bool has_svsholdmod = false;
static bool has_chghostmod = false;
static bool has_chgidentmod = false;
static bool has_hidechansmod = false;
/* CHGHOST */
void inspircd_cmd_chghost(const char *nick, const char *vhost)
{
if (has_chghostmod == 1)
if (has_chghostmod)
{
if (!nick || !vhost)
return;
@@ -102,9 +95,8 @@ void inspircd_cmd_chghost(const char *nick, const char *vhost)
int anope_event_idle(const char *source, int ac, const char **av)
{
if (ac == 1) {
if (ac == 1)
send_cmd(av[0], "IDLE %s %ld 0", source, static_cast<long>(time(NULL)));
}
return MOD_CONT;
}
@@ -116,7 +108,6 @@ void inspircd_cmd_pass(const char *pass)
strlcpy(currentpass, pass, sizeof(currentpass));
}
class InspIRCdProto : public IRCDProto
{
void SendAkillDel(XLine *x)
@@ -137,9 +128,7 @@ class InspIRCdProto : public IRCDProto
inspircd_cmd_chghost(u->nick.c_str(), u->host);
if (has_chgidentmod && u->GetIdent() != u->GetVIdent())
{
inspircd_cmd_chgident(u->nick.c_str(), u->GetIdent().c_str());
}
}
void SendAkill(XLine *x)
@@ -173,13 +162,15 @@ class InspIRCdProto : public IRCDProto
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(source ? source->nick : Config.s_OperServ, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf);
}
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(bi ? bi->nick : Config.ServerName, "MODE %s %s", u->nick.c_str(), buf);
}
@@ -191,13 +182,16 @@ class InspIRCdProto : public IRCDProto
void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
{
if (buf) send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
else send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), user->nick.c_str());
if (buf)
send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
else
send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), user->nick.c_str());
}
void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(Config.ServerName, "NOTICE @%s :%s", dest->name.c_str(), buf);
}
@@ -228,7 +222,8 @@ class InspIRCdProto : public IRCDProto
/* SQUIT */
void SendSquit(const char *servname, const char *message)
{
if (!servname || !message) return;
if (!servname || !message)
return;
send_cmd(Config.ServerName, "SQUIT %s :%s", servname, message);
}
@@ -254,14 +249,14 @@ class InspIRCdProto : public IRCDProto
/* CHGIDENT */
void inspircd_cmd_chgident(const char *nick, const char *vIdent)
{
if (has_chgidentmod == 1) {
if (!nick || !vIdent || !*vIdent) {
if (has_chgidentmod)
{
if (!nick || !vIdent || !*vIdent)
return;
}
send_cmd(Config.s_OperServ, "CHGIDENT %s %s", nick, vIdent);
} else {
ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
else
ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
/* SVSHOLD - set */
@@ -323,23 +318,17 @@ class InspIRCdProto : public IRCDProto
u->SetMode(NickServ, UMODE_REGISTERED);
}
} ircd_proto;
int anope_event_ftopic(const char *source, int ac, const char **av)
{
/* :source FTOPIC channel ts setby :topic */
const char *temp;
if (ac < 4)
return MOD_CONT;
temp = av[1]; /* temp now holds ts */
av[1] = av[2]; /* av[1] now holds set by */
av[2] = temp; /* av[2] now holds ts */
temp = av[1]; /* temp now holds ts */
av[1] = av[2]; /* av[1] now holds set by */
av[2] = temp; /* av[2] now holds ts */
do_topic(source, ac, av);
return MOD_CONT;
}
@@ -349,18 +338,18 @@ int anope_event_mode(const char *source, int ac, const char **av)
if (ac < 2)
return MOD_CONT;
if (*av[0] == '#' || *av[0] == '&') {
if (*av[0] == '#' || *av[0] == '&')
do_cmode(source, ac, av);
} else {
else
{
/* InspIRCd lets opers change another
users modes, we have to kludge this
as it slightly breaks RFC1459
*/
if (!strcasecmp(source, av[0])) {
if (!strcasecmp(source, av[0]))
do_umode(source, ac, av);
} else {
else
do_umode(av[0], ac, av);
}
}
return MOD_CONT;
}
@@ -371,12 +360,14 @@ int anope_event_opertype(const char *source, int ac, const char **av)
dont do this directly */
User *u;
u = finduser(source);
if (u && !is_oper(u)) {
if (u && !is_oper(u))
{
const char *newav[2];
newav[0] = source;
newav[1] = "+o";
return anope_event_mode(source, 2, newav);
} else
}
else
return MOD_CONT;
}
@@ -391,28 +382,30 @@ int anope_event_fmode(const char *source, int ac, const char **av)
return MOD_CONT;
/* Checking the TS for validity to avoid desyncs */
if ((c = findchan(av[0]))) {
if (c->creation_time > strtol(av[1], NULL, 10)) {
if ((c = findchan(av[0])))
{
if (c->creation_time > strtol(av[1], NULL, 10))
/* Our TS is bigger, we should lower it */
c->creation_time = strtol(av[1], NULL, 10);
} else if (c->creation_time < strtol(av[1], NULL, 10)) {
else if (c->creation_time < strtol(av[1], NULL, 10))
/* The TS we got is bigger, we should ignore this message. */
return MOD_CONT;
}
} else {
}
else
/* Got FMODE for a non-existing channel */
return MOD_CONT;
}
/* TS's are equal now, so we can proceed with parsing */
n = o = 0;
while (n < ac) {
if (n != 1) {
while (n < ac)
{
if (n != 1)
{
newav[o] = av[n];
o++;
++o;
Alog(LOG_DEBUG) << "Param: " << newav[o - 1];
}
n++;
++n;
}
return anope_event_mode(source, ac - 1, newav);
@@ -467,7 +460,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */
else
keep_their_modes = false;
/* Mark the channel as syncing */
if (was_created)
c->SetFlag(CH_SYNCING);
@@ -512,10 +505,8 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Update their status internally on the channel
* This will enforce secureops etc on the user
*/
for (std::list<ChannelMode *>::iterator it = Status.begin(); it != Status.end(); ++it)
{
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it)
c->SetModeInternal(*it, buf);
}
/* Now set whatever modes this user is allowed to have on the channel */
chan_set_correct_modes(u, c, 1);
@@ -567,9 +558,8 @@ int anope_event_436(const char *source, int ac, const char **av)
int anope_event_away(const char *source, int ac, const char **av)
{
if (!source) {
if (!source)
return MOD_CONT;
}
m_away(source, (ac ? av[0] : NULL));
return MOD_CONT;
}
@@ -590,7 +580,8 @@ int anope_event_topic(const char *source, int ac, const char **av)
if (check_topiclock(c, topic_time))
return MOD_CONT;
if (c->topic) {
if (c->topic)
{
delete [] c->topic;
c->topic = NULL;
}
@@ -602,10 +593,12 @@ int anope_event_topic(const char *source, int ac, const char **av)
record_topic(av[0]);
if (ac > 1 && *av[1]) {
if (ac > 1 && *av[1])
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[1]));
}
else {
else
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
}
@@ -626,7 +619,7 @@ int anope_event_rsquit(const char *source, int ac, const char **av)
return MOD_CONT;
/* Horrible workaround to an insp bug (#) in how RSQUITs are sent - mark */
if (ac > 1 && strcmp(Config.ServerName, av[0]) == 0)
if (ac > 1 && !strcmp(Config.ServerName, av[0]))
do_squit(source, ac - 1, av + 1);
else
do_squit(source, ac, av);
@@ -642,7 +635,6 @@ int anope_event_quit(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_kill(const char *source, int ac, const char **av)
{
if (ac != 2)
@@ -660,7 +652,6 @@ int anope_event_kick(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_join(const char *source, int ac, const char **av)
{
if (ac != 2)
@@ -671,9 +662,8 @@ int anope_event_join(const char *source, int ac, const char **av)
int anope_event_motd(const char *source, int ac, const char **av)
{
if (!source) {
if (!source)
return MOD_CONT;
}
m_motd(source);
return MOD_CONT;
@@ -776,8 +766,10 @@ int anope_event_nick(const char *source, int ac, const char **av)
struct in_addr addy;
uint32 *ad = reinterpret_cast<uint32 *>(&addy);
if (ac != 1) {
if (ac == 8) {
if (ac != 1)
{
if (ac == 8)
{
int ts = strtoul(av[0], NULL, 10);
inet_aton(av[6], &addy);
@@ -787,7 +779,8 @@ int anope_event_nick(const char *source, int ac, const char **av)
source, /* server */
av[7], /* realname */
ts, htonl(*ad), av[3], NULL);
if (user) {
if (user)
{
/* InspIRCd1.1 has no user mode +d so we
* use nick timestamp to check for auth - Adam
*/
@@ -797,9 +790,9 @@ int anope_event_nick(const char *source, int ac, const char **av)
user->SetCloakedHost(av[3]);
}
}
} else {
do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, NULL, NULL);
}
else
do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, NULL, NULL);
return MOD_CONT;
}
@@ -829,7 +822,6 @@ int anope_event_server(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_privmsg(const char *source, int ac, const char **av)
{
if (ac != 2)
@@ -848,55 +840,40 @@ int anope_event_part(const char *source, int ac, const char **av)
int anope_event_whois(const char *source, int ac, const char **av)
{
if (source && ac >= 1) {
if (source && ac >= 1)
m_whois(source, av[0]);
}
return MOD_CONT;
}
int anope_event_capab(const char *source, int ac, const char **av)
{
if (strcasecmp(av[0], "START") == 0) {
if (!strcasecmp(av[0], "START"))
{
/* reset CAPAB */
has_servicesmod = 0;
has_globopsmod = 0;
has_svsholdmod = 0;
has_chghostmod = 0;
has_chgidentmod = 0;
has_messagefloodmod = 0;
has_banexceptionmod = 0;
has_inviteexceptionmod = 0;
has_hidechansmod = 0;
} else if (strcasecmp(av[0], "MODULES") == 0) {
if (strstr(av[1], "m_globops.so")) {
has_globopsmod = 1;
}
if (strstr(av[1], "m_services.so")) {
has_servicesmod = 1;
}
if (strstr(av[1], "m_svshold.so")) {
has_svsholdmod = 1;
}
if (strstr(av[1], "m_chghost.so")) {
has_chghostmod = 1;
}
if (strstr(av[1], "m_chgident.so")) {
has_chgidentmod = 1;
}
if (strstr(av[1], "m_messageflood.so")) {
has_messagefloodmod = 1;
}
if (strstr(av[1], "m_banexception.so")) {
has_banexceptionmod = 1;
}
if (strstr(av[1], "m_inviteexception.so")) {
has_inviteexceptionmod = 1;
}
if (strstr(av[1], "m_hidechans.so")) {
has_hidechansmod = 1;
}
} else if (strcasecmp(av[0], "CAPABILITIES") == 0) {
has_servicesmod = false;
has_globopsmod = false;
has_svsholdmod = false;
has_chghostmod = false;
has_chgidentmod = false;
has_hidechansmod = false;
}
else if (!strcasecmp(av[0], "MODULES"))
{
if (strstr(av[1], "m_globops.so"))
has_globopsmod = true;
if (strstr(av[1], "m_services.so"))
has_servicesmod = true;
if (strstr(av[1], "m_svshold.so"))
has_svsholdmod = true;
if (strstr(av[1], "m_chghost.so"))
has_chghostmod = true;
if (strstr(av[1], "m_chgident.so"))
has_chgidentmod = true;
if (strstr(av[1], "m_hidechans.so"))
has_hidechansmod = true;
}
else if (!strcasecmp(av[0], "CAPABILITIES"))
{
spacesepstream ssep(av[1]);
std::string capab;
while (ssep.GetToken(capab))
@@ -908,7 +885,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
std::string modebuf;
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -927,7 +904,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -941,7 +918,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -960,7 +937,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -1034,7 +1011,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
std::string modes(capab.begin() + 8, capab.begin() + capab.find(")"));
std::string chars(capab.begin() + capab.find(")") + 1, capab.end());
for (size_t t = 0; t < modes.size(); ++t)
for (size_t t = 0, end = modes.size(); t < end; ++t)
{
switch (modes[t])
{
@@ -1062,37 +1039,39 @@ int anope_event_capab(const char *source, int ac, const char **av)
ircd->maxmodes = atoi(maxmodes.c_str());
}
}
} else if (strcasecmp(av[0], "END") == 0) {
if (!has_globopsmod) {
}
else if (!strcasecmp(av[0], "END"))
{
if (!has_globopsmod)
{
send_cmd(NULL, "ERROR :m_globops is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_globops module loaded, and this is required.";
quitting = 1;
return MOD_STOP;
}
if (!has_servicesmod) {
if (!has_servicesmod)
{
send_cmd(NULL, "ERROR :m_services is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_services module loaded, and this is required.";
quitting = 1;
return MOD_STOP;
}
if (!has_hidechansmod) {
if (!has_hidechansmod)
{
send_cmd(NULL, "ERROR :m_hidechans.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server deos not have the m_hidechans module loaded, and this is required.";
quitting = 1;
return MOD_STOP;
}
if (!has_svsholdmod) {
if (!has_svsholdmod)
ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
}
if (!has_chghostmod) {
if (!has_chghostmod)
ircdproto->SendGlobops(OperServ, "CHGHOST missing, Usage disabled until module is loaded.");
}
if (!has_chgidentmod) {
if (!has_chgidentmod)
ircdproto->SendGlobops(OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
ircd->svshold = has_svsholdmod;
}
CapabParse(ac, av);
return MOD_CONT;
}
@@ -1103,7 +1082,6 @@ int anope_event_endburst(const char *source, int ac, const char **av)
return MOD_CONT;
}
void moduleAddIRCDMsgs()
{
Anope::AddMessage("ENDBURST", anope_event_endburst);
+131 -168
View File
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
/*************************************************************************/
@@ -18,13 +16,13 @@
#include "hashcomp.h"
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
#endif
#ifdef _WIN32
#include <winsock.h>
# include <winsock.h>
int inet_aton(const char *name, struct in_addr *addr)
{
uint32 a = inet_addr(name);
@@ -34,65 +32,61 @@ int inet_aton(const char *name, struct in_addr *addr)
#endif
IRCDVar myIrcd[] = {
{"InspIRCd 1.2", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
0, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
4, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
0, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
1, /* ts6 */
0, /* p10 */
1, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
{"InspIRCd 1.2", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
0, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
4, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
0, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
1, /* ts6 */
0, /* p10 */
1, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
}
,
{NULL}
};
static int has_servicesmod = 0;
static int has_globopsmod = 0;
static int has_svsholdmod = 0;
static int has_chghostmod = 0;
static int has_chgidentmod = 0;
static int has_messagefloodmod = 0;
static int has_banexceptionmod = 0;
static int has_inviteexceptionmod = 0;
static int has_hidechansmod = 0;
static bool has_servicesmod = false;
static bool has_globopsmod = false;
static bool has_svsholdmod = false;
static bool has_chghostmod = false;
static bool has_chgidentmod = false;
static bool has_hidechansmod = false;
/* Previously introduced user during burst */
static User *prev_u_intro = NULL;
/* CHGHOST */
void inspircd_cmd_chghost(const char *nick, const char *vhost)
{
if (has_chghostmod != 1)
if (!has_chghostmod)
{
ircdproto->SendGlobops(OperServ, "CHGHOST not loaded!");
return;
@@ -120,7 +114,6 @@ void inspircd_cmd_pass(const char *pass)
strlcpy(currentpass, pass, sizeof(currentpass));
}
class InspIRCdProto : public IRCDProto
{
void SendAkillDel(XLine *x)
@@ -142,9 +135,7 @@ class InspIRCdProto : public IRCDProto
inspircd_cmd_chghost(u->nick.c_str(), u->host);
if (has_chgidentmod && u->GetIdent() != u->GetVIdent())
{
inspircd_cmd_chgident(u->nick.c_str(), u->GetIdent().c_str());
}
}
void SendAkill(XLine *x)
@@ -184,7 +175,8 @@ class InspIRCdProto : public IRCDProto
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(bi ? bi->GetUID() : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
}
@@ -258,10 +250,8 @@ class InspIRCdProto : public IRCDProto
/* CHGIDENT */
void inspircd_cmd_chgident(const char *nick, const char *vIdent)
{
if (has_chgidentmod == 0)
{
if (!has_chgidentmod)
ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
else
{
BotInfo *bi = OperServ;
@@ -360,23 +350,17 @@ class InspIRCdProto : public IRCDProto
u->SetMode(NickServ, UMODE_REGISTERED);
}
} ircd_proto;
int anope_event_ftopic(const char *source, int ac, const char **av)
{
/* :source FTOPIC channel ts setby :topic */
const char *temp;
if (ac < 4)
return MOD_CONT;
temp = av[1]; /* temp now holds ts */
av[1] = av[2]; /* av[1] now holds set by */
av[2] = temp; /* av[2] now holds ts */
temp = av[1]; /* temp now holds ts */
av[1] = av[2]; /* av[1] now holds set by */
av[2] = temp; /* av[2] now holds ts */
do_topic(source, ac, av);
return MOD_CONT;
}
@@ -384,9 +368,7 @@ int anope_event_ftopic(const char *source, int ac, const char **av)
int anope_event_mode(const char *source, int ac, const char **av)
{
if (*av[0] == '#' || *av[0] == '&')
{
do_cmode(source, ac, av);
}
else
{
/* InspIRCd lets opers change another
@@ -397,7 +379,7 @@ int anope_event_mode(const char *source, int ac, const char **av)
User *u2 = finduser(av[0]);
// This can happen with server-origin modes.
if (u == NULL)
if (!u)
u = u2;
// if it's still null, drop it like fire.
@@ -417,12 +399,14 @@ int anope_event_opertype(const char *source, int ac, const char **av)
dont do this directly */
User *u;
u = finduser(source);
if (u && !is_oper(u)) {
if (u && !is_oper(u))
{
const char *newav[2];
newav[0] = source;
newav[1] = "+o";
return anope_event_mode(source, 2, newav);
} else
}
else
return MOD_CONT;
}
@@ -437,28 +421,30 @@ int anope_event_fmode(const char *source, int ac, const char **av)
return MOD_CONT;
/* Checking the TS for validity to avoid desyncs */
if ((c = findchan(av[0]))) {
if (c->creation_time > strtol(av[1], NULL, 10)) {
if ((c = findchan(av[0])))
{
if (c->creation_time > strtol(av[1], NULL, 10))
/* Our TS is bigger, we should lower it */
c->creation_time = strtol(av[1], NULL, 10);
} else if (c->creation_time < strtol(av[1], NULL, 10)) {
else if (c->creation_time < strtol(av[1], NULL, 10))
/* The TS we got is bigger, we should ignore this message. */
return MOD_CONT;
}
} else {
}
else
/* Got FMODE for a non-existing channel */
return MOD_CONT;
}
/* TS's are equal now, so we can proceed with parsing */
n = o = 0;
while (n < ac) {
if (n != 1) {
while (n < ac)
{
if (n != 1)
{
newav[o] = av[n];
o++;
++o;
Alog(LOG_DEBUG) << "Param: " << newav[o - 1];
}
n++;
++n;
}
return anope_event_mode(source, ac - 1, newav);
@@ -521,11 +507,11 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */
else
keep_their_modes = false;
/* Mark the channel as syncing */
if (was_created)
c->SetFlag(CH_SYNCING);
/* If we need to keep their modes, and this FJOIN string contains modes */
if (keep_their_modes && ac >= 4)
{
@@ -572,10 +558,8 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Update their status internally on the channel
* This will enforce secureops etc on the user
*/
for (std::list<ChannelMode *>::iterator it = Status.begin(); it != Status.end(); ++it)
{
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it)
c->SetModeInternal(*it, buf);
}
/* Now set whatever modes this user is allowed to have on the channel */
chan_set_correct_modes(u, c, 1);
@@ -603,7 +587,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
* and destroy the channel soon
*/
}
return MOD_CONT;
}
@@ -659,7 +643,8 @@ int anope_event_topic(const char *source, int ac, const char **av)
if (check_topiclock(c, topic_time))
return MOD_CONT;
if (c->topic) {
if (c->topic)
{
delete [] c->topic;
c->topic = NULL;
}
@@ -671,10 +656,12 @@ int anope_event_topic(const char *source, int ac, const char **av)
record_topic(av[0]);
if (ac > 1 && *av[1]) {
if (ac > 1 && *av[1])
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[0]));
}
else {
else
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
}
@@ -692,9 +679,7 @@ int anope_event_rsquit(const char *source, int ac, const char **av)
/* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
Server *s = Server::Find(av[0]);
if (s && s->HasFlag(SERVER_JUPED))
{
send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), ac > 1 ? av[1] : "");
}
do_squit(source, ac, av);
@@ -707,7 +692,6 @@ int anope_event_quit(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_kill(const char *source, int ac, const char **av)
{
User *u = finduser(av[0]);
@@ -722,7 +706,6 @@ int anope_event_kick(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_join(const char *source, int ac, const char **av)
{
do_join(source, ac, av);
@@ -810,14 +793,12 @@ int anope_event_sethost(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_nick(const char *source, int ac, const char **av)
{
do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, NULL, NULL);
return MOD_CONT;
}
/*
* [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org>
* 0: uid
@@ -830,7 +811,7 @@ int anope_event_nick(const char *source, int ac, const char **av)
* 7: signon
* 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname!
* last: realname
*/
*/
int anope_event_uid(const char *source, int ac, const char **av)
{
@@ -866,13 +847,9 @@ int anope_event_uid(const char *source, int ac, const char **av)
UserSetInternalModes(user, 1, &av[8]);
user->SetCloakedHost(av[4]);
if (!user->server->IsSynced())
{
prev_u_intro = user;
}
else
{
validate_user(user);
}
}
return MOD_CONT;
@@ -907,7 +884,6 @@ int anope_event_server(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_privmsg(const char *source, int ac, const char **av)
{
if (!finduser(source))
@@ -949,50 +925,35 @@ int anope_event_metadata(const char *source, int ac, const char **av)
int anope_event_capab(const char *source, int ac, const char **av)
{
if (strcasecmp(av[0], "START") == 0) {
if (!strcasecmp(av[0], "START"))
{
/* reset CAPAB */
has_servicesmod = 0;
has_globopsmod = 0;
has_svsholdmod = 0;
has_chghostmod = 0;
has_chgidentmod = 0;
has_messagefloodmod = 0;
has_banexceptionmod = 0;
has_inviteexceptionmod = 0;
has_hidechansmod = 0;
} else if (strcasecmp(av[0], "MODULES") == 0) {
if (strstr(av[1], "m_globops.so")) {
has_globopsmod = 1;
}
if (strstr(av[1], "m_services_account.so")) {
has_servicesmod = 1;
}
if (strstr(av[1], "m_svshold.so")) {
has_svsholdmod = 1;
}
if (strstr(av[1], "m_chghost.so")) {
has_chghostmod = 1;
}
if (strstr(av[1], "m_chgident.so")) {
has_chgidentmod = 1;
}
if (strstr(av[1], "m_messageflood.so")) {
has_messagefloodmod = 1;
}
if (strstr(av[1], "m_banexception.so")) {
has_banexceptionmod = 1;
}
if (strstr(av[1], "m_inviteexception.so")) {
has_inviteexceptionmod = 1;
}
if (strstr(av[1], "m_hidechans.so")) {
has_hidechansmod = 1;
}
if (strstr(av[1], "m_servprotect.so")) {
has_servicesmod = false;
has_globopsmod = false;
has_svsholdmod = false;
has_chghostmod = false;
has_chgidentmod = false;
has_hidechansmod = false;
}
else if (!strcasecmp(av[0], "MODULES"))
{
if (strstr(av[1], "m_globops.so"))
has_globopsmod = true;
if (strstr(av[1], "m_services_account.so"))
has_servicesmod = true;
if (strstr(av[1], "m_svshold.so"))
has_svsholdmod = true;
if (strstr(av[1], "m_chghost.so"))
has_chghostmod = true;
if (strstr(av[1], "m_chgident.so"))
has_chgidentmod = true;
if (strstr(av[1], "m_hidechans.so"))
has_hidechansmod = true;
if (strstr(av[1], "m_servprotect.so"))
ircd->pseudoclient_mode = "+Ik";
}
} else if (strcasecmp(av[0], "CAPABILITIES") == 0) {
}
else if (!strcasecmp(av[0], "CAPABILITIES"))
{
spacesepstream ssep(av[1]);
std::string capab;
while (ssep.GetToken(capab))
@@ -1004,7 +965,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
std::string modebuf;
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -1031,7 +992,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -1044,7 +1005,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -1072,7 +1033,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -1161,7 +1122,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
while (sep.GetToken(modebuf))
{
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -1229,8 +1190,8 @@ int anope_event_capab(const char *source, int ac, const char **av)
{
std::string modes(capab.begin() + 8, capab.begin() + capab.find(")"));
std::string chars(capab.begin() + capab.find(")") + 1, capab.end());
for (size_t t = 0; t < modes.size(); ++t)
for (size_t t = 0, end = modes.size(); t < end; ++t)
{
switch (modes[t])
{
@@ -1258,34 +1219,36 @@ int anope_event_capab(const char *source, int ac, const char **av)
ircd->maxmodes = atoi(maxmodes.c_str());
}
}
} else if (strcasecmp(av[0], "END") == 0) {
if (!has_globopsmod) {
}
else if (!strcasecmp(av[0], "END"))
{
if (!has_globopsmod)
{
send_cmd(NULL, "ERROR :m_globops is not loaded. This is required by Anope");
quitmsg = "Remote server does not have the m_globops module loaded, and this is required.";
quitting = 1;
return MOD_STOP;
}
if (!has_servicesmod) {
if (!has_servicesmod)
{
send_cmd(NULL, "ERROR :m_services_account.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
quitting = 1;
return MOD_STOP;
}
if (!has_hidechansmod) {
if (!has_hidechansmod)
{
send_cmd(NULL, "ERROR :m_hidechans.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
quitting = 1;
return MOD_STOP;
}
if (!has_svsholdmod) {
if (!has_svsholdmod)
ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
}
if (!has_chghostmod) {
if (!has_chghostmod)
ircdproto->SendGlobops(OperServ, "CHGHOST missing, Usage disabled until module is loaded.");
}
if (!has_chgidentmod) {
if (!has_chgidentmod)
ircdproto->SendGlobops(OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
ircd->svshold = has_svsholdmod;
}
@@ -1301,14 +1264,13 @@ int anope_event_endburst(const char *source, int ac, const char **av)
Server *s = Server::Find(source ? source : "");
if (!s)
{
throw new CoreException("Got ENDBURST without a source");
}
/* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
* If not, validate the user. ~ Viper*/
prev_u_intro = NULL;
if (u) na = findnick(u->nick);
if (u)
na = findnick(u->nick);
if (u && !u->server->IsSynced() && (!na || na->nc != u->Account()))
{
validate_user(u);
@@ -1363,7 +1325,8 @@ void moduleAddIRCDMsgs()
bool ChannelModeFlood::IsValid(const std::string &value)
{
char *dp, *end;
if (!value.empty() && value[0] != ':' && strtoul((value[0] == '*' ? value.c_str() + 1 : value.c_str()), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1;
if (!value.empty() && value[0] != ':' && strtoul((value[0] == '*' ? value.c_str() + 1 : value.c_str()), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end)
return 1;
else return 0;
}
+111 -135
View File
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
/*************************************************************************/
@@ -18,13 +16,13 @@
#include "hashcomp.h"
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
#endif
#ifdef _WIN32
#include <winsock.h>
# include <winsock.h>
int inet_aton(const char *name, struct in_addr *addr)
{
uint32 a = inet_addr(name);
@@ -34,51 +32,51 @@ int inet_aton(const char *name, struct in_addr *addr)
#endif
IRCDVar myIrcd[] = {
{"InspIRCd 2.0", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
0, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
4, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
0, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
1, /* ts6 */
0, /* p10 */
1, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
{"InspIRCd 2.0", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
0, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
4, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
0, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
1, /* ts6 */
0, /* p10 */
1, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
}
,
{NULL}
};
static int has_servicesmod = 0;
static int has_svsholdmod = 0;
static int has_chghostmod = 0;
static int has_chgidentmod = 0;
static bool has_servicesmod = false;
static bool has_svsholdmod = false;
static bool has_chghostmod = false;
static bool has_chgidentmod = false;
/* Previously introduced user during burst */
static User *prev_u_intro = NULL;
@@ -86,7 +84,7 @@ static User *prev_u_intro = NULL;
/* CHGHOST */
void inspircd_cmd_chghost(const char *nick, const char *vhost)
{
if (has_chghostmod != 1)
if (!has_chghostmod)
{
ircdproto->SendGlobops(OperServ, "CHGHOST not loaded!");
return;
@@ -114,7 +112,6 @@ void inspircd_cmd_pass(const char *pass)
strlcpy(currentpass, pass, sizeof(currentpass));
}
class InspIRCdProto : public IRCDProto
{
void SendAkillDel(XLine *x)
@@ -136,9 +133,7 @@ class InspIRCdProto : public IRCDProto
inspircd_cmd_chghost(u->nick.c_str(), u->host);
if (has_chgidentmod && u->GetIdent() != u->GetVIdent())
{
inspircd_cmd_chgident(u->nick.c_str(), u->GetIdent().c_str());
}
}
void SendAkill(XLine *x)
@@ -178,7 +173,8 @@ class InspIRCdProto : public IRCDProto
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(bi ? bi->GetUID() : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
}
@@ -255,10 +251,8 @@ class InspIRCdProto : public IRCDProto
/* CHGIDENT */
void inspircd_cmd_chgident(const char *nick, const char *vIdent)
{
if (has_chgidentmod == 0)
{
if (!has_chgidentmod)
ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
else
{
BotInfo *bi = OperServ;
@@ -354,23 +348,17 @@ class InspIRCdProto : public IRCDProto
u->SetMode(NickServ, UMODE_REGISTERED);
}
} ircd_proto;
int anope_event_ftopic(const char *source, int ac, const char **av)
{
/* :source FTOPIC channel ts setby :topic */
const char *temp;
if (ac < 4)
return MOD_CONT;
temp = av[1]; /* temp now holds ts */
av[1] = av[2]; /* av[1] now holds set by */
av[2] = temp; /* av[2] now holds ts */
temp = av[1]; /* temp now holds ts */
av[1] = av[2]; /* av[1] now holds set by */
av[2] = temp; /* av[2] now holds ts */
do_topic(source, ac, av);
return MOD_CONT;
}
@@ -378,9 +366,7 @@ int anope_event_ftopic(const char *source, int ac, const char **av)
int anope_event_mode(const char *source, int ac, const char **av)
{
if (*av[0] == '#' || *av[0] == '&')
{
do_cmode(source, ac, av);
}
else
{
/* InspIRCd lets opers change another
@@ -391,7 +377,7 @@ int anope_event_mode(const char *source, int ac, const char **av)
User *u2 = finduser(av[0]);
// This can happen with server-origin modes.
if (u == NULL)
if (!u)
u = u2;
// if it's still null, drop it like fire.
@@ -411,12 +397,14 @@ int anope_event_opertype(const char *source, int ac, const char **av)
dont do this directly */
User *u;
u = finduser(source);
if (u && !is_oper(u)) {
if (u && !is_oper(u))
{
const char *newav[2];
newav[0] = source;
newav[1] = "+o";
return anope_event_mode(source, 2, newav);
} else
}
else
return MOD_CONT;
}
@@ -431,28 +419,30 @@ int anope_event_fmode(const char *source, int ac, const char **av)
return MOD_CONT;
/* Checking the TS for validity to avoid desyncs */
if ((c = findchan(av[0]))) {
if (c->creation_time > strtol(av[1], NULL, 10)) {
if ((c = findchan(av[0])))
{
if (c->creation_time > strtol(av[1], NULL, 10))
/* Our TS is bigger, we should lower it */
c->creation_time = strtol(av[1], NULL, 10);
} else if (c->creation_time < strtol(av[1], NULL, 10)) {
else if (c->creation_time < strtol(av[1], NULL, 10))
/* The TS we got is bigger, we should ignore this message. */
return MOD_CONT;
}
} else {
}
else
/* Got FMODE for a non-existing channel */
return MOD_CONT;
}
/* TS's are equal now, so we can proceed with parsing */
n = o = 0;
while (n < ac) {
if (n != 1) {
while (n < ac)
{
if (n != 1)
{
newav[o] = av[n];
o++;
++o;
Alog(LOG_DEBUG) << "Param: " << newav[o - 1];
}
n++;
++n;
}
return anope_event_mode(source, ac - 1, newav);
@@ -515,11 +505,11 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */
else
keep_their_modes = false;
/* Mark the channel as syncing */
if (was_created)
c->SetFlag(CH_SYNCING);
/* If we need to keep their modes, and this FJOIN string contains modes */
if (keep_their_modes && ac >= 4)
{
@@ -566,10 +556,8 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Update their status internally on the channel
* This will enforce secureops etc on the user
*/
for (std::list<ChannelMode *>::iterator it = Status.begin(); it != Status.end(); ++it)
{
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it)
c->SetModeInternal(*it, buf);
}
/* Now set whatever modes this user is allowed to have on the channel */
chan_set_correct_modes(u, c, 1);
@@ -597,7 +585,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
* and destroy the channel soon
*/
}
return MOD_CONT;
}
@@ -653,7 +641,8 @@ int anope_event_topic(const char *source, int ac, const char **av)
if (check_topiclock(c, topic_time))
return MOD_CONT;
if (c->topic) {
if (c->topic)
{
delete [] c->topic;
c->topic = NULL;
}
@@ -665,10 +654,12 @@ int anope_event_topic(const char *source, int ac, const char **av)
record_topic(av[0]);
if (ac > 1 && *av[1]) {
if (ac > 1 && *av[1])
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[0]));
}
else {
else
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
}
@@ -686,9 +677,7 @@ int anope_event_rsquit(const char *source, int ac, const char **av)
/* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
Server *s = Server::Find(av[0]);
if (s && s->HasFlag(SERVER_JUPED))
{
send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), ac > 1 ? av[1] : "");
}
do_squit(source, ac, av);
@@ -701,7 +690,6 @@ int anope_event_quit(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_kill(const char *source, int ac, const char **av)
{
User *u = finduser(av[0]);
@@ -716,7 +704,6 @@ int anope_event_kick(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_join(const char *source, int ac, const char **av)
{
do_join(source, ac, av);
@@ -803,14 +790,12 @@ int anope_event_sethost(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_nick(const char *source, int ac, const char **av)
{
do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, NULL, NULL);
return MOD_CONT;
}
/*
* [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org>
* 0: uid
@@ -823,7 +808,7 @@ int anope_event_nick(const char *source, int ac, const char **av)
* 7: signon
* 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname!
* last: realname
*/
*/
int anope_event_uid(const char *source, int ac, const char **av)
{
@@ -838,7 +823,8 @@ int anope_event_uid(const char *source, int ac, const char **av)
* If not, validate the user. ~ Viper*/
user = prev_u_intro;
prev_u_intro = NULL;
if (user) na = findnick(user->nick);
if (user)
na = findnick(user->nick);
if (user && !user->server->IsSynced() && (!na || na->nc != user->Account()))
{
validate_user(user);
@@ -859,13 +845,9 @@ int anope_event_uid(const char *source, int ac, const char **av)
UserSetInternalModes(user, 1, &av[8]);
user->SetCloakedHost(av[4]);
if (!user->server->IsSynced())
{
prev_u_intro = user;
}
else
{
validate_user(user);
}
}
return MOD_CONT;
@@ -900,7 +882,6 @@ int anope_event_server(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_privmsg(const char *source, int ac, const char **av)
{
if (!finduser(source))
@@ -942,7 +923,7 @@ int anope_event_metadata(const char *source, int ac, const char **av)
int anope_event_capab(const char *source, int ac, const char **av)
{
if (strcasecmp(av[0], "START") == 0)
if (!strcasecmp(av[0], "START"))
{
if (ac < 2 || atoi(av[1]) < 1202)
{
@@ -953,12 +934,12 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
/* reset CAPAB */
has_servicesmod = 0;
has_svsholdmod = 0;
has_chghostmod = 0;
has_chgidentmod = 0;
has_servicesmod = false;
has_svsholdmod = false;
has_chghostmod = false;
has_chgidentmod = false;
}
else if (strcasecmp(av[0], "CHANMODES") == 0)
else if (!strcasecmp(av[0], "CHANMODES"))
{
spacesepstream ssep(av[1]);
std::string capab;
@@ -1065,14 +1046,14 @@ int anope_event_capab(const char *source, int ac, const char **av)
cm = new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", modechar[0]);
else if (modename == "voice")
cm = new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", modechar[1], modechar[0]);
if (cm)
ModeManager::AddChannelMode(cm);
else
Alog() << "Unrecognized mode string in CAPAB CHANMODES: " << capab;
}
}
else if (strcasecmp(av[0], "USERMODES") == 0)
else if (!strcasecmp(av[0], "USERMODES"))
{
spacesepstream ssep(av[1]);
std::string capab;
@@ -1126,18 +1107,16 @@ int anope_event_capab(const char *source, int ac, const char **av)
Alog() << "Unrecognized mode string in CAPAB USERMODES: " << capab;
}
}
else if (strcasecmp(av[0], "MODULES") == 0)
else if (!strcasecmp(av[0], "MODULES"))
{
spacesepstream ssep(av[1]);
std::string module;
while (ssep.GetToken(module))
{
if (module == "m_svshold.so")
has_svsholdmod = 1;
}
has_svsholdmod = true;
}
else if (strcasecmp(av[0], "MODSUPPORT") == 0)
else if (!strcasecmp(av[0], "MODSUPPORT"))
{
spacesepstream ssep(av[1]);
std::string module;
@@ -1145,16 +1124,16 @@ int anope_event_capab(const char *source, int ac, const char **av)
while (ssep.GetToken(module))
{
if (module == "m_services_account.so")
has_servicesmod = 1;
has_servicesmod = true;
else if (module == "m_chghost.so")
has_chghostmod = 1;
has_chghostmod = true;
else if (module == "m_chgident.so")
has_chgidentmod = 1;
has_chgidentmod = true;
else if (module == "m_servprotect.so")
ircd->pseudoclient_mode = "+Ik";
}
}
else if (strcasecmp(av[0], "CAPABILITIES") == 0)
else if (!strcasecmp(av[0], "CAPABILITIES"))
{
spacesepstream ssep(av[1]);
std::string capab;
@@ -1167,7 +1146,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
std::string modebuf;
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
if (ModeManager::FindChannelModeByChar(modebuf[t]))
continue;
@@ -1176,7 +1155,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
if (ModeManager::FindChannelModeByChar(modebuf[t]))
continue;
@@ -1184,7 +1163,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
if (ModeManager::FindChannelModeByChar(modebuf[t]))
continue;
@@ -1192,7 +1171,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
if (ModeManager::FindChannelModeByChar(modebuf[t]));
continue;
@@ -1207,10 +1186,10 @@ int anope_event_capab(const char *source, int ac, const char **av)
sep.GetToken(modebuf);
sep.GetToken(modebuf);
if (sep.GetToken(modebuf))
{
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
ModeManager::AddUserMode(new UserModeParam(UMODE_END, "", modebuf[t]));
}
@@ -1218,7 +1197,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
if (sep.GetToken(modebuf))
{
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
ModeManager::AddUserMode(new UserMode(UMODE_END, "", modebuf[t]));
}
@@ -1231,7 +1210,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
}
}
else if (strcasecmp(av[0], "END") == 0)
else if (!strcasecmp(av[0], "END"))
{
if (!has_servicesmod)
{
@@ -1247,15 +1226,12 @@ int anope_event_capab(const char *source, int ac, const char **av)
quitting = 1;
return MOD_STOP;
}
if (!has_svsholdmod) {
if (!has_svsholdmod)
ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
}
if (!has_chghostmod) {
if (!has_chghostmod)
ircdproto->SendGlobops(OperServ, "CHGHOST missing, Usage disabled until module is loaded.");
}
if (!has_chgidentmod) {
if (!has_chgidentmod)
ircdproto->SendGlobops(OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
ircd->svshold = has_svsholdmod;
}
@@ -1271,14 +1247,13 @@ int anope_event_endburst(const char *source, int ac, const char **av)
Server *s = Server::Find(source ? source : "");
if (!s)
{
throw new CoreException("Got ENDBURST without a source");
}
/* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
* If not, validate the user. ~ Viper*/
prev_u_intro = NULL;
if (u) na = findnick(u->nick);
if (u)
na = findnick(u->nick);
if (u && !u->server->IsSynced() && (!na || na->nc != u->Account()))
{
validate_user(u);
@@ -1333,7 +1308,8 @@ void moduleAddIRCDMsgs()
bool ChannelModeFlood::IsValid(const std::string &value)
{
char *dp, *end;
if (!value.empty() && value[0] != ':' && strtoul((value[0] == '*' ? value.c_str() + 1 : value.c_str()), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1;
if (!value.empty() && value[0] != ':' && strtoul((value[0] == '*' ? value.c_str() + 1 : value.c_str()), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end)
return 1;
else return 0;
}
+106 -110
View File
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
#include "services.h"
@@ -17,42 +15,42 @@
static char *TS6UPLINK = NULL; // XXX is this needed?
IRCDVar myIrcd[] = {
{"Ratbox 2.0+", /* ircd name */
"+oi", /* Modes used by pseudoclients */
2, /* Chan Max Symbols */
"+o", /* Channel Umode used by Botserv bots */
0, /* SVSNICK */
0, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
0, /* Supports SZlines */
3, /* Number of server args */
1, /* Join 2 Set */
1, /* Join 2 Message */
0, /* TS Topic Forward */
0, /* TS Topci Backward */
1, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
0, /* Reverse */
0, /* vidents */
0, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
0, /* UMODE */
0, /* O:LINE */
0, /* VHOST ON NICK */
0, /* Change RealName */
0, /* No Knock requires +i */
0, /* We support TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
1, /* ts6 */
0, /* p10 */
0, /* CIDR channelbans */
"$$", /* TLD Prefix for Global */
4, /* Max number of modes we can send per line */
{"Ratbox 2.0+", /* ircd name */
"+oi", /* Modes used by pseudoclients */
2, /* Chan Max Symbols */
"+o", /* Channel Umode used by Botserv bots */
0, /* SVSNICK */
0, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
0, /* Supports SZlines */
3, /* Number of server args */
1, /* Join 2 Set */
1, /* Join 2 Message */
0, /* TS Topic Forward */
0, /* TS Topci Backward */
1, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
0, /* Reverse */
0, /* vidents */
0, /* svshold */
0, /* time stamp on mode */
0, /* NICKIP */
0, /* UMODE */
0, /* O:LINE */
0, /* VHOST ON NICK */
0, /* Change RealName */
0, /* No Knock requires +i */
0, /* We support TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
1, /* ts6 */
0, /* p10 */
0, /* CIDR channelbans */
"$$", /* TLD Prefix for Global */
4, /* Max number of modes we can send per line */
}
,
{NULL}
@@ -73,7 +71,6 @@ void ratbox_cmd_svinfo()
void ratbox_cmd_svsinfo()
{
}
void ratbox_cmd_tmode(const char *source, const char *dest, const char *fmt, ...)
@@ -82,14 +79,14 @@ void ratbox_cmd_tmode(const char *source, const char *dest, const char *fmt, ...
char buf[BUFSIZE];
*buf = '\0';
if (fmt) {
if (fmt)
{
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
}
if (!*buf) {
if (!*buf)
return;
}
send_cmd(NULL, "MODE %s %s", dest, buf);
}
@@ -116,8 +113,7 @@ void ratbox_cmd_tmode(const char *source, const char *dest, const char *fmt, ...
*/
void ratbox_cmd_capab()
{
send_cmd(NULL,
"CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP");
send_cmd(NULL, "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP");
}
/* PASS */
@@ -224,22 +220,23 @@ class RatboxProto : public IRCDTS6Proto
void SendModeInternal(BotInfo *bi, Channel *dest, const char *buf)
{
if (bi)
{
send_cmd(bi->GetUID(), "MODE %s %s", dest->name.c_str(), buf);
}
else send_cmd(TS6SID, "MODE %s %s", dest->name.c_str(), buf);
}
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(bi ? bi->GetUID() : TS6SID, "SVSMODE %s %s", u->nick.c_str(), buf);
}
void SendKickInternal(BotInfo *bi, Channel *chan, User *user, const char *buf)
{
if (buf) send_cmd(bi->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
else send_cmd(bi->GetUID(), "KICK %s %s", chan->name.c_str(), user->GetUID().c_str());
if (buf)
send_cmd(bi->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
else
send_cmd(bi->GetUID(), "KICK %s %s", chan->name.c_str(), user->GetUID().c_str());
}
void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
@@ -250,8 +247,10 @@ class RatboxProto : public IRCDTS6Proto
/* QUIT */
void SendQuitInternal(BotInfo *bi, const char *buf)
{
if (buf) send_cmd(bi->GetUID(), "QUIT :%s", buf);
else send_cmd(bi->GetUID(), "QUIT");
if (buf)
send_cmd(bi->GetUID(), "QUIT :%s", buf);
else
send_cmd(bi->GetUID(), "QUIT");
}
/* INVITE */
@@ -274,7 +273,8 @@ class RatboxProto : public IRCDTS6Proto
int IsNickValid(const char *nick)
{
/* TS6 Save extension -Certus */
if (isdigit(*nick)) return 0;
if (isdigit(*nick))
return 0;
return 1;
}
@@ -295,12 +295,8 @@ class RatboxProto : public IRCDTS6Proto
u->Account()->Shrink("authenticationtoken");
u->Account()->Extend("authenticationtoken", new ExtensibleItemPointerArray<char>(sstrdup(svidbuf)));
}
} ircd_proto;
int anope_event_sjoin(const char *source, int ac, const char **av)
{
Channel *c = findchan(av[1]);
@@ -350,11 +346,11 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */
else
keep_their_modes = false;
/* Mark the channel as syncing */
if (was_created)
c->SetFlag(CH_SYNCING);
/* If we need to keep their modes, and this SJOIN string contains modes */
if (keep_their_modes && ac >= 4)
{
@@ -400,10 +396,8 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Update their status internally on the channel
* This will enforce secureops etc on the user
*/
for (std::list<ChannelMode *>::iterator it = Status.begin(); it != Status.end(); ++it)
{
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it)
c->SetModeInternal(*it, buf);
}
/* Now set whatever modes this user is allowed to have on the channel */
chan_set_correct_modes(u, c, 1);
@@ -467,8 +461,7 @@ int anope_event_nick(const char *source, int ac, const char **av)
{
Server *s = Server::Find(source ? source : "");
/* Source is always the server */
user = do_nick("", av[0], av[4], av[5], s->GetName().c_str(), av[8],
strtoul(av[2], NULL, 10), 0, "*", av[7]);
user = do_nick("", av[0], av[4], av[5], s->GetName().c_str(), av[8], strtoul(av[2], NULL, 10), 0, "*", av[7]);
if (user)
{
/* No usermode +d on ratbox so we use
@@ -478,13 +471,9 @@ int anope_event_nick(const char *source, int ac, const char **av)
UserSetInternalModes(user, 1, &av[3]);
}
} else {
if (ac == 2)
{
do_nick(source, av[0], NULL, NULL, NULL, NULL,
strtoul(av[1], NULL, 10), 0, NULL, NULL);
}
}
else if (ac == 2)
do_nick(source, av[0], NULL, NULL, NULL, NULL, strtoul(av[1], NULL, 10), 0, NULL, NULL);
return MOD_CONT;
}
@@ -492,13 +481,15 @@ int anope_event_topic(const char *source, int ac, const char **av)
{
User *u;
if (ac == 4) {
if (ac == 4)
do_topic(source, ac, av);
} else {
else
{
Channel *c = findchan(av[0]);
time_t topic_time = time(NULL);
if (!c) {
if (!c)
{
Alog(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
return MOD_CONT;
}
@@ -506,7 +497,8 @@ int anope_event_topic(const char *source, int ac, const char **av)
if (check_topiclock(c, topic_time))
return MOD_CONT;
if (c->topic) {
if (c->topic)
{
delete [] c->topic;
c->topic = NULL;
}
@@ -519,10 +511,12 @@ int anope_event_topic(const char *source, int ac, const char **av)
record_topic(av[0]);
if (ac > 1 && *av[1]) {
if (ac > 1 && *av[1])
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[1]));
}
else {
else
{
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, ""));
}
}
@@ -535,16 +529,15 @@ int anope_event_tburst(const char *source, int ac, const char **av)
Channel *c;
time_t topic_time;
if (ac != 4) {
if (ac != 4)
return MOD_CONT;
}
setter = myStrGetToken(av[2], '!', 0);
c = findchan(av[0]);
topic_time = strtol(av[1], NULL, 10);
if (!c)
if (!c)
{
Alog(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
if (setter)
@@ -552,13 +545,15 @@ int anope_event_tburst(const char *source, int ac, const char **av)
return MOD_CONT;
}
if (check_topiclock(c, topic_time)) {
if (check_topiclock(c, topic_time))
{
if (setter)
delete [] setter;
return MOD_CONT;
}
if (c->topic) {
if (c->topic)
{
delete [] c->topic;
c->topic = NULL;
}
@@ -583,7 +578,6 @@ int anope_event_436(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_ping(const char *source, int ac, const char **av)
{
if (ac < 1)
@@ -620,20 +614,20 @@ int anope_event_kick(const char *source, int ac, const char **av)
int anope_event_join(const char *source, int ac, const char **av)
{
if (ac != 1) {
if (ac != 1)
{
anope_event_sjoin(source, ac, av);
return MOD_CONT;
} else {
do_join(source, ac, av);
}
else
do_join(source, ac, av);
return MOD_CONT;
}
int anope_event_motd(const char *source, int ac, const char **av)
{
if (!source) {
if (!source)
return MOD_CONT;
}
m_motd(source);
return MOD_CONT;
@@ -644,9 +638,8 @@ int anope_event_privmsg(const char *source, int ac, const char **av)
User *u;
BotInfo *bi;
if (ac != 2) {
if (ac != 2)
return MOD_CONT;
}
u = finduser(source);
bi = findbot(av[0]);
@@ -659,9 +652,8 @@ int anope_event_part(const char *source, int ac, const char **av)
{
User *u;
if (ac < 1 || ac > 2) {
if (ac < 1 || ac > 2)
return MOD_CONT;
}
u = finduser(source);
do_part(u ? u->nick.c_str() : source, ac, av);
@@ -673,7 +665,8 @@ int anope_event_whois(const char *source, int ac, const char **av)
{
BotInfo *bi;
if (source && ac >= 1) {
if (source && ac >= 1)
{
bi = findbot(av[0]);
m_whois(source, bi->GetUID().c_str());
}
@@ -683,15 +676,15 @@ int anope_event_whois(const char *source, int ac, const char **av)
/* EVENT: SERVER */
int anope_event_server(const char *source, int ac, const char **av)
{
if (!stricmp(av[1], "1")) {
if (TS6UPLINK) {
if (!stricmp(av[1], "1"))
{
if (TS6UPLINK)
do_server(source, av[0], atoi(av[1]), av[2], TS6UPLINK);
} else {
else
do_server(source, av[0], atoi(av[1]), av[2], "");
}
} else {
do_server(source, av[0], atoi(av[1]), av[2], "");
}
else
do_server(source, av[0], atoi(av[1]), av[2], "");
return MOD_CONT;
}
@@ -717,9 +710,8 @@ int anope_event_quit(const char *source, int ac, const char **av)
{
User *u;
if (ac != 1) {
if (ac != 1)
return MOD_CONT;
}
u = finduser(source);
@@ -731,13 +723,13 @@ int anope_event_mode(const char *source, int ac, const char **av)
{
User *u, *u2;
if (ac < 2) {
if (ac < 2)
return MOD_CONT;
}
if (*av[0] == '#' || *av[0] == '&') {
if (*av[0] == '#' || *av[0] == '&')
do_cmode(source, ac, av);
} else {
else
{
u = finduser(source);
u2 = finduser(av[0]);
av[0] = u2->nick.c_str();
@@ -748,9 +740,8 @@ int anope_event_mode(const char *source, int ac, const char **av)
int anope_event_tmode(const char *source, int ac, const char **av)
{
if (*av[1] == '#' || *av[1] == '&') {
if (*av[1] == '#' || *av[1] == '&')
do_cmode(source, ac, av);
}
return MOD_CONT;
}
@@ -779,20 +770,25 @@ int anope_event_bmask(const char *source, int ac, const char **av)
/* 0 1 2 3 */
c = findchan(av[1]);
if (c) {
if (c)
{
bans = sstrdup(av[3]);
count = myNumToken(bans, ' ');
for (i = 0; i <= count - 1; i++) {
for (i = 0; i <= count - 1; ++i)
{
b = myStrGetToken(bans, ' ', i);
if (!stricmp(av[2], "b")) {
if (!stricmp(av[2], "b"))
{
cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "e")) {
if (!stricmp(av[2], "e"))
{
cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "I")) {
if (!stricmp(av[2], "I"))
{
cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
cms->AddMask(c, b);
}
+154 -159
View File
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
/*************************************************************************/
@@ -17,41 +15,41 @@
#include "modules.h"
IRCDVar myIrcd[] = {
{"UnrealIRCd 3.2.x", /* ircd name */
"+Soi", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
3, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
1, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
1, /* time stamp on mode */
1, /* NICKIP */
1, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
1, /* Change RealName */
1, /* No Knock requires +i */
1, /* We support Unreal TOKENS */
1, /* TIME STAMPS are BASE64 */
1, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
0, /* p10 */
0, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
{"UnrealIRCd 3.2.x", /* ircd name */
"+Soi", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
1, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
3, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Chan SQlines */
0, /* Quit on Kill */
1, /* SVSMODE unban */
1, /* Reverse */
1, /* vidents */
1, /* svshold */
1, /* time stamp on mode */
1, /* NICKIP */
1, /* O:LINE */
1, /* UMODE */
1, /* VHOST ON NICK */
1, /* Change RealName */
1, /* No Knock requires +i */
1, /* We support Unreal TOKENS */
1, /* TIME STAMPS are BASE64 */
1, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
0, /* p10 */
0, /* CIDR channelbans */
"$", /* TLD Prefix for Global */
12, /* Max number of modes we can send per line */
}
,
@@ -72,31 +70,28 @@ void unreal_cmd_netinfo(int ac, const char **av)
{
send_cmd(NULL, "AO %ld %ld %d %s 0 0 0 :%s", static_cast<long>(maxusercnt), static_cast<long>(time(NULL)), atoi(av[2]), av[3], av[7]);
}
/* PROTOCTL */
/*
NICKv2 = Nick Version 2
VHP = Sends hidden host
VHP = Sends hidden host
UMODE2 = sends UMODE2 on user modes
NICKIP = Sends IP on NICK
TOKEN = Use tokens to talk
SJ3 = Supports SJOIN
SJ3 = Supports SJOIN
NOQUIT = No Quit
TKLEXT = Extended TKL we don't use it but best to have it
SJB64 = Base64 encoded time stamps
VL = Version Info
NS = Config.Numeric Server
VL = Version Info
NS = Config.Numeric Server
*/
void unreal_cmd_capab()
{
if (Config.Numeric)
{
send_cmd(NULL, "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT SJB64 VL");
}
else
{
send_cmd(NULL, "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT SJB64");
}
}
/* PASS */
@@ -108,23 +103,19 @@ void unreal_cmd_pass(const char *pass)
/* CHGHOST */
void unreal_cmd_chghost(const char *nick, const char *vhost)
{
if (!nick || !vhost) {
if (!nick || !vhost)
return;
}
send_cmd(Config.ServerName, "AL %s %s", nick, vhost);
}
/* CHGIDENT */
void unreal_cmd_chgident(const char *nick, const char *vIdent)
{
if (!nick || !vIdent) {
if (!nick || !vIdent)
return;
}
send_cmd(Config.ServerName, "AZ %s %s", nick, vIdent);
}
class UnrealIRCdProto : public IRCDProto
{
/* SVSNOOP */
@@ -157,7 +148,8 @@ class UnrealIRCdProto : public IRCDProto
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - time(NULL);
if (timeleft > 172800) timeleft = 172800;
if (timeleft > 172800)
timeleft = 172800;
send_cmd(NULL, "BD + G %s %s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(time(NULL) + timeleft), static_cast<long>(x->Expires), x->Reason.c_str());
}
@@ -175,21 +167,25 @@ class UnrealIRCdProto : public IRCDProto
*/
void SendSVSMode(User *u, int ac, const char **av)
{
if (ac >= 1) {
if (!u || !av[0]) return;
if (ac >= 1)
{
if (!u || !av[0])
return;
this->SendModeInternal(NULL, u, merge_args(ac, av));
}
}
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(source->nick, "G %s %s", dest->name.c_str(), buf);
}
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(bi ? bi->nick : Config.ServerName, "v %s %s", u->nick.c_str(), buf);
}
@@ -201,13 +197,16 @@ class UnrealIRCdProto : public IRCDProto
void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
{
if (buf) send_cmd(source->nick, "H %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
else send_cmd(source->nick, "H %s %s", chan->name.c_str(), user->nick.c_str());
if (buf)
send_cmd(source->nick, "H %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
else
send_cmd(source->nick, "H %s %s", chan->name.c_str(), user->nick.c_str());
}
void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
if (!buf)
return;
send_cmd(source->nick, "B @%s :%s", dest->name.c_str(), buf);
}
@@ -234,7 +233,6 @@ class UnrealIRCdProto : public IRCDProto
send_cmd(NULL, "d %s", x->Mask.c_str());
}
/* SQLINE */
/*
** - Unreal will translate this to TKL for us
@@ -253,14 +251,16 @@ class UnrealIRCdProto : public IRCDProto
*/
void SendSVSO(const char *source, const char *nick, const char *flag)
{
if (!source || !nick || !flag) return;
if (!source || !nick || !flag)
return;
send_cmd(source, "BB %s %s", nick, flag);
}
/* NICK <newnick> */
void SendChangeBotNick(BotInfo *oldnick, const char *newnick)
{
if (!oldnick || !newnick) return;
if (!oldnick || !newnick)
return;
send_cmd(oldnick->nick, "& %s %ld", newnick, static_cast<long>(time(NULL)));
}
@@ -268,7 +268,7 @@ class UnrealIRCdProto : public IRCDProto
void SendVhost(User *u, const std::string &vIdent, const std::string &vhost)
{
if (!vIdent.empty())
if (!vIdent.empty())
unreal_cmd_chgident(u->nick.c_str(), vIdent.c_str());
if (!vhost.empty())
unreal_cmd_chghost(u->nick.c_str(), vhost.c_str());
@@ -285,8 +285,7 @@ class UnrealIRCdProto : public IRCDProto
/* SVSHOLD - set */
void SendSVSHold(const char *nick)
{
send_cmd(NULL, "BD + Q H %s %s %ld %ld :%s", nick, Config.ServerName, static_cast<long>(time(NULL) + Config.NSReleaseTimeout),
static_cast<long>(time(NULL)), "Being held for registered user");
send_cmd(NULL, "BD + Q H %s %s %ld %ld :%s", nick, Config.ServerName, static_cast<long>(time(NULL) + Config.NSReleaseTimeout), static_cast<long>(time(NULL)), "Being held for registered user");
}
/* SVSHOLD - release */
@@ -334,13 +333,14 @@ class UnrealIRCdProto : public IRCDProto
SendSVSModeChan(c, "-b", nick.empty() ? NULL : nick.c_str());
}
/* SVSMODE channel modes */
void SendSVSModeChan(Channel *c, const char *mode, const char *nick)
{
if (nick) send_cmd(Config.ServerName, "n %s %s %s", c->name.c_str(), mode, nick);
else send_cmd(Config.ServerName, "n %s %s", c->name.c_str(), mode);
if (nick)
send_cmd(Config.ServerName, "n %s %s %s", c->name.c_str(), mode, nick);
else
send_cmd(Config.ServerName, "n %s %s", c->name.c_str(), mode);
}
/* svsjoin
@@ -354,8 +354,10 @@ class UnrealIRCdProto : public IRCDProto
*/
void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param)
{
if (param) send_cmd(source, "BX %s %s :%s", nick, chan, param);
else send_cmd(source, "BX %s :%s", nick, chan);
if (param)
send_cmd(source, "BX %s %s :%s", nick, chan, param);
else
send_cmd(source, "BX %s :%s", nick, chan);
}
/* svspart
@@ -391,7 +393,8 @@ class UnrealIRCdProto : public IRCDProto
int IsChannelValid(const char *chan)
{
if (strchr(chan, ':') || *chan != '#') return 0;
if (strchr(chan, ':') || *chan != '#')
return 0;
return 1;
}
@@ -419,11 +422,8 @@ class UnrealIRCdProto : public IRCDProto
u->RemoveMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d 1");
}
} ircd_proto;
/* Event: PROTOCTL */
int anope_event_capab(const char *source, int ac, const char **av)
{
@@ -438,7 +438,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
std::string modebuf;
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -457,7 +457,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -476,7 +476,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -492,7 +492,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
}
sep.GetToken(modebuf);
for (size_t t = 0; t < modebuf.size(); ++t)
for (size_t t = 0, end = modebuf.size(); t < end; ++t)
{
switch (modebuf[t])
{
@@ -584,7 +584,7 @@ int anope_event_ping(const char *source, int ac, const char **av)
}
/** This is here because:
*
*
* If we had servers three servers, A, B & C linked like so: A<->B<->C
* If Anope is (linked to) A and B splits from A and then reconnects
* B introduces itself, introduces C, sends EOS for C, introduces Bs clients
@@ -632,9 +632,8 @@ int anope_event_436(const char *source, int ac, const char **av)
*/
int anope_event_away(const char *source, int ac, const char **av)
{
if (!source) {
if (!source)
return MOD_CONT;
}
m_away(source, (ac ? av[0] : NULL));
return MOD_CONT;
}
@@ -680,11 +679,10 @@ int anope_event_mode(const char *source, int ac, const char **av)
if (ac < 2)
return MOD_CONT;
if (*av[0] == '#' || *av[0] == '&') {
if (*av[0] == '#' || *av[0] == '&')
do_cmode(source, ac, av);
} else {
else
do_umode(source, ac, av);
}
return MOD_CONT;
}
@@ -731,7 +729,6 @@ int anope_event_kick(const char *source, int ac, const char **av)
return MOD_CONT;
}
int anope_event_join(const char *source, int ac, const char **av)
{
if (ac != 1)
@@ -742,9 +739,8 @@ int anope_event_join(const char *source, int ac, const char **av)
int anope_event_motd(const char *source, int ac, const char **av)
{
if (!source) {
if (!source)
return MOD_CONT;
}
m_motd(source);
return MOD_CONT;
@@ -758,7 +754,7 @@ int anope_event_setname(const char *source, int ac, const char **av)
return MOD_CONT;
u = finduser(source);
if (!u)
if (!u)
{
Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source;
return MOD_CONT;
@@ -794,7 +790,7 @@ int anope_event_setident(const char *source, int ac, const char **av)
return MOD_CONT;
u = finduser(source);
if (!u)
if (!u)
{
Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source;
return MOD_CONT;
@@ -829,7 +825,7 @@ int anope_event_sethost(const char *source, int ac, const char **av)
return MOD_CONT;
u = finduser(source);
if (!u)
if (!u)
{
Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source;
return MOD_CONT;
@@ -837,13 +833,9 @@ int anope_event_sethost(const char *source, int ac, const char **av)
/* When a user sets +x we recieve the new host and then the mode change */
if (u->HasMode(UMODE_CLOAK))
{
u->SetDisplayedHost(av[0]);
}
else
{
u->SetCloakedHost(av[0]);
}
return MOD_CONT;
}
@@ -883,35 +875,35 @@ int anope_event_nick(const char *source, int ac, const char **av)
{
User *user;
if (ac != 2) {
if (ac == 7) {
if (ac != 2)
{
if (ac == 7)
{
/*
<codemastr> that was a bug that is now fixed in 3.2.1
<codemastr> in some instances it would use the non-nickv2 format
<codemastr> it's sent when a nick collision occurs
- so we have to leave it around for now -TSL
*/
do_nick(source, av[0], av[3], av[4], av[5], av[6],
strtoul(av[2], NULL, 10), 0, "*", NULL);
} else if (ac == 11) {
user = do_nick(source, av[0], av[3], av[4], av[5], av[10],
strtoul(av[2], NULL, 10), ntohl(decode_ip(av[9])), av[8], NULL);
if (user)
{
/* Check to see if the user should be identified because their
* services id matches the one in their nickcore
*/
user->CheckAuthenticationToken(av[6]);
UserSetInternalModes(user, 1, &av[7]);
}
} else {
/* NON NICKIP */
user = do_nick(source, av[0], av[3], av[4], av[5], av[9],
strtoul(av[2], NULL, 10), 0, av[8],
NULL);
do_nick(source, av[0], av[3], av[4], av[5], av[6], strtoul(av[2], NULL, 10), 0, "*", NULL);
}
else if (ac == 11)
{
user = do_nick(source, av[0], av[3], av[4], av[5], av[10], strtoul(av[2], NULL, 10), ntohl(decode_ip(av[9])), av[8], NULL);
if (user)
{
/* Check to see if the user should be identified because their
* services id matches the one in their nickcore
*/
user->CheckAuthenticationToken(av[6]);
UserSetInternalModes(user, 1, &av[7]);
}
}
else
{
/* NON NICKIP */
user = do_nick(source, av[0], av[3], av[4], av[5], av[9], strtoul(av[2], NULL, 10), 0, av[8], NULL);
if (user)
{
/* Check to see if the user should be identified because their
@@ -922,14 +914,12 @@ int anope_event_nick(const char *source, int ac, const char **av)
UserSetInternalModes(user, 1, &av[7]);
}
}
} else {
do_nick(source, av[0], NULL, NULL, NULL, NULL,
strtoul(av[1], NULL, 10), 0, NULL, NULL);
}
else
do_nick(source, av[0], NULL, NULL, NULL, NULL, strtoul(av[1], NULL, 10), 0, NULL, NULL);
return MOD_CONT;
}
int anope_event_chghost(const char *source, int ac, const char **av)
{
User *u;
@@ -955,7 +945,8 @@ int anope_event_server(const char *source, int ac, const char **av)
char *vl;
char *upnumeric;
if (!stricmp(av[1], "1")) {
if (!stricmp(av[1], "1"))
{
vl = myStrGetToken(av[2], ' ', 0);
upnumeric = myStrGetToken(vl, '-', 2);
desc = myStrGetTokenRemainder(av[2], ' ', 1);
@@ -963,9 +954,9 @@ int anope_event_server(const char *source, int ac, const char **av)
delete [] vl;
delete [] desc;
delete [] upnumeric;
} else {
do_server(source, av[0], atoi(av[1]), av[2], "");
}
else
do_server(source, av[0], atoi(av[1]), av[2], "");
ircdproto->SendPing(Config.ServerName, av[0]);
return MOD_CONT;
@@ -989,19 +980,17 @@ int anope_event_part(const char *source, int ac, const char **av)
int anope_event_whois(const char *source, int ac, const char **av)
{
if (source && ac >= 1) {
if (source && ac >= 1)
m_whois(source, av[0]);
}
return MOD_CONT;
}
int anope_event_error(const char *source, int ac, const char **av)
{
if (av[0])
{
Alog(LOG_DEBUG) << av[0];
if(strstr(av[0],"No matching link configuration")!=0)
if (strstr(av[0], "No matching link configuration"))
Alog() << "Error: Your IRCD's link block may not be setup correctly, please check unrealircd.conf";
}
return MOD_CONT;
@@ -1066,7 +1055,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */
else
keep_their_modes = false;
/* Mark the channel as syncing */
if (was_created)
c->SetFlag(CH_SYNCING);
@@ -1144,11 +1133,9 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Update their status internally on the channel
* This will enforce secureops etc on the user
*/
for (std::list<ChannelMode *>::iterator it = Status.begin(); it != Status.end(); ++it)
{
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it)
c->SetModeInternal(*it, buf);
}
/* Now set whatever modes this user is allowed to have on the channel */
chan_set_correct_modes(u, c, 1);
@@ -1184,43 +1171,43 @@ void moduleAddIRCDMsgs()
{
Anope::AddMessage("436", anope_event_436);
Anope::AddMessage("AWAY", anope_event_away);
Anope::AddMessage("6", anope_event_away);
Anope::AddMessage("6", anope_event_away);
Anope::AddMessage("JOIN", anope_event_join);
Anope::AddMessage("C", anope_event_join);
Anope::AddMessage("KICK", anope_event_kick);
Anope::AddMessage("H", anope_event_kick);
Anope::AddMessage("H", anope_event_kick);
Anope::AddMessage("KILL", anope_event_kill);
Anope::AddMessage(".", anope_event_kill);
Anope::AddMessage(".", anope_event_kill);
Anope::AddMessage("MODE", anope_event_mode);
Anope::AddMessage("G", anope_event_gmode);
Anope::AddMessage("G", anope_event_gmode);
Anope::AddMessage("MOTD", anope_event_motd);
Anope::AddMessage("F", anope_event_motd);
Anope::AddMessage("F", anope_event_motd);
Anope::AddMessage("NICK", anope_event_nick);
Anope::AddMessage("&", anope_event_nick);
Anope::AddMessage("&", anope_event_nick);
Anope::AddMessage("PART", anope_event_part);
Anope::AddMessage("D", anope_event_part);
Anope::AddMessage("D", anope_event_part);
Anope::AddMessage("PING", anope_event_ping);
Anope::AddMessage("8", anope_event_ping);
Anope::AddMessage("8", anope_event_ping);
Anope::AddMessage("PONG", anope_event_pong);
Anope::AddMessage("9", anope_event_pong);
Anope::AddMessage("PRIVMSG", anope_event_privmsg);
Anope::AddMessage("!", anope_event_privmsg);
Anope::AddMessage("!", anope_event_privmsg);
Anope::AddMessage("QUIT", anope_event_quit);
Anope::AddMessage(",", anope_event_quit);
Anope::AddMessage(",", anope_event_quit);
Anope::AddMessage("SERVER", anope_event_server);
Anope::AddMessage("'", anope_event_server);
Anope::AddMessage("'", anope_event_server);
Anope::AddMessage("SQUIT", anope_event_squit);
Anope::AddMessage("-", anope_event_squit);
Anope::AddMessage("-", anope_event_squit);
Anope::AddMessage("TOPIC", anope_event_topic);
Anope::AddMessage(")", anope_event_topic);
Anope::AddMessage(")", anope_event_topic);
Anope::AddMessage("SVSMODE", anope_event_mode);
Anope::AddMessage("n", anope_event_mode);
Anope::AddMessage("n", anope_event_mode);
Anope::AddMessage("SVS2MODE", anope_event_mode);
Anope::AddMessage("v", anope_event_mode);
Anope::AddMessage("WHOIS", anope_event_whois);
Anope::AddMessage("#", anope_event_whois);
Anope::AddMessage("#", anope_event_whois);
Anope::AddMessage("PROTOCTL", anope_event_capab);
Anope::AddMessage("_", anope_event_capab);
Anope::AddMessage("_", anope_event_capab);
Anope::AddMessage("CHGHOST", anope_event_chghost);
Anope::AddMessage("AL", anope_event_chghost);
Anope::AddMessage("CHGIDENT", anope_event_chgident);
@@ -1238,7 +1225,7 @@ void moduleAddIRCDMsgs()
Anope::AddMessage("ERROR", anope_event_error);
Anope::AddMessage("5", anope_event_error);
Anope::AddMessage("UMODE2", anope_event_umode2);
Anope::AddMessage("|", anope_event_umode2);
Anope::AddMessage("|", anope_event_umode2);
Anope::AddMessage("SJOIN", anope_event_sjoin);
Anope::AddMessage("~", anope_event_sjoin);
Anope::AddMessage("SDESC", anope_event_sdesc);
@@ -1258,23 +1245,31 @@ bool ChannelModeFlood::IsValid(const std::string &value2)
/* NEW +F */
char xbuf[256], *p, *p2, *x = xbuf + 1;
int v;
if (!value) return 0;
if (*value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1;
else {
if (!value)
return 0;
if (*value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end)
return 1;
else
{
/* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
strlcpy(xbuf, value, sizeof(xbuf));
p2 = strchr(xbuf + 1, ']');
if (!p2) return 0;
*p2 = '\0';
if (*(p2 + 1) != ':') return 0;
for (x = strtok(xbuf + 1, ","); x; x = strtok(NULL, ",")) {
if (*(p2 + 1) != ':')
return 0;
for (x = strtok(xbuf + 1, ","); x; x = strtok(NULL, ","))
{
/* <number><1 letter>[optional: '#'+1 letter] */
p = x;
while (isdigit(*p)) ++p;
if (!*p || !(*p == 'c' || *p == 'j' || *p == 'k' || *p == 'm' || *p == 'n' || *p == 't')) continue; /* continue instead of break for forward compatability. */
while (isdigit(*p))
++p;
if (!*p || !(*p == 'c' || *p == 'j' || *p == 'k' || *p == 'm' || *p == 'n' || *p == 't'))
continue; /* continue instead of break for forward compatability. */
*p = '\0';
v = atoi(x);
if (v < 1 || v > 999) return 0;
if (v < 1 || v > 999)
return 0;
++p;
}
return 1;
@@ -1341,7 +1336,7 @@ class ProtoUnreal : public Module
ModuleManager::Attach(I_OnUserNickChange, this);
}
void OnUserNickChange(User *u, const std::string &)
{
u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));