diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-07-21 18:18:33 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-07-24 18:12:22 +0200 |
commit | c6b911132caba237f86280d1b2cb32ad3123f0da (patch) | |
tree | 8713ae256f7cdf66865b1b29de3e088376d6a59a | |
parent | d763f0b2eeee0e1c9cade555ce21337a1be629df (diff) |
m_spanningtree Change the type of TreeServer::ServerName to std::string
-rw-r--r-- | src/modules/m_spanningtree/addline.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_map.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 4 |
8 files changed, 17 insertions, 29 deletions
diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp index a43112ce9..020526eb3 100644 --- a/src/modules/m_spanningtree/addline.cpp +++ b/src/modules/m_spanningtree/addline.cpp @@ -30,7 +30,7 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist ¶ms) { if (params.size() < 6) { - std::string servername = MyRoot->GetName(); + const std::string& servername = MyRoot->GetName(); ServerInstance->SNO->WriteToSnoMask('d', "%s sent me a malformed ADDLINE", servername.c_str()); return true; } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index e4bdee879..7cda6a810 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -118,8 +118,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops) else if ((Current->Hidden) && (!user->IsOper())) return; - std::string servername = Current->GetName(); - user->WriteNumeric(364, "%s %s %s :%d %s", user->nick.c_str(), servername.c_str(), + user->WriteNumeric(364, "%s %s %s :%d %s", user->nick.c_str(), Current->GetName().c_str(), (Utils->FlatLinks && (!user->IsOper())) ? ServerInstance->Config->ServerName.c_str() : Parent.c_str(), (Utils->FlatLinks && (!user->IsOper())) ? 0 : hops, Current->GetDesc().c_str()); @@ -215,8 +214,7 @@ restart: if ((Utils->PingWarnTime) && (!s->Warned) && (curtime >= s->NextPingTime() - (Utils->PingFreq - Utils->PingWarnTime)) && (!s->AnsweredLastPing())) { /* The server hasnt responded, send a warning to opers */ - std::string servername = s->GetName(); - ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not responded to PING for %d seconds, high latency.", servername.c_str(), Utils->PingWarnTime); + ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not responded to PING for %d seconds, high latency.", s->GetName().c_str(), Utils->PingWarnTime); s->Warned = true; } } @@ -412,8 +410,7 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para } else { - std::string servername = CheckDupe->GetParent()->GetName(); - RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), servername.c_str()); + RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), CheckDupe->GetParent()->GetName().c_str()); return MOD_RES_DENY; } } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 39056b1fe..aefb9de01 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -34,9 +34,8 @@ */ void TreeSocket::DoBurst(TreeServer* s) { - std::string servername = s->GetName(); ServerInstance->SNO->WriteToSnoMask('l',"Bursting to \2%s\2 (Authentication: %s%s).", - servername.c_str(), + s->GetName().c_str(), capab->auth_fingerprint ? "SSL Fingerprint and " : "", capab->auth_challenge ? "challenge-response" : "plaintext password"); this->CleanNegotiationInfo(); diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index 72128a1c3..5dcb6f7cf 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -55,14 +55,13 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, int memset(myname, ' ', depth); int w = depth; - std::string servername = Current->GetName(); if (user->IsOper()) { - w += snprintf(myname + depth, 99 - depth, "%s (%s)", servername.c_str(), Current->GetID().c_str()); + w += snprintf(myname + depth, 99 - depth, "%s (%s)", Current->GetName().c_str(), Current->GetID().c_str()); } else { - w += snprintf(myname + depth, 99 - depth, "%s", servername.c_str()); + w += snprintf(myname + depth, 99 - depth, "%s", Current->GetName().c_str()); } memset(myname + w, ' ', 100 - w); if (w > maxnamew) diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 393485cce..7b745410d 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -35,7 +35,7 @@ * no socket associated with it. Its version string is our own local version. */ TreeServer::TreeServer(SpanningTreeUtilities* Util) - : Parent(NULL), Route(NULL), ServerName(ServerInstance->Config->ServerName.c_str()), ServerDesc(ServerInstance->Config->ServerDesc) + : Parent(NULL), Route(NULL), ServerName(ServerInstance->Config->ServerName), ServerDesc(ServerInstance->Config->ServerDesc) , VersionString(ServerInstance->GetVersionString()), Socket(NULL), Utils(Util), sid(ServerInstance->Config->GetSID()), ServerUser(ServerInstance->FakeClient) , age(ServerInstance->Time()), Warned(false), bursting(false), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(false) { @@ -47,7 +47,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util) * its ping counters so that it will be pinged one minute from now. */ TreeServer::TreeServer(SpanningTreeUtilities* Util, const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide) - : Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), sid(id), ServerUser(new FakeUser(id, Name)) + : Parent(Above), ServerName(Name), ServerDesc(Desc), Socket(Sock), Utils(Util), sid(id), ServerUser(new FakeUser(id, Name)) , age(ServerInstance->Time()), Warned(false), bursting(true), UserCount(0), OperCount(0), rtt(0), Hidden(Hide) { SetNextPingTime(ServerInstance->Time() + Utils->PingFreq); @@ -136,7 +136,7 @@ void TreeServer::FinishBurst() unsigned long bursttime = ts - this->StartBurst; ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)", ServerName.c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs")); - AddServerEvent(Utils->Creator, ServerName.c_str()); + AddServerEvent(Utils->Creator, ServerName); } int TreeServer::QuitUsers(const std::string &reason) @@ -173,7 +173,7 @@ int TreeServer::QuitUsers(const std::string &reason) */ void TreeServer::AddHashEntry() { - Utils->serverlist[ServerName.c_str()] = this; + Utils->serverlist[ServerName] = this; Utils->sidlist[sid] = this; } @@ -185,11 +185,6 @@ TreeServer* TreeServer::GetRoute() return Route; } -std::string TreeServer::GetName() -{ - return ServerName.c_str(); -} - const std::string& TreeServer::GetDesc() { return ServerDesc; @@ -307,5 +302,5 @@ TreeServer::~TreeServer() delete ServerUser; Utils->sidlist.erase(sid); - Utils->serverlist.erase(ServerName.c_str()); + Utils->serverlist.erase(ServerName); } diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 26cc0e424..a579d2fc7 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -42,7 +42,7 @@ class TreeServer : public classbase TreeServer* Parent; /* Parent entry */ TreeServer* Route; /* Route entry */ std::vector<TreeServer*> Children; /* List of child objects */ - irc::string ServerName; /* Server's name */ + std::string ServerName; /* Server's name */ std::string ServerDesc; /* Server's description */ std::string VersionString; /* Version string or empty string */ TreeSocket* Socket; /* For directly connected servers this points at the socket object */ @@ -88,7 +88,7 @@ class TreeServer : public classbase /** Get server name */ - std::string GetName(); + const std::string& GetName() const { return ServerName; } /** Get server description (GECOS) */ diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 719c31bce..739b50dba 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -143,9 +143,7 @@ void TreeSocket::SendError(const std::string &errormessage) */ void TreeSocket::SquitServer(std::string &from, TreeServer* Current, int& num_lost_servers, int& num_lost_users) { - std::string servername = Current->GetName(); - ServerInstance->Logs->Log("m_spanningtree", LOG_DEBUG, "SquitServer for %s from %s", - servername.c_str(), from.c_str()); + ServerInstance->Logs->Log("m_spanningtree", LOG_DEBUG, "SquitServer for %s from %s", Current->GetName().c_str(), from.c_str()); /* recursively squit the servers attached to 'Current'. * We're going backwards so we don't remove users * while we still need them ;) diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index f527de56e..bbaa9bb60 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -60,7 +60,7 @@ TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName) if (InspIRCd::IsSID(ServerName)) return this->FindServerID(ServerName); - server_hash::iterator iter = serverlist.find(ServerName.c_str()); + server_hash::iterator iter = serverlist.find(ServerName); if (iter != serverlist.end()) { return iter->second; @@ -79,7 +79,7 @@ TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName) */ TreeServer* SpanningTreeUtilities::BestRouteTo(const std::string &ServerName) { - if (ServerName.c_str() == TreeRoot->GetName() || ServerName == ServerInstance->Config->GetSID()) + if (ServerName == TreeRoot->GetName() || ServerName == ServerInstance->Config->GetSID()) return NULL; TreeServer* Found = FindServer(ServerName); if (Found) |