summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-07-27 18:12:34 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-07-27 18:12:34 +0200
commit05e594030ccfc044ac69f650eccaba8e981ce329 (patch)
treef4d39d617d76e58a3a6f5ded0c494842291371a5 /src
parenta7043cc3d3a30a7d8a14e9c12f3628836a2b1397 (diff)
m_spanningtree Deduplicate auth finish code
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_spanningtree/server.cpp12
-rw-r--r--src/modules/m_spanningtree/treesocket.h10
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp28
3 files changed, 28 insertions, 22 deletions
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 73f36f37f..5a12497bc 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -120,17 +120,7 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
* While we're at it, create a treeserver object so we know about them.
* -- w
*/
- this->LinkState = CONNECTED;
-
- Utils->timeoutlist.erase(this);
- linkID = sname;
-
- MyRoot = new TreeServer(sname, description, sid, Utils->TreeRoot, this, x->Hidden);
- Utils->TreeRoot->AddChild(MyRoot);
- this->DoBurst(MyRoot);
-
- // This will send a * in place of the password/hmac
- CommandServer::Builder(MyRoot).Forward(MyRoot);
+ FinishAuth(sname, sid, description, x->Hidden);
return true;
}
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 27c8ab275..9dbc212a1 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -129,6 +129,16 @@ class TreeSocket : public BufferedSocket
*/
User* FindSource(const std::string& prefix, const std::string& command);
+ /** Finish the authentication phase of this connection.
+ * Change the state of the connection to CONNECTED, create a TreeServer object for the server on the
+ * other end of the connection using the details provided in the parameters, and finally send a burst.
+ * @param remotename Name of the remote server
+ * @param remotesid SID of the remote server
+ * @param remotedesc Description of the remote server
+ * @param hidden True if the remote server is hidden according to the configuration
+ */
+ void FinishAuth(const std::string& remotename, const std::string& remotesid, const std::string& remotedesc, bool hidden);
+
public:
const time_t age;
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 3df0bdee8..bfd3db587 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -168,18 +168,8 @@ void TreeSocket::ProcessLine(std::string &line)
if (!CheckDuplicate(capab->name, capab->sid))
return;
- this->LinkState = CONNECTED;
- Utils->timeoutlist.erase(this);
+ FinishAuth(capab->name, capab->sid, capab->description, capab->hidden);
- linkID = capab->name;
-
- MyRoot = new TreeServer(capab->name, capab->description, capab->sid, Utils->TreeRoot, this, capab->hidden);
- Utils->TreeRoot->AddChild(MyRoot);
-
- MyRoot->bursting = true;
- this->DoBurst(MyRoot);
-
- CommandServer::Builder(MyRoot).Forward(MyRoot);
CmdBuilder(MyRoot->GetID(), "BURST").insert(params).Forward(MyRoot);
}
else if (command == "ERROR")
@@ -380,3 +370,19 @@ void TreeSocket::Close()
}
}
}
+
+void TreeSocket::FinishAuth(const std::string& remotename, const std::string& remotesid, const std::string& remotedesc, bool hidden)
+{
+ this->LinkState = CONNECTED;
+ Utils->timeoutlist.erase(this);
+
+ linkID = remotename;
+
+ MyRoot = new TreeServer(remotename, remotedesc, remotesid, Utils->TreeRoot, this, hidden);
+ Utils->TreeRoot->AddChild(MyRoot);
+
+ this->DoBurst(MyRoot);
+
+ // This will send a * in place of the password/hmac
+ CommandServer::Builder(MyRoot).Forward(MyRoot);
+}