summaryrefslogtreecommitdiff
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
parent73e93305c10f349742fad3b2197c6c5dd3aea34e (diff)
Rewrote all of the server handling code
-rw-r--r--include/extern.h36
-rw-r--r--include/modules.h9
-rw-r--r--include/servers.h179
-rw-r--r--include/services.h93
-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
27 files changed, 890 insertions, 987 deletions
diff --git a/include/extern.h b/include/extern.h
index 5ede04dc8..79f1702f9 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -23,8 +23,6 @@
E void ModuleRunTimeDirCleanUp();
-E char *uplink;
-
/* IRC Variables */
E IRCDVar *ircd;
@@ -423,7 +421,7 @@ E int add_szline(User * u, const char *mask, const char *by,
E void expire_szlines();
E int check_szline(const char *nick, char *ip);
-E Server *server_global(Server * s, char *msg);
+E void server_global(Server *s, const std::string &message);
E std::vector<NewsItem *> News;
@@ -459,37 +457,6 @@ E void notice_lang(const std::string &source, User *dest, int message, ...); //
E void notice_help(const char *source, User *dest, int message, ...); // MARK_DEPRECATED;
-/**** servers.c ****/
-
-E Server *servlist;
-E Server *me_server;
-E Server *serv_uplink;
-E Flags<CapabType> Capab;
-E CapabInfo Capab_Info[];
-
-E Server *first_server(ServerFlag flag);
-E Server *next_server(ServerFlag flag);
-
-E void CapabParse(int ac, const char **av);
-E int is_ulined(const char *server);
-E int is_sync(Server *server);
-
-E Server *new_server(Server * uplink, const char *name, const char *desc, ServerFlag flag, const std::string &suid);
-
-E Server *findserver(Server *s, const char *name);
-
-E void do_server(const char *source, const char *servername, const char *hops, const char *descript, const std::string &numeric);
-E void do_squit(const char *source, int ac, const char **av);
-E int anope_check_sync(const char *name);
-
-E void finish_sync(Server *serv, int sync_links);
-
-E void ts6_uid_init();
-E void ts6_uid_increment(unsigned int slot);
-E const char *ts6_uid_retrieve();
-
-E const char *ts6_sid_retrieve();
-
/**** sessions.c ****/
E Exception *exceptions;
@@ -550,7 +517,6 @@ E User *first_uid();
E User *next_uid();
E Server *findserver_uid(Server * s, const char *name);
E char *TS6SID;
-E char *TS6UPLINK;
E User *do_nick(const char *source, const char *nick, const char *username, const char *host,
const char *server, const char *realname, time_t ts, uint32 ip, const char *vhost, const char *uid);
diff --git a/include/modules.h b/include/modules.h
index dcaac342c..afc6806d1 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -585,9 +585,9 @@ class CoreExport Module
*/
virtual void OnServerConnect() { }
- /** Called when we are done synching with the uplink, just before we send the EOB
+ /** Called when we are almost done synching with the uplink, just before we send the EOB
*/
- virtual void OnFinishSync(Server *serv) { }
+ virtual void OnPreUplinkSync(Server *serv) { }
/** Called when Anope disconnects from its uplink, before it tries to reconnect
*/
@@ -1060,8 +1060,9 @@ class CoreExport Module
virtual void OnServerSync(Server *s) { }
/** Called when we sync with our uplink
+ * @param s Our uplink
*/
- virtual void OnUplinkSync() { }
+ virtual void OnUplinkSync(Server *s) { }
};
@@ -1109,7 +1110,7 @@ enum Implementation
I_OnModuleLoad, I_OnModuleUnload,
/* Other */
- I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnFinishSync, I_OnServerDisconnect, I_OnPreCommandRun,
+ I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, I_OnPreCommandRun,
I_OnPreCommand, I_OnPostCommand, I_OnPreDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal,
I_OnServerQuit, I_OnTopicUpdated,
I_OnEncrypt, I_OnEncryptInPlace, I_OnEncryptCheckLen, I_OnDecrypt, I_OnCheckPassword,
diff --git a/include/servers.h b/include/servers.h
new file mode 100644
index 000000000..f6a5933ed
--- /dev/null
+++ b/include/servers.h
@@ -0,0 +1,179 @@
+/* Anope */
+extern CoreExport Server *Me;
+
+extern CoreExport void CapabParse(int ac, const char **av);
+
+extern CoreExport void do_server(const std::string &source, const std::string &servername, unsigned int hops, const std::string &descript, const std::string &numeric);
+extern CoreExport void do_squit(const char *source, int ac, const char **av);
+
+extern CoreExport const char *ts6_uid_retrieve();
+extern CoreExport const char *ts6_sid_retrieve();
+
+/* Types of capab
+ */
+enum CapabType
+{
+ CAPAB_BEGIN,
+
+ CAPAB_NOQUIT,
+ CAPAB_TSMODE,
+ CAPAB_UNCONNECT,
+ CAPAB_NICKIP,
+ CAPAB_NSJOIN,
+ CAPAB_ZIP,
+ CAPAB_BURST,
+ CAPAB_TS3,
+ CAPAB_TS5,
+ CAPAB_DKEY,
+ CAPAB_DOZIP,
+ CAPAB_DODKEY,
+ CAPAB_QS,
+ CAPAB_SCS,
+ CAPAB_PT4,
+ CAPAB_UID,
+ CAPAB_KNOCK,
+ CAPAB_CLIENT,
+ CAPAB_IPV6,
+ CAPAB_SSJ5,
+ CAPAB_SN2,
+ CAPAB_VHOST,
+ CAPAB_TOKEN,
+ CAPAB_SSJ3,
+ CAPAB_NICK2,
+ CAPAB_VL,
+ CAPAB_TLKEXT,
+ CAPAB_CHANMODE,
+ CAPAB_SJB64,
+ CAPAB_NICKCHARS,
+
+ CAPAB_END
+};
+
+/* CAPAB stuffs */
+struct CapabInfo
+{
+ std::string Token;
+ CapabType Flag;
+};
+
+extern CoreExport Flags<CapabType> Capab;
+extern CoreExport CapabInfo Capab_Info[];
+
+/** Flags set on servers
+ */
+enum ServerFlag
+{
+ /* Server is syncing */
+ SERVER_SYNCING,
+ /* This server was juped */
+ SERVER_JUPED
+};
+
+/** Class representing a server
+ */
+class Server : public Flags<ServerFlag>
+{
+ private:
+ /* Server name */
+ std::string Name;
+ /* Hops between services and server */
+ unsigned int Hops;
+ /* Server description */
+ std::string Description;
+ /* Server ID */
+ std::string SID;
+ /* Links for this server */
+ std::list<Server *>* Links;
+ /* Uplink for this server */
+ Server *UplinkServer;
+
+ /* Reason this server was quit */
+ std::string QReason;
+
+ public:
+ /** Constructor
+ * @param uplink The uplink this server is from, is only NULL when creating Me
+ * @param name The server name
+ * @param hops Hops from services server
+ * @param description Server rdescription
+ * @param sid Server sid/numeric
+ */
+ Server(Server *uplink, const std::string &name, unsigned int hops, const std::string &description, const std::string &sid);
+
+ /** Destructor
+ */
+ ~Server();
+
+ /** Delete this server with a reason
+ * @param reason The reason
+ */
+ void Delete(const std::string &reason);
+
+ /** Get the name for this server
+ * @return The name
+ */
+ const std::string& GetName() const;
+
+ /** Get the number of hops this server is from services
+ * @return Number of hops
+ */
+ unsigned int GetHops() const;
+
+ /** Set the server description
+ * @param desc The new description
+ */
+ void SetDescription(const std::string& desc);
+
+ /** Get the server description
+ * @return The server description
+ */
+ const std::string& GetDescription() const;
+
+ /** Get the server numeric/SID
+ * @return The numeric/SID
+ */
+ const std::string& GetSID() const;
+
+ /** Get the list of links this server has, or NULL if it has none
+ * @return A list of servers
+ */
+ const std::list<Server*>* GetLinks() const;
+
+ /** Get the uplink server for this server, if this is our uplink will be Me
+ * @return The servers uplink
+ */
+ Server* GetUplink() const;
+
+ /** Adds a link to this server
+ * @param s The linking server
+ */
+ void AddLink(Server *s);
+
+ /** Delinks a server from this server
+ * @param s The server
+ */
+ void DelLink(Server *s);
+
+ /** Finish syncing this server and optionally all links to it
+ * @param SyncLinks True to sync the links for this server too (if any)
+ */
+ void Sync(bool SyncLinks);
+
+ /** Check if this server is synced
+ * @return true or false
+ */
+ bool IsSynced() const;
+
+ /** Check if this server is ULined
+ * @return true or false
+ */
+ bool IsULined() const;
+
+ /** Find a server
+ * @param name The name or SID/numeric
+ * @param s The server list to search for this server on, defaults to our Uplink
+ * @return The server
+ */
+ static Server* Find(const std::string &name, Server *s = NULL);
+};
+
diff --git a/include/services.h b/include/services.h
index 2741e0178..4dd35a751 100644
--- a/include/services.h
+++ b/include/services.h
@@ -348,6 +348,7 @@ template<typename T> class Flags
class User;
class ChannelInfo;
class Channel;
+class Server;
struct EList;
typedef struct bandata_ BanData;
@@ -677,48 +678,7 @@ typedef struct {
/*************************************************************************/
-/* Server data */
-
-typedef enum {
- SSYNC_IN_PROGRESS = 0, /* Sync is currently in progress */
- SSYNC_DONE = 1 /* We're in sync */
-} SyncState;
-
-/** Flags set on servers
- */
-enum ServerFlag
-{
- SERVER_START,
-
- /* This server is me */
- SERVER_ISME,
- /* This server was juped */
- SERVER_JUPED,
- /* This server is the current uplink */
- SERVER_ISUPLINK,
-
- SERVER_END
-};
-
-class Server : public Flags<ServerFlag>
-{
- public:
- Server *next, *prev;
-
- char *name; /* Server name */
- uint16 hops; /* Hops between services and server */
- char *desc; /* Server description */
- char *suid; /* Server Univeral ID */
- SyncState sync; /* Server sync state (see above) */
-
- Server *links; /* Linked list head for linked servers */
- Server *uplink; /* Server which pretends to be the uplink */
-};
-
-/*************************************************************************/
-
#include "users.h"
-
/* This structure stocks ban data since it must not be removed when
* user is kicked.
*/
@@ -920,55 +880,6 @@ enum DefconLevel
/*************************************************************************/
-/* Types of capab
- */
-enum CapabType
-{
- CAPAB_BEGIN,
-
- CAPAB_NOQUIT,
- CAPAB_TSMODE,
- CAPAB_UNCONNECT,
- CAPAB_NICKIP,
- CAPAB_NSJOIN,
- CAPAB_ZIP,
- CAPAB_BURST,
- CAPAB_TS3,
- CAPAB_TS5,
- CAPAB_DKEY,
- CAPAB_DOZIP,
- CAPAB_DODKEY,
- CAPAB_QS,
- CAPAB_SCS,
- CAPAB_PT4,
- CAPAB_UID,
- CAPAB_KNOCK,
- CAPAB_CLIENT,
- CAPAB_IPV6,
- CAPAB_SSJ5,
- CAPAB_SN2,
- CAPAB_VHOST,
- CAPAB_TOKEN,
- CAPAB_SSJ3,
- CAPAB_NICK2,
- CAPAB_VL,
- CAPAB_TLKEXT,
- CAPAB_CHANMODE,
- CAPAB_SJB64,
- CAPAB_NICKCHARS,
-
- CAPAB_END
-};
-
-/* CAPAB stuffs */
-struct CapabInfo
-{
- std::string Token;
- CapabType Flag;
-};
-
-/*************************************************************************/
-
/**
* RFC: defination of a valid nick
* nickname = ( letter / special ) *8( letter / digit / special / "-" )
@@ -986,7 +897,9 @@ struct CapabInfo
class IRCDProto;
struct Uplink;
class ServerConfig;
+
#include "extern.h"
+#include "servers.h"
#include "configreader.h"
class CoreExport IRCDProto
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