diff options
author | Peter Powell <petpow@saberuk.com> | 2019-09-23 11:49:26 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-09-23 13:18:14 +0100 |
commit | a4305d8f3c3e613be839bdcd61a1d14c87fed5aa (patch) | |
tree | 16e01b6079f017c00d2bda2da0fcb759b98a5ea1 /src | |
parent | b64177d3fb4f113c4db3325575970964867f01cc (diff) |
Add the server id to the Server class.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_spanningtree/commandbuilder.h | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/compat.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/num.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_map.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/pingtimer.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/postcommand.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/server.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 36 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/uid.cpp | 2 |
12 files changed, 38 insertions, 29 deletions
diff --git a/src/modules/m_spanningtree/commandbuilder.h b/src/modules/m_spanningtree/commandbuilder.h index f6cca9917..6374582c6 100644 --- a/src/modules/m_spanningtree/commandbuilder.h +++ b/src/modules/m_spanningtree/commandbuilder.h @@ -58,7 +58,7 @@ class CmdBuilder : content(1, ':') , tagsize(0) { - content.append(src->GetID()); + content.append(src->GetId()); push(cmd); FireEvent(src, cmd, tags); } diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index 0d50b4325..270aad954 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -381,7 +381,7 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, Comm return false; } - params[0] = server->GetID(); + params[0] = server->GetId(); } } else if ((cmd == "GLINE") || (cmd == "KLINE") || (cmd == "ELINE") || (cmd == "ZLINE") || (cmd == "QLINE")) @@ -564,7 +564,7 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, Comm // Second parameter becomes the target uuid params[0].swap(params[1]); // Replace first param (now the PUSH payload, not needed) with the source sid - params[0] = numericsource->GetID(); + params[0] = numericsource->GetId(); params.push_back(InspIRCd::Format("%03u", numeric_number)); diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 43417bc3c..2848ce940 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -804,7 +804,7 @@ ModuleSpanningTree::~ModuleSpanningTree() { ServerInstance->PI = &ServerInstance->DefaultProtocolInterface; - Server* newsrv = new Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); + Server* newsrv = new Server(ServerInstance->Config->GetSID(), ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); SetLocalUsersServer(newsrv); delete Utils; diff --git a/src/modules/m_spanningtree/num.cpp b/src/modules/m_spanningtree/num.cpp index 564b808fd..23290421b 100644 --- a/src/modules/m_spanningtree/num.cpp +++ b/src/modules/m_spanningtree/num.cpp @@ -51,7 +51,7 @@ CommandNum::Builder::Builder(SpanningTree::RemoteUser* target, const Numeric::Nu : CmdBuilder("NUM") { TreeServer* const server = (numeric.GetServer() ? (static_cast<TreeServer*>(numeric.GetServer())) : Utils->TreeRoot); - push(server->GetID()).push(target->uuid).push(InspIRCd::Format("%03u", numeric.GetNumeric())); + push(server->GetId()).push(target->uuid).push(InspIRCd::Format("%03u", numeric.GetNumeric())); const CommandBase::Params& params = numeric.GetParams(); if (!params.empty()) { diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index 735bc7148..2f22f89a4 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -76,7 +76,7 @@ static std::vector<std::string> GetMap(User* user, TreeServer* current, unsigned std::string buffer = current->GetName(); if (user->IsOper()) { - buffer += " (" + current->GetID(); + buffer += " (" + current->GetId(); const std::string& cur_vers = current->GetRawVersion(); if (!cur_vers.empty()) diff --git a/src/modules/m_spanningtree/pingtimer.cpp b/src/modules/m_spanningtree/pingtimer.cpp index 1c96259bf..baa799d00 100644 --- a/src/modules/m_spanningtree/pingtimer.cpp +++ b/src/modules/m_spanningtree/pingtimer.cpp @@ -36,7 +36,7 @@ PingTimer::State PingTimer::TickInternal() if (state == PS_SENDPING) { // Last ping was answered, send next ping - server->GetSocket()->WriteLine(CmdBuilder("PING").push(server->GetID())); + server->GetSocket()->WriteLine(CmdBuilder("PING").push(server->GetId())); LastPingMsec = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000); // Warn next unless warnings are disabled. If they are, jump straight to timeout. if (Utils->PingWarnTime) diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index 10cbbce82..ed962653e 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -64,7 +64,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm if (encap) { - params.push(sdest->GetID()); + params.push(sdest->GetId()); params.push(command); } } diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index 9fe93a389..28b2c8f16 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -65,7 +65,7 @@ bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targ return false; // Use the SID of the target in the message instead of the server name - encap.push(server->GetID()).push(cmd).insert(params).Unicast(server->ServerUser); + encap.push(server->GetId()).push(cmd).insert(params).Unicast(server->ServerUser); } return true; diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index 92ba69eda..41ea365e0 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -188,8 +188,8 @@ bool TreeSocket::CheckDuplicate(const std::string& sname, const std::string& sid if (CheckDupe) { - this->SendError("Server ID "+CheckDupe->GetID()+" already exists on server "+CheckDupe->GetName()+"! You may want to specify the server ID for the server manually with <server:id> so they do not conflict."); - ServerInstance->SNO->WriteToSnoMask('l', "Server connection from \002"+sname+"\002 denied, server ID '"+CheckDupe->GetID()+ + this->SendError("Server ID "+CheckDupe->GetId()+" already exists on server "+CheckDupe->GetName()+"! You may want to specify the server ID for the server manually with <server:id> so they do not conflict."); + ServerInstance->SNO->WriteToSnoMask('l', "Server connection from \002"+sname+"\002 denied, server ID '"+CheckDupe->GetId()+ "' already exists on server "+CheckDupe->GetName()); return false; } @@ -228,7 +228,7 @@ CommandServer::Builder::Builder(TreeServer* server) : CmdBuilder(server->GetParent(), "SERVER") { push(server->GetName()); - push(server->GetID()); + push(server->GetId()); if (server->IsBursting()) push_property("burst", ConvToStr(server->StartBurst)); push_property("hidden", ConvToStr(server->Hidden)); diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 952899962..2b143269c 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -32,16 +32,22 @@ * no socket associated with it. Its version string is our own local version. */ TreeServer::TreeServer() - : Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc) + : Server(ServerInstance->Config->GetSID(), ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc) , Parent(NULL), Route(NULL) , VersionString(ServerInstance->GetVersionString()) , fullversion(ServerInstance->GetVersionString(true)) , rawversion(INSPIRCD_VERSION) - , Socket(NULL), sid(ServerInstance->Config->GetSID()), behind_bursting(0), isdead(false) + , Socket(NULL) + , behind_bursting(0) + , isdead(false) , pingtimer(this) , ServerUser(ServerInstance->FakeClient) - , age(ServerInstance->Time()), UserCount(ServerInstance->Users.LocalUserCount()) - , OperCount(0), rtt(0), StartBurst(0), Hidden(false) + , age(ServerInstance->Time()) + , UserCount(ServerInstance->Users.LocalUserCount()) + , OperCount(0) + , rtt(0) + , StartBurst(0) + , Hidden(false) { AddHashEntry(); } @@ -51,11 +57,19 @@ TreeServer::TreeServer() * the ping timer for the server. */ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide) - : Server(Name, Desc) - , Parent(Above), Socket(Sock), sid(id), behind_bursting(Parent->behind_bursting), isdead(false) + : Server(id, Name, Desc) + , Parent(Above) + , Socket(Sock) + , behind_bursting(Parent->behind_bursting) + , isdead(false) , pingtimer(this) , ServerUser(new FakeUser(id, this)) - , age(ServerInstance->Time()), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(Hide) + , age(ServerInstance->Time()) + , UserCount(0) + , OperCount(0) + , rtt(0) + , StartBurst(0) + , Hidden(Hide) { ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "New server %s behind_bursting %u", GetName().c_str(), behind_bursting); CheckULine(); @@ -128,7 +142,7 @@ void TreeServer::BeginBurst(uint64_t startms) if ((!startms) || (startms > now)) startms = now; this->StartBurst = startms; - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %s behind_bursting %u", sid.c_str(), ConvToStr(startms).c_str(), behind_bursting); + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %s behind_bursting %u", GetId().c_str(), ConvToStr(startms).c_str(), behind_bursting); } void TreeServer::FinishBurstInternal() @@ -166,7 +180,7 @@ void TreeServer::SQuitChild(TreeServer* server, const std::string& reason) { // Server split from us, generate a SQUIT message and broadcast it ServerInstance->SNO->WriteGlobalSno('l', "Server \002" + server->GetName() + "\002 split: " + reason); - CmdBuilder("SQUIT").push(server->GetID()).push_last(reason).Broadcast(); + CmdBuilder("SQUIT").push(server->GetId()).push_last(reason).Broadcast(); } else { @@ -258,7 +272,7 @@ void TreeServer::CheckULine() void TreeServer::AddHashEntry() { Utils->serverlist[GetName()] = this; - Utils->sidlist[sid] = this; + Utils->sidlist[GetId()] = this; } CullResult TreeServer::cull() @@ -288,6 +302,6 @@ TreeServer::~TreeServer() void TreeServer::RemoveHash() { - Utils->sidlist.erase(sid); + Utils->sidlist.erase(GetId()); Utils->serverlist.erase(GetName()); } diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index ffe0373d2..90841d0b4 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -51,7 +51,6 @@ class TreeServer : public Server std::string rawversion; TreeSocket* Socket; /* Socket used to communicate with this server */ - std::string sid; /* Server ID */ /** Counter counting how many servers are bursting in front of this server, including * this server. Set to parents' value on construction then it is increased if the @@ -194,10 +193,6 @@ class TreeServer : public Server */ const ChildServers& GetChildren() const { return Children; } - /** Get server ID - */ - const std::string& GetID() const { return sid; } - /** Marks a server as having finished bursting and performs appropriate actions. */ void FinishBurst(); diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index bf99fb445..3ce7c904b 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -38,7 +38,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params const std::string& modestr = params[8]; // Check if the length of the uuid is correct and confirm the sid portion of the uuid matches the sid of the server introducing the user - if (params[0].length() != UIDGenerator::UUID_LENGTH || params[0].compare(0, 3, remoteserver->GetID())) + if (params[0].length() != UIDGenerator::UUID_LENGTH || params[0].compare(0, 3, remoteserver->GetId())) throw ProtocolException("Bogus UUID"); // Sanity check on mode string: must begin with '+' if (modestr[0] != '+') |