summaryrefslogtreecommitdiff
path: root/src/core
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/core
parent73e93305c10f349742fad3b2197c6c5dd3aea34e (diff)
Rewrote all of the server handling code
Diffstat (limited to 'src/core')
-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
6 files changed, 24 insertions, 21 deletions
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;
}