summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-04-29 17:31:34 -0400
committerAdam <Adam@anope.org>2010-06-18 20:58:52 -0400
commitc1d161dec451ea790ff87078b5d80b1f71a3e9f0 (patch)
tree2ada0230d0411d10bb1e710d701874d253a4d4aa /src
parent73e93305c10f349742fad3b2197c6c5dd3aea34e (diff)
Rewrote all of the server handling code
Diffstat (limited to 'src')
-rw-r--r--src/Makefile26
-rw-r--r--src/bots.cpp3
-rw-r--r--src/botserv.c2
-rw-r--r--src/channels.c12
-rw-r--r--src/core/cs_modes.c2
-rw-r--r--src/core/cs_xop.c2
-rw-r--r--src/core/os_defcon.c6
-rw-r--r--src/core/os_jupe.c12
-rw-r--r--src/core/os_noop.c2
-rw-r--r--src/core/os_stats.c21
-rw-r--r--src/main.c2
-rw-r--r--src/modules.c4
-rw-r--r--src/operserv.c47
-rw-r--r--src/protocol.cpp4
-rw-r--r--src/protocol/bahamut.c23
-rw-r--r--src/protocol/inspircd11.c13
-rw-r--r--src/protocol/inspircd12.cpp29
-rw-r--r--src/protocol/ratbox.c26
-rw-r--r--src/protocol/unreal32.c23
-rw-r--r--src/regchannel.cpp2
-rw-r--r--src/servers.c702
-rw-r--r--src/servers.cpp576
-rw-r--r--src/users.c21
23 files changed, 702 insertions, 858 deletions
diff --git a/src/Makefile b/src/Makefile
index 949e7e8ec..be4004ec9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,8 +1,8 @@
OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o command.o commands.o compat.o \
- config.o encrypt.o hashcomp.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \
- memory.o memoserv.o messages.o misc.o modules.o nickserv.o operserv.o \
- process.o protocol.o send.o servers.o sessions.o slist.o sockets.o opertype.o users.o module.o modulemanager.o configreader.o \
- wildcard.o nickcore.o nickalias.o timers.o modes.o regchannel.o
+ config.o configreader.o encrypt.o hashcomp.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \
+ memory.o memoserv.o messages.o misc.o modes.o modules.o module.o modulemanager.o nickalias.o \
+ nickcore.o nickserv.o operserv.o process.o protocol.o regchannel.o send.o servers.o sessions.o slist.o \
+ sockets.o timers.o opertype.o users.o wildcard.o
INCLUDES = ../include/commands.h ../include/defs.h ../include/language.h \
../include/pseudo.h ../include/sysconf.h ../include/config.h \
@@ -33,20 +33,17 @@ services: $(OBJS)
$(MAKEBIN) $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS)
$(OBJS): Makefile
-modes.o: modes.cpp $(INCLUDES)
-timers.o: timers.cpp $(INCLUDES)
-nickcore.o: nickcore.cpp $(INCLUDES)
-nickalias.o: nickalias.cpp $(INCLUDES)
actions.o: actions.c $(INCLUDES)
base64.o: base64.c $(INCLUDES)
bots.o: bots.cpp $(INCLUDES)
botserv.o: botserv.c $(INCLUDES)
channels.o: channels.c $(INCLUDES)
chanserv.o: chanserv.c $(INCLUDES)
-command.o: command.cpp $(INCLUDES)
+command.o: command.cpp $(INCLUDES)
commands.o: commands.c $(INCLUDES)
compat.o: compat.c $(INCLUDES)
config.o: config.c $(INCLUDES)
+configreader.o: configreader.cpp $(INCLUDES)
encrypt.o: encrypt.c $(INCLUDES)
init.o: init.c $(INCLUDES)
ircd.o: ircd.c $(INCLUDES)
@@ -58,23 +55,26 @@ main.o: main.c $(INCLUDES)
memory.o: memory.c $(INCLUDES)
memoserv.o: memoserv.c $(INCLUDES)
messages.o: messages.c $(INCLUDES)
+modes.o: modes.cpp $(INCLUDES)
modules.o: modules.c $(INCLUDES)
module.o: module.cpp $(INCLUDES)
modulemanager.o: modulemanager.cpp $(INCLUDES)
misc.o: misc.c $(INCLUDES)
+nickalias.o: nickalias.cpp $(INCLUDES)
+nickcore.o: nickcore.cpp $(INCLUDES)
nickserv.o: nickserv.c $(INCLUDES)
operserv.o: operserv.c $(INCLUDES)
+opertype.o: opertype.cpp $(INCLUDES)
process.o: process.c $(INCLUDES)
protocol.o: protocol.cpp $(INCLUDES)
regchannel.o: regchannel.cpp $(INCLUDES)
send.o: send.c $(INCLUDES)
-servers.o: servers.c $(INCLUDES)
+servers.o: servers.cpp $(INCLUDES)
sessions.o: sessions.c $(INCLUDES)
slist.o: slist.c $(INCLUDES)
-sockets.o: sockets.cpp $(INCLUDES)
-opertype.o: opertype.cpp $(INCLUDES)
+sockets.o: sockets.cpp $(INCLUDES)
+timers.o: timers.cpp $(INCLUDES)
users.o: users.c $(INCLUDES)
-vsnprintf.o: vsnprintf.c $(INCLUDES)
wildcard.o: wildcard.cpp $(INCLUDES)
modules: DUMMY
diff --git a/src/bots.cpp b/src/bots.cpp
index e663d9225..f65f2a35e 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -63,8 +63,7 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::
insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
// If we're synchronised with the uplink already, call introduce_user() for this bot.
- if (serv_uplink && serv_uplink->sync == SSYNC_DONE)
- {
+ if (Me && Me->GetUplink()->IsSynced())
ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid);
ircdproto->SendSQLine(this->nick, "Reserved for services");
}
diff --git a/src/botserv.c b/src/botserv.c
index 54b968dec..05c8ea2bd 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -665,7 +665,7 @@ static void check_ban(ChannelInfo *ci, User *u, int ttbtype)
return;
/* Don't ban ulines */
- if (is_ulined(u->server->name))
+ if (u->server->IsULined())
return;
bd->ttb[ttbtype]++;
diff --git a/src/channels.c b/src/channels.c
index b98a2f579..557894eff 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -118,7 +118,7 @@ void Channel::Sync()
stick_all(this->ci);
}
- if (serv_uplink && is_sync(serv_uplink) && !this->topic_sync)
+ if (Me && Me->IsSynced() && !this->topic_sync)
restore_topic(name.c_str());
}
@@ -146,7 +146,7 @@ void Channel::JoinUser(User *user)
}
/* Added channelname to entrymsg - 30.03.2004, Certus */
/* Also, don't send the entrymsg when bursting -GD */
- if (this->ci && this->ci->entry_message && is_sync(user->server))
+ if (this->ci && this->ci->entry_message && user->server->IsSynced())
user->SendMessage(whosends(this->ci)->nick, "[%s] %s", this->name.c_str(), this->ci->entry_message);
}
@@ -158,7 +158,7 @@ void Channel::JoinUser(User *user)
* But don't join the bot if the channel is persistant - Adam
* But join persistant channels when syncing with our uplink- DP
**/
- if (Config.s_BotServ && this->ci && this->ci->bi && ((serv_uplink->sync == SSYNC_IN_PROGRESS) || !this->ci->HasFlag(CI_PERSIST)))
+ if (Config.s_BotServ && this->ci && this->ci->bi && (!Me->IsSynced() || !this->ci->HasFlag(CI_PERSIST)))
{
if (this->users.size() == Config.BSMinUsers)
bot_join(this->ci);
@@ -172,7 +172,7 @@ void Channel::JoinUser(User *user)
* to has synced, or we'll get greet-floods when the net
* recovers from a netsplit. -GD
*/
- if (is_sync(user->server))
+ if (user->server->IsSynced())
{
ircdproto->SendPrivmsg(this->ci->bi, this->name.c_str(), "[%s] %s", user->Account()->display, user->Account()->greet);
this->ci->bi->lastmsg = time(NULL);
@@ -975,7 +975,7 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...)
va_end(args);
/* May not kick ulines */
- if (is_ulined(u->server->name))
+ if (u->server->IsULined())
return false;
EventReturn MOD_RESULT;
@@ -1513,7 +1513,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
c->SetMode(NULL, CMODE_VOICE, user->nick);
}
/* If this channel has secureops or the user matches autodeop or the channel is syncing and this is the first user and they are not ulined, check to remove modes */
- if ((ci->HasFlag(CI_SECUREOPS) || check_access(user, ci, CA_AUTODEOP) || (c->HasFlag(CH_SYNCING) && c->users.size() == 1)) && !is_ulined(user->server->name))
+ if ((ci->HasFlag(CI_SECUREOPS) || check_access(user, ci, CA_AUTODEOP) || (c->HasFlag(CH_SYNCING) && c->users.size() == 1)) && !user->server->IsULined())
{
if (owner && c->HasUserStatus(user, CMODE_OWNER) && !IsFounder(user, ci))
c->RemoveMode(NULL, CMODE_OWNER, user->nick);
diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c
index 3df93d912..06e737eff 100644
--- a/src/core/cs_modes.c
+++ b/src/core/cs_modes.c
@@ -380,7 +380,7 @@ class CSModes : public Module
this->AddCommand(CHANSERV, new CommandCSVoice());
this->AddCommand(CHANSERV, new CommandCSDeVoice());
- if (serv_uplink && is_sync(serv_uplink))
+ if (Me && Me->IsSynced())
OnUplinkSync();
Implementation i[] = {
diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c
index a6f980ad0..18ff222b1 100644
--- a/src/core/cs_xop.c
+++ b/src/core/cs_xop.c
@@ -544,7 +544,7 @@ class CSXOP : public Module
this->AddCommand(CHANSERV, new CommandCSAOP());
this->AddCommand(CHANSERV, new CommandCSVOP());
- if (serv_uplink && is_sync(serv_uplink))
+ if (Me && Me->IsSynced())
OnUplinkSync();
Implementation i[] = {
diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c
index 403ac1281..654ed89cc 100644
--- a/src/core/os_defcon.c
+++ b/src/core/os_defcon.c
@@ -156,13 +156,11 @@ class OSDEFCON : public Module
EventReturn OnPreUserConnect(User *u)
{
- std::string mask;
-
- if (u && is_sync(u->server) && CheckDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(u->server->name))
+ if (u->server->IsSynced() && CheckDefCon(DEFCON_AKILL_NEW_CLIENTS) && !u->server->IsULined())
{
if (CheckDefCon(DEFCON_AKILL_NEW_CLIENTS))
{
- mask = "*@" + std::string(u->host);
+ std::string mask = "*@" + std::string(u->host);
Alog() << "DEFCON: adding akill for " << mask;
add_akill(NULL, mask.c_str(), Config.s_OperServ,
time(NULL) + Config.DefConAKILL,
diff --git a/src/core/os_jupe.c b/src/core/os_jupe.c
index 9af3d3176..899dd4ea4 100644
--- a/src/core/os_jupe.c
+++ b/src/core/os_jupe.c
@@ -25,18 +25,20 @@ class CommandOSJupe : public Command
{
const char *jserver = params[0].c_str();
const char *reason = params.size() > 1 ? params[1].c_str() : NULL;
- Server *server = findserver(servlist, jserver);
+ Server *server = Server::Find(jserver);
if (!isValidHost(jserver, 3))
notice_lang(Config.s_OperServ, u, OPER_JUPE_HOST_ERROR);
- else if (server && (server->HasFlag(SERVER_ISME) || server->HasFlag(SERVER_ISUPLINK)))
+ else if (server && (server == Me || server == Me->GetUplink()))
notice_lang(Config.s_OperServ, u, OPER_JUPE_INVALID_SERVER);
- else {
+ else
+ {
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", u->nick.c_str(), reason ? ": " : "", reason ? reason : "");
- if (findserver(servlist, jserver))
+ if (server)
ircdproto->SendSquit(jserver, rbuf);
- Server *juped_server = new_server(me_server, jserver, rbuf, SERVER_JUPED, ircd->ts6 ? ts6_sid_retrieve() : "");
+ Server *juped_server = new Server(Me, jserver, 0, rbuf, ircd->ts6 ? ts6_sid_retrieve() : "");
+ juped_server->SetFlag(SERVER_JUPED);
ircdproto->SendServer(juped_server);
if (Config.WallOSJupe)
diff --git a/src/core/os_noop.c b/src/core/os_noop.c
index c0fc33161..eec054ea4 100644
--- a/src/core/os_noop.c
+++ b/src/core/os_noop.c
@@ -44,7 +44,7 @@ class CommandOSNOOP : public Command
for (u2 = firstuser(); u2; u2 = u3)
{
u3 = nextuser();
- if (u2 && is_oper(u2) && u2->server->name && Anope::Match(u2->server->name, server, true))
+ if (u2 && is_oper(u2) && Anope::Match(u2->server->GetName(), server, true))
kill_user(Config.s_OperServ, u2->nick.c_str(), reason.c_str());
}
}
diff --git a/src/core/os_stats.c b/src/core/os_stats.c
index 711e1f646..9dae3474a 100644
--- a/src/core/os_stats.c
+++ b/src/core/os_stats.c
@@ -21,16 +21,19 @@ void get_operserv_stats(long *nrec, long *memuse);
* @param s The server to start counting from
* @return Amount of servers connected to server s
**/
-int stats_count_servers(Server *s)
+static int stats_count_servers(Server *s)
{
- int count = 0;
+ if (!s)
+ return 0;
+
+ int count = 1;
- while (s)
+ if (s->GetLinks())
{
- ++count;
- if (s->links)
- count += stats_count_servers(s->links);
- s = s->next;
+ for (std::list<Server *>::const_iterator it = s->GetLinks()->begin(); it != s->GetLinks()->end(); ++it)
+ {
+ count += stats_count_servers(*it);
+ }
}
return count;
@@ -214,9 +217,9 @@ class CommandOSStats : public Command
if (!buf.empty())
buf.erase(buf.begin());
- notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER, serv_uplink->name);
+ notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER, Me->GetUplink()->GetName().c_str());
notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf.c_str());
- notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(serv_uplink));
+ notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(Me->GetUplink()));
return MOD_CONT;
}
diff --git a/src/main.c b/src/main.c
index d17d98a39..234a2e023 100644
--- a/src/main.c
+++ b/src/main.c
@@ -235,8 +235,6 @@ static void services_shutdown()
if (started && UplinkSock)
{
ircdproto->SendSquit(Config.ServerName, quitmsg);
- if (uplink)
- delete [] uplink;
u = firstuser();
while (u) {
next = nextuser();
diff --git a/src/modules.c b/src/modules.c
index af3aa2f4d..97a3b55c6 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -76,10 +76,6 @@ int protocol_module_init()
Alog() << "This IRCd protocol requires a server id to be set in Anope's configuration.";
ret = -1;
}
- else
- {
- ts6_uid_init();
- }
}
}
diff --git a/src/operserv.c b/src/operserv.c
index 455d74923..a5d0f0d61 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -144,60 +144,49 @@ void operserv(User * u, char *buf)
/*************************************************************************/
/*********************** OperServ command functions **********************/
-/*************************************************************************/
+/*******************************
+ * ******************************************/
/*************************************************************************/
-Server *server_global(Server * s, char *msg)
+void server_global(Server *s, const std::string &message)
{
- Server *sl;
-
- while (s) {
- /* Do not send the notice to ourselves our juped servers */
- if (!s->HasFlag(SERVER_ISME) && !s->HasFlag(SERVER_JUPED))
- notice_server(Config.s_GlobalNoticer, s, "%s", msg);
-
- if (s->links) {
- sl = server_global(s->links, msg);
- if (sl)
- s = sl;
- else
- s = s->next;
- } else {
- s = s->next;
+ /* Do not send the notice to ourselves our juped servers */
+ if (s != Me && !s->HasFlag(SERVER_JUPED))
+ notice_server(Config.s_GlobalNoticer, s, "%s", message.c_str());
+
+ if (s->GetLinks())
+ {
+ for (std::list<Server *>::const_iterator it = s->GetLinks()->begin(); it != s->GetLinks()->end(); ++it)
+ {
+ server_global(*it, message);
}
}
- return s;
-
}
void oper_global(char *nick, const char *fmt, ...)
{
va_list args;
char msg[2048]; /* largest valid message is 512, this should cover any global */
- char dmsg[2048]; /* largest valid message is 512, this should cover any global */
va_start(args, fmt);
vsnprintf(msg, sizeof(msg), fmt, args);
va_end(args);
/* I don't like the way this is coded... */
- if ((nick) && (!Config.AnonymousGlobal)) {
- snprintf(dmsg, sizeof(dmsg), "[%s] %s", nick, msg);
- server_global(servlist, dmsg);
- } else {
- server_global(servlist, msg);
+ if (nick && !Config.AnonymousGlobal)
+ {
+ std::string rmsg = std::string("[") + nick + std::string("] ") + msg;
+ server_global(Me->GetUplink(), rmsg.c_str());
}
+ else
+ server_global(Me->GetUplink(), msg);
}
/**************************************************************************/
-
-/************************************************************************/
-/*************************************************************************/
-
/* Adds an AKILL to the list. Returns >= 0 on success, -1 if it fails, -2
* if only the expiry time was changed.
* The success result is the number of AKILLs that were deleted to successfully add one.
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 2188e86ba..761df1ca1 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -153,12 +153,12 @@ void IRCDProto::SendPrivmsg(BotInfo *bi, const char *dest, const char *fmt, ...)
void IRCDProto::SendGlobalNotice(BotInfo *bi, Server *dest, const char *msg)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "NOTICE %s%s :%s", ircd->globaltldprefix, dest->name, msg);
+ send_cmd(ircd->ts6 ? bi->uid : bi->nick, "NOTICE %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg);
}
void IRCDProto::SendGlobalPrivmsg(BotInfo *bi, Server *dest, const char *msg)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "PRIVMSG %s%s :%s", ircd->globaltldprefix, dest->name, msg);
+ send_cmd(ircd->ts6 ? bi->uid : bi->nick, "PRIVMSG %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg);
}
void IRCDProto::SendQuit(const char *nick, const char *)
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c
index 1e38a4aa2..d84d3f25a 100644
--- a/src/protocol/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -273,15 +273,15 @@ class BahamutIRCdProto : public IRCDProto
/* SERVER */
void SendServer(Server *server)
{
- send_cmd(NULL, "SERVER %s %d :%s", server->name, server->hops, server->desc);
+ send_cmd(NULL, "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
}
void SendConnect()
{
+ Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, "");
bahamut_cmd_pass(uplink_server->password);
bahamut_cmd_capab();
- me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, "");
- SendServer(me_server);
+ SendServer(Me);
bahamut_cmd_svinfo();
bahamut_cmd_burst();
}
@@ -575,11 +575,7 @@ int anope_event_436(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")) {
- uplink = sstrdup(av[0]);
- }
-
- do_server(source, av[0], av[1], av[2], "");
+ do_server(source, av[0], atoi(av[1]), av[2], "");
return MOD_CONT;
}
@@ -711,8 +707,8 @@ int anope_event_error(const char *source, int ac, const char **av)
int anope_event_burst(const char *source, int ac, const char **av)
{
- Server *s;
- s = findserver(servlist, source);
+ Server *s = Server::Find(source ? source : "");
+
if (!ac) {
/* for future use - start burst */
} else {
@@ -720,9 +716,10 @@ int anope_event_burst(const char *source, int ac, const char **av)
* finished bursting. If there was no source, then our uplink
* server finished bursting. -GD
*/
- if (!s && serv_uplink)
- s = serv_uplink;
- finish_sync(s, 1);
+ if (!s)
+ s = Me->GetUplink();
+ if (s)
+ s->Sync(true);
}
return MOD_CONT;
}
diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c
index b5c55cfa8..764b887de 100644
--- a/src/protocol/inspircd11.c
+++ b/src/protocol/inspircd11.c
@@ -204,7 +204,7 @@ class InspIRCdProto : public IRCDProto
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(Server *server)
{
- send_cmd(Config.ServerName, "SERVER %s %s %d :%s", server->name, currentpass, server->hops, server->desc);
+ send_cmd(Config.ServerName, "SERVER %s %s %d :%s", server->GetName().c_str(), currentpass, server->GetHops(), server->GetDescription().c_str());
}
/* JOIN */
@@ -248,9 +248,9 @@ class InspIRCdProto : public IRCDProto
void SendConnect()
{
+ Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, "");
inspircd_cmd_pass(uplink_server->password);
- me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, "");
- SendServer(me_server);
+ SendServer(Me);
send_cmd(NULL, "BURST");
send_cmd(Config.ServerName, "VERSION :Anope-%s %s :%s - %s (%s) -- %s", version_number, Config.ServerName, ircd->name, version_flags, Config.EncModuleList.begin()->c_str(), version_build);
}
@@ -823,10 +823,7 @@ int anope_event_chghost(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")) {
- uplink = sstrdup(av[0]);
- }
- do_server(source, av[0], av[1], av[2], "");
+ do_server(source, av[0], atoi(av[1]), av[2], "");
return MOD_CONT;
}
@@ -1100,7 +1097,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
int anope_event_endburst(const char *source, int ac, const char **av)
{
- finish_sync(serv_uplink, 1);
+ Me->GetUplink()->Sync(true);
return MOD_CONT;
}
diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp
index 4ad390f00..5ff9db94b 100644
--- a/src/protocol/inspircd12.cpp
+++ b/src/protocol/inspircd12.cpp
@@ -209,7 +209,7 @@ class InspIRCdProto : public IRCDProto
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(Server *server)
{
- send_cmd(NULL, "SERVER %s %s %d %s :%s", server->name, currentpass, server->hops, server->suid, server->desc);
+ send_cmd(NULL, "SERVER %s %s %d %s :%s", server->GetName().c_str(), currentpass, server->GetHops(), server->GetSID().c_str(), server->GetDescription().c_str());
}
/* JOIN */
@@ -252,9 +252,9 @@ class InspIRCdProto : public IRCDProto
void SendConnect()
{
+ Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, TS6SID);
inspircd_cmd_pass(uplink_server->password);
- me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, TS6SID);
- SendServer(me_server);
+ SendServer(Me);
send_cmd(TS6SID, "BURST");
send_cmd(TS6SID, "VERSION :Anope-%s %s :%s - %s (%s) -- %s", version_number, Config.ServerName, ircd->name, version_flags, Config.EncModuleList.begin()->c_str(), version_build);
}
@@ -837,7 +837,7 @@ int anope_event_uid(const char *source, int ac, const char **av)
User *user;
NickAlias *na;
struct in_addr addy;
- Server *s = findserver_uid(servlist, source);
+ Server *s = Server::Find(source ? source : "");
uint32 *ad = reinterpret_cast<uint32 *>(&addy);
int ts = strtoul(av[1], NULL, 10);
@@ -846,7 +846,7 @@ int anope_event_uid(const char *source, int ac, const char **av)
user = prev_u_intro;
prev_u_intro = NULL;
if (user) na = findnick(user->nick);
- if (user && user->server->sync == SSYNC_IN_PROGRESS && (!na || na->nc != user->Account()))
+ if (user && !user->server->IsSynced() && (!na || na->nc != user->Account()))
{
validate_user(user);
if (user->HasMode(UMODE_REGISTERED))
@@ -858,14 +858,14 @@ int anope_event_uid(const char *source, int ac, const char **av)
user = do_nick("", av[2], /* nick */
av[5], /* username */
av[3], /* realhost */
- s->name, /* server */
+ s->GetName().c_str(), /* server */
av[ac - 1], /* realname */
ts, htonl(*ad), av[4], av[0]);
if (user)
{
UserSetInternalModes(user, 1, &av[8]);
user->SetCloakedHost(av[4]);
- if (user->server->sync == SSYNC_IN_PROGRESS)
+ if (!user->server->IsSynced())
{
prev_u_intro = user;
}
@@ -903,11 +903,7 @@ int anope_event_chghost(const char *source, int ac, const char **av)
*/
int anope_event_server(const char *source, int ac, const char **av)
{
- if (!stricmp(av[2], "0"))
- {
- uplink = sstrdup(av[0]);
- }
- do_server(source, av[0], av[2], av[4], av[3]);
+ do_server(source, av[0], atoi(av[2]), av[4], av[3]);
return MOD_CONT;
}
@@ -1308,7 +1304,8 @@ int anope_event_endburst(const char *source, int ac, const char **av)
{
NickAlias *na;
User *u = prev_u_intro;
- Server *s = findserver_uid(servlist, source);
+ Server *s = Server::Find(source ? source : "");
+
if (!s)
{
throw new CoreException("Got ENDBURST without a source");
@@ -1318,16 +1315,16 @@ int anope_event_endburst(const char *source, int ac, const char **av)
* If not, validate the user. ~ Viper*/
prev_u_intro = NULL;
if (u) na = findnick(u->nick);
- if (u && u->server->sync == SSYNC_IN_PROGRESS && (!na || na->nc != u->Account()))
+ if (u && !u->server->IsSynced() && (!na || na->nc != u->Account()))
{
validate_user(u);
if (u->HasMode(UMODE_REGISTERED))
u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
}
- Alog() << "Processed ENDBURST for " << s->name;
+ Alog() << "Processed ENDBURST for " << s->GetName();
- finish_sync(s, 1);
+ s->Sync(true);
return MOD_CONT;
}
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index 8d0a84826..ace2a650c 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -14,6 +14,8 @@
#include "services.h"
#include "pseudo.h"
+static char *TS6UPLINK = NULL; // XXX is this needed?
+
IRCDVar myIrcd[] = {
{"Ratbox 2.0+", /* ircd name */
"+oi", /* Modes used by pseudoclients */
@@ -190,16 +192,16 @@ class RatboxProto : public IRCDTS6Proto
/* SERVER name hop descript */
void SendServer(Server *server)
{
- send_cmd(NULL, "SERVER %s %d :%s", server->name, server->hops, server->desc);
+ send_cmd(NULL, "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
}
void SendConnect()
{
+ Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, TS6SID);
ratbox_cmd_pass(uplink_server->password);
ratbox_cmd_capab();
/* Make myself known to myself in the serverlist */
- me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, TS6SID);
- SendServer(me_server);
+ SendServer(Me);
ratbox_cmd_svinfo();
}
@@ -457,14 +459,13 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
*/
int anope_event_nick(const char *source, int ac, const char **av)
{
- Server *s;
User *user;
if (ac == 9)
{
- s = findserver_uid(servlist, source);
+ Server *s = Server::Find(source ? source : "");
/* Source is always the server */
- user = do_nick("", av[0], av[4], av[5], s->name, av[8],
+ 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)
{
@@ -681,27 +682,24 @@ int anope_event_whois(const char *source, int ac, const char **av)
int anope_event_server(const char *source, int ac, const char **av)
{
if (!stricmp(av[1], "1")) {
- uplink = sstrdup(av[0]);
if (TS6UPLINK) {
- do_server(source, av[0], av[1], av[2], TS6UPLINK);
+ do_server(source, av[0], atoi(av[1]), av[2], TS6UPLINK);
} else {
- do_server(source, av[0], av[1], av[2], "");
+ do_server(source, av[0], atoi(av[1]), av[2], "");
}
} else {
- do_server(source, av[0], av[1], av[2], "");
+ do_server(source, av[0], atoi(av[1]), av[2], "");
}
return MOD_CONT;
}
int anope_event_sid(const char *source, int ac, const char **av)
{
- Server *s;
-
/* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */
- s = findserver_uid(servlist, source);
+ Server *s = Server::Find(source);
- do_server(s->name, av[0], av[1], av[3], av[2]);
+ do_server(s->GetName(), av[0], atoi(av[1]), av[3], av[2]);
return MOD_CONT;
}
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index 3564fecd6..aeb35ee88 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -216,9 +216,9 @@ class UnrealIRCdProto : public IRCDProto
void SendServer(Server *server)
{
if (Config.Numeric)
- send_cmd(NULL, "SERVER %s %d :U0-*-%s %s", server->name, server->hops, Config.Numeric, server->desc);
+ send_cmd(NULL, "SERVER %s %d :U0-*-%s %s", server->GetName().c_str(), server->GetHops(), Config.Numeric, server->GetDescription().c_str());
else
- send_cmd(NULL, "SERVER %s %d :%s", server->name, server->hops, server->desc);
+ send_cmd(NULL, "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
}
/* JOIN */
@@ -286,10 +286,10 @@ class UnrealIRCdProto : public IRCDProto
void SendConnect()
{
+ Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, (Config.Numeric ? Config.Numeric : ""));
unreal_cmd_capab();
unreal_cmd_pass(uplink_server->password);
- me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, (Config.Numeric ? Config.Numeric : ""));
- SendServer(me_server);
+ SendServer(Me);
}
/* SVSHOLD - set */
@@ -701,7 +701,7 @@ int anope_event_mode(const char *source, int ac, const char **av)
/* This is used to strip the TS from the end of the mode stirng */
int anope_event_gmode(const char *source, int ac, const char **av)
{
- if (findserver(servlist, source))
+ if (Server::Find(source))
--ac;
return anope_event_mode(source, ac, av);
}
@@ -966,16 +966,15 @@ int anope_event_server(const char *source, int ac, const char **av)
char *upnumeric;
if (!stricmp(av[1], "1")) {
- uplink = sstrdup(av[0]);
vl = myStrGetToken(av[2], ' ', 0);
upnumeric = myStrGetToken(vl, '-', 2);
desc = myStrGetTokenRemainder(av[2], ' ', 1);
- do_server(source, av[0], av[1], desc, upnumeric);
+ do_server(source, av[0], atoi(av[1]), desc, upnumeric);
delete [] vl;
delete [] desc;
delete [] upnumeric;
} else {
- do_server(source, av[0], av[1], av[2], "");
+ do_server(source, av[0], atoi(av[1]), av[2], "");
}
ircdproto->SendPing(Con