mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Tidy up duplicate code, provide GetSID() method on ServerConfig which returns the SID always 3 digits long
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7959 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
02b2c0ac2b
commit
f83322c938
@ -618,6 +618,10 @@ class CoreExport ServerConfig : public Extensible
|
|||||||
*/
|
*/
|
||||||
void ClearStack();
|
void ClearStack();
|
||||||
|
|
||||||
|
/** Get server ID as string with required leading zeroes
|
||||||
|
*/
|
||||||
|
std::string GetSID();
|
||||||
|
|
||||||
/** Update the 005 vector
|
/** Update the 005 vector
|
||||||
*/
|
*/
|
||||||
void Update005();
|
void Update005();
|
||||||
|
@ -1716,6 +1716,14 @@ InspIRCd* ServerConfig::GetInstance()
|
|||||||
return ServerInstance;
|
return ServerInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ServerConfig::GetSID()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
return OurSID;
|
||||||
|
}
|
||||||
|
|
||||||
ValueItem::ValueItem(int value)
|
ValueItem::ValueItem(int value)
|
||||||
{
|
{
|
||||||
|
@ -430,12 +430,6 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms)
|
|||||||
}
|
}
|
||||||
else if (params[0] == "END")
|
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;
|
std::string reason;
|
||||||
int ip6support = 0;
|
int ip6support = 0;
|
||||||
#ifdef SUPPORT_IP6LINKS
|
#ifdef SUPPORT_IP6LINKS
|
||||||
@ -508,14 +502,14 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms)
|
|||||||
if (!this->GetTheirChallenge().empty() && (this->LinkState == CONNECTING))
|
if (!this->GetTheirChallenge().empty() && (this->LinkState == CONNECTING))
|
||||||
{
|
{
|
||||||
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(OutboundPass, this->GetTheirChallenge())+" 0 "+
|
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(OutboundPass, this->GetTheirChallenge())+" 0 "+
|
||||||
OurSID+" :"+this->Instance->Config->ServerDesc);
|
Instance->Config->GetSID()+" :"+this->Instance->Config->ServerDesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* They didnt specify a challenge or we don't have m_sha256.so, we use plaintext */
|
/* They didnt specify a challenge or we don't have m_sha256.so, we use plaintext */
|
||||||
if (this->LinkState == CONNECTING)
|
if (this->LinkState == CONNECTING)
|
||||||
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+OutboundPass+" 0 "+OurSID+" :"+this->Instance->Config->ServerDesc);
|
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+OutboundPass+" 0 "+Instance->Config->GetSID()+" :"+this->Instance->Config->ServerDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reason.length())
|
if (reason.length())
|
||||||
|
@ -910,17 +910,12 @@ bool TreeSocket::Inbound_Server(std::deque<std::string> ¶ms)
|
|||||||
std::string password = params[1];
|
std::string password = params[1];
|
||||||
std::string sid = params[3];
|
std::string sid = params[3];
|
||||||
std::string description = params[4];
|
std::string description = params[4];
|
||||||
std::string OurSID;
|
|
||||||
int hops = atoi(params[2].c_str());
|
int hops = atoi(params[2].c_str());
|
||||||
|
|
||||||
this->InboundServerName = sname;
|
this->InboundServerName = sname;
|
||||||
this->InboundDescription = description;
|
this->InboundDescription = description;
|
||||||
this->InboundSID = sid;
|
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)
|
if (!sentcapab)
|
||||||
this->SendCapabilities();
|
this->SendCapabilities();
|
||||||
|
|
||||||
@ -976,7 +971,7 @@ bool TreeSocket::Inbound_Server(std::deque<std::string> ¶ms)
|
|||||||
|
|
||||||
// this is good. Send our details: Our server name and description and hopcount of 0,
|
// this is good. Send our details: Our server name and description and hopcount of 0,
|
||||||
// along with the sendpass from this block.
|
// along with the sendpass from this block.
|
||||||
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+OurSID+" :"+this->Instance->Config->ServerDesc);
|
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+Instance->Config->GetSID()+" :"+this->Instance->Config->ServerDesc);
|
||||||
// move to the next state, we are now waiting for THEM.
|
// move to the next state, we are now waiting for THEM.
|
||||||
this->LinkState = WAIT_AUTH_2;
|
this->LinkState = WAIT_AUTH_2;
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user