Beispiel #1
0
ModResult ModuleSpanningTree::HandleVersion(const CommandBase::Params& parameters, User* user)
{
	// We've already confirmed that !parameters.empty(), so this is safe
	TreeServer* found = Utils->FindServerMask(parameters[0]);
	if (found)
	{
		if (found == Utils->TreeRoot)
		{
			// Pass to default VERSION handler.
			return MOD_RES_PASSTHRU;
		}

		// If an oper wants to see the version then show the full version string instead of the normal,
		// but only if it is non-empty.
		// If it's empty it might be that the server is still syncing (full version hasn't arrived yet)
		// or the server is a 2.0 server and does not send a full version.
		bool showfull = ((user->IsOper()) && (!found->GetFullVersion().empty()));

		Numeric::Numeric numeric(RPL_VERSION);
		irc::tokenstream tokens(showfull ? found->GetFullVersion() : found->GetVersion());
		for (std::string token; tokens.GetTrailing(token); )
			numeric.push(token);
		user->WriteNumeric(numeric);
	}
	else
	{
		user->WriteNumeric(ERR_NOSUCHSERVER, parameters[0], "No such server");
	}
	return MOD_RES_DENY;
}
ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
{
	// we've already checked if pcnt > 0, so this is safe
	TreeServer* found = Utils->FindServerMask(parameters[0]);
	if (found)
	{
		if (found == Utils->TreeRoot)
		{
			// Pass to default VERSION handler.
			return MOD_RES_PASSTHRU;
		}

		// If an oper wants to see the version then show the full version string instead of the normal,
		// but only if it is non-empty.
		// If it's empty it might be that the server is still syncing (full version hasn't arrived yet)
		// or the server is a 2.0 server and does not send a full version.
		bool showfull = ((user->IsOper()) && (!found->GetFullVersion().empty()));
		const std::string& Version = (showfull ? found->GetFullVersion() : found->GetVersion());
		user->WriteNumeric(RPL_VERSION, ":%s", Version.c_str());
	}
	else
	{
		user->WriteNumeric(ERR_NOSUCHSERVER, "%s :No such server", parameters[0].c_str());
	}
	return MOD_RES_DENY;
}
Beispiel #3
0
int ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
{
	// we've already checked if pcnt > 0, so this is safe
	TreeServer* found = Utils->FindServerMask(parameters[0]);
	if (found)
	{
		std::string Version = found->GetVersion();
		user->WriteNumeric(351, "%s :%s",user->nick.c_str(),Version.c_str());
		if (found == Utils->TreeRoot)
		{
			ServerInstance->Config->Send005(user);
		}
	}
	else
	{
		user->WriteNumeric(402, "%s %s :No such server",user->nick.c_str(),parameters[0].c_str());
	}
	return 1;
}
Beispiel #4
0
int ModuleSpanningTree::HandleVersion(const char** parameters, int pcnt, userrec* user)
{
	// we've already checked if pcnt > 0, so this is safe
	TreeServer* found = Utils->FindServerMask(parameters[0]);
	if (found)
	{
		std::string Version = found->GetVersion();
		user->WriteServ("351 %s :%s",user->nick,Version.c_str());
		if (found == Utils->TreeRoot)
		{
			ServerInstance->Config->Send005(user);
		}
	}
	else
	{
		user->WriteServ("402 %s %s :No such server",user->nick,parameters[0]);
	}
	return 1;
}
Beispiel #5
0
ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
{
	// we've already checked if pcnt > 0, so this is safe
	TreeServer* found = Utils->FindServerMask(parameters[0]);
	if (found)
	{
		if (found == Utils->TreeRoot)
		{
			// Pass to default VERSION handler.
			return MOD_RES_PASSTHRU;
		}
		std::string Version = found->GetVersion();
		user->WriteNumeric(351, "%s :%s",user->nick.c_str(),Version.c_str());
	}
	else
	{
		user->WriteNumeric(402, "%s %s :No such server",user->nick.c_str(),parameters[0].c_str());
	}
	return MOD_RES_DENY;
}