Esempio n. 1
0
/** This is a wrapper function for SquitServer above, which
 * does some validation first and passes on the SQUIT to all
 * other remaining servers.
 */
void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
{
	bool LocalSquit = false;

	if (!Current->IsRoot())
	{
		DelServerEvent(Utils->Creator, Current->GetName());

		if (Current->IsLocal())
		{
			ServerInstance->SNO->WriteGlobalSno('l', "Server \002"+Current->GetName()+"\002 split: "+reason);
			LocalSquit = true;
			if (Current->GetSocket()->Introduced())
			{
				CmdBuilder params("SQUIT");
				params.push_back(Current->GetID());
				params.push_last(reason);
				params.Broadcast();
			}
		}
		else
		{
			ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
		}
		int num_lost_servers = 0;
		int num_lost_users = 0;
		std::string from = Current->GetParent()->GetName()+" "+Current->GetName();

		ModuleSpanningTree* st = Utils->Creator;
		st->SplitInProgress = true;
		SquitServer(from, Current, num_lost_servers, num_lost_users);
		st->SplitInProgress = false;

		ServerInstance->SNO->WriteToSnoMask(LocalSquit ? 'l' : 'L', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.",
			num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
		Current->Tidy();
		Current->GetParent()->DelChild(Current);
		Current->cull();
		const bool ismyroot = (Current == MyRoot);
		delete Current;
		if (ismyroot)
		{
			MyRoot = NULL;
			Close();
		}
	}
}
Esempio n. 2
0
/** This is a wrapper function for SquitServer above, which
 * does some validation first and passes on the SQUIT to all
 * other remaining servers.
 */
void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
{
	bool LocalSquit = false;

	if ((Current) && (Current != Utils->TreeRoot))
	{
		DelServerEvent(Utils->Creator, Current->GetName());

		if (!Current->GetSocket() || Current->GetSocket()->Introduced())
		{
			parameterlist params;
			params.push_back(Current->GetName());
			params.push_back(":"+reason);
			Utils->DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
		}

		if (Current->GetParent() == Utils->TreeRoot)
		{
			ServerInstance->SNO->WriteGlobalSno('l', "Server \002"+Current->GetName()+"\002 split: "+reason);
			LocalSquit = true;
		}
		else
		{
			ServerInstance->SNO->WriteGlobalSno('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
		}
		int num_lost_servers = 0;
		int num_lost_users = 0;
		std::string from = Current->GetParent()->GetName()+" "+Current->GetName();
		SquitServer(from, Current, num_lost_servers, num_lost_users);
		ServerInstance->SNO->WriteToSnoMask(LocalSquit ? 'l' : 'L', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.",
			num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
		Current->Tidy();
		Current->GetParent()->DelChild(Current);
		Current->cull();
		delete Current;
		if (Current == MyRoot)
		{
			MyRoot = NULL;
			Close();
		}
	}
	else
		ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Squit from unknown server");
}