summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-27 20:50:07 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-27 20:50:07 +0000
commit66d187fa55b4fdcb38ec987c269c4c1573a441b5 (patch)
tree6560fe4224b89abf745ef8a90d913ef85b582441
parent8c3a4a51ff092a0614e6c9a15e4bd53e4877bc48 (diff)
Store id in TreeServer, use TreeServer::GetID() to get the id (NOTE: it is std::string)
Server id sent on all outbound and inbound SERVER now. last parameter before desc. Min params for SERVER is now 5, not 4. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7918 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp10
-rw-r--r--src/modules/m_spanningtree/treeserver.h9
-rw-r--r--src/modules/m_spanningtree/treesocket.h1
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp15
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp32
5 files changed, 55 insertions, 12 deletions
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index d13075f0f..d252f2386 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -124,6 +124,16 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
this->AddHashEntry();
}
+std::string& TreeServer::GetID()
+{
+ return sid;
+}
+
+void TreeServer::SetID(const std::string &id)
+{
+ sid = id;
+}
+
int TreeServer::QuitUsers(const std::string &reason)
{
const char* reason_s = reason.c_str();
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index d8d3b70e8..125fdbd67 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -43,6 +43,7 @@ class TreeServer : public classbase
time_t NextPing; /* After this time, the server should be PINGed*/
bool LastPingWasGood; /* True if the server responded to the last PING with a PONG */
SpanningTreeUtilities* Utils; /* Utility class */
+ std::string sid; /* Server ID */
public:
@@ -181,6 +182,14 @@ class TreeServer : public classbase
*/
bool Tidy();
+ /** Get server ID
+ */
+ std::string& GetID();
+
+ /** Set server ID
+ */
+ void SetID(const std::string &id);
+
/** Destructor
*/
~TreeServer();
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 55a83f3ef..e7cacf0c6 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -83,6 +83,7 @@ class TreeSocket : public InspSocket
ServerState LinkState; /* Link state */
std::string InboundServerName; /* Server name sent to us by other side */
std::string InboundDescription; /* Server description (GECOS) sent to us by the other side */
+ std::string InboundSID; /* Server ID sent to us by the other side */
int num_lost_users; /* Users lost in split */
int num_lost_servers; /* Servers lost in split */
time_t NextPing; /* Time when we are due to ping this server */
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index f419f9bec..9c53a16cd 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -268,7 +268,9 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
TreeServer* recursive_server = Current->GetChild(q);
if (recursive_server != s)
{
- snprintf(command,1024,":%s SERVER %s * %d :%s",Current->GetName().c_str(),recursive_server->GetName().c_str(),hops,recursive_server->GetDesc().c_str());
+ snprintf(command,1024,":%s SERVER %s * %d %s :%s",Current->GetName().c_str(),recursive_server->GetName().c_str(),hops,
+ recursive_server->GetID().c_str(),
+ recursive_server->GetDesc().c_str());
this->WriteLine(command);
this->WriteLine(":"+recursive_server->GetName()+" VERSION :"+recursive_server->GetVersion());
/* down to next level */
@@ -432,6 +434,12 @@ bool TreeSocket::Capab(const std::deque<std::string> &params)
}
else if (params[0] == "END")
{
+ std::string OurSID;
+
+ OurSID += (char)((Instance->Config->sid / 100) + 48);
+ OurSID += (char)((Instance->Config->sid / 10) % 10 + 48);
+ OurSID += (char)(Instance->Config->sid % 10 + 48);
+
std::string reason;
int ip6support = 0;
#ifdef SUPPORT_IP6LINKS
@@ -503,14 +511,15 @@ bool TreeSocket::Capab(const std::deque<std::string> &params)
this->SetTheirChallenge(n->second);
if (!this->GetTheirChallenge().empty() && (this->LinkState == CONNECTING))
{
- this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(OutboundPass, this->GetTheirChallenge())+" 0 :"+this->Instance->Config->ServerDesc);
+ this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(OutboundPass, this->GetTheirChallenge())+" 0 "+
+ OurSID+" :"+this->Instance->Config->ServerDesc);
}
}
else
{
/* They didnt specify a challenge or we don't have m_sha256.so, we use plaintext */
if (this->LinkState == CONNECTING)
- this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+OutboundPass+" 0 :"+this->Instance->Config->ServerDesc);
+ this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+OutboundPass+" 0 "+OurSID+" :"+this->Instance->Config->ServerDesc);
}
if (reason.length())
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 64705cb98..067a972ae 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -779,12 +779,13 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque<std::string>
bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string> &params)
{
- if (params.size() < 4)
+ if (params.size() < 5)
return false;
std::string servername = params[0];
std::string password = params[1];
// hopcount is not used for a remote server, we calculate this ourselves
- std::string description = params[3];
+ std::string sid = params[3];
+ std::string description = params[4];
TreeServer* ParentOfThis = Utils->FindServer(prefix);
if (!ParentOfThis)
{
@@ -801,7 +802,8 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string>
Link* lnk = Utils->FindLink(servername);
TreeServer* Node = new TreeServer(this->Utils,this->Instance,servername,description,ParentOfThis,NULL, lnk ? lnk->Hidden : false);
ParentOfThis->AddChild(Node);
- params[3] = ":" + params[3];
+ Node->SetID(sid);
+ params[4] = ":" + params[4];
Utils->SetRemoteBursting(Node, true);
Utils->DoOneToAllButSender(prefix,"SERVER",params,prefix);
this->Instance->SNO->WriteToSnoMask('l',"Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
@@ -828,17 +830,19 @@ bool TreeSocket::ComparePass(const std::string &ours, const std::string &theirs)
bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
{
- if (params.size() < 4)
+ if (params.size() < 5)
return false;
irc::string servername = params[0].c_str();
std::string sname = params[0];
std::string password = params[1];
- std::string description = params[3];
+ std::string sid = params[3];
+ std::string description = params[4];
int hops = atoi(params[2].c_str());
this->InboundServerName = sname;
this->InboundDescription = description;
+ this->InboundSID = sid;
if (!sentcapab)
this->SendCapabilities();
@@ -871,7 +875,8 @@ bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
// node.
TreeServer* Node = new TreeServer(this->Utils,this->Instance,sname,description,Utils->TreeRoot,this,x->Hidden);
Utils->TreeRoot->AddChild(Node);
- params[3] = ":" + params[3];
+ params[4] = ":" + params[4];
+ Node->SetID(params[3]);
Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,sname);
this->bursting = true;
this->DoBurst(Node);
@@ -885,16 +890,23 @@ bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
bool TreeSocket::Inbound_Server(std::deque<std::string> &params)
{
- if (params.size() < 4)
+ if (params.size() < 5)
return false;
irc::string servername = params[0].c_str();
std::string sname = params[0];
std::string password = params[1];
- std::string description = params[3];
+ std::string sid = params[3];
+ std::string description = params[4];
+ std::string OurSID;
int hops = atoi(params[2].c_str());
this->InboundServerName = sname;
this->InboundDescription = description;
+ this->InboundSID = sid;
+
+ OurSID += (char)((Instance->Config->sid / 100) + 48);
+ OurSID += (char)((Instance->Config->sid / 10) % 10 + 48);
+ OurSID += (char)(Instance->Config->sid % 10 + 48);
if (!sentcapab)
this->SendCapabilities();
@@ -941,7 +953,7 @@ bool TreeSocket::Inbound_Server(std::deque<std::string> &params)
// this is good. Send our details: Our server name and description and hopcount of 0,
// along with the sendpass from this block.
- this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 :"+this->Instance->Config->ServerDesc);
+ this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+OurSID+" :"+this->Instance->Config->ServerDesc);
// move to the next state, we are now waiting for THEM.
this->LinkState = WAIT_AUTH_2;
return true;
@@ -1071,7 +1083,9 @@ bool TreeSocket::ProcessLine(std::string &line)
params.push_back(InboundServerName);
params.push_back("*");
params.push_back("1");
+ params.push_back(InboundSID);
params.push_back(":"+InboundDescription);
+ Node->SetID(InboundSID);
Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,InboundServerName);
this->bursting = true;
this->DoBurst(Node);