• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TreeServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TreeServer的典型用法代码示例。如果您正苦于以下问题:C++ TreeServer类的具体用法?C++ TreeServer怎么用?C++ TreeServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TreeServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: HandleServer

CmdResult CommandSQuit::HandleServer(TreeServer* server, std::vector<std::string>& params)
{
	TreeServer* quitting = Utils->FindServer(params[0]);
	if (!quitting)
	{
		ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Squit from unknown server");
		return CMD_FAILURE;
	}

	CmdResult ret = CMD_SUCCESS;
	if (quitting == server)
	{
		ret = CMD_FAILURE;
		server = server->GetParent();
	}
	else if (quitting->GetParent() != server)
		throw ProtocolException("Attempted to SQUIT a non-directly connected server or the parent");

	server->SQuitChild(quitting, params[1]);

	// XXX: Return CMD_FAILURE when servers SQUIT themselves (i.e. :00S SQUIT 00S :Shutting down)
	// to stop this message from being forwarded.
	// The squit logic generates a SQUIT message with our sid as the source and sends it to the
	// remaining servers.
	return ret;
}
开发者ID:GGXY,项目名称:inspircd,代码行数:26,代码来源:treesocket1.cpp


示例2: HandleRemote

/** Because the core won't let users or even SERVERS set +o,
 * we use the OPERTYPE command to do this.
 */
CmdResult CommandOpertype::HandleRemote(RemoteUser* u, std::vector<std::string>& params)
{
	const std::string& opertype = params[0];
	if (!u->IsOper())
		ServerInstance->Users->all_opers.push_back(u);

	ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
	u->SetMode(opermh, true);

	OperIndex::iterator iter = ServerInstance->Config->OperTypes.find(opertype);
	if (iter != ServerInstance->Config->OperTypes.end())
		u->oper = iter->second;
	else
	{
		u->oper = new OperInfo;
		u->oper->name = opertype;
	}

	if (Utils->quiet_bursts)
	{
		/*
		 * If quiet bursts are enabled, and server is bursting or silent uline (i.e. services),
		 * then do nothing. -- w00t
		 */
		TreeServer* remoteserver = TreeServer::Get(u);
		if (remoteserver->bursting || remoteserver->IsSilentULine())
			return CMD_SUCCESS;
	}

	ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%[email protected]%s) is now an IRC operator of type %s",u->server->GetName().c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), opertype.c_str());
	return CMD_SUCCESS;
}
开发者ID:CardboardAqueduct,项目名称:inspircd,代码行数:35,代码来源:opertype.cpp


示例3: HandleStats

int ModuleSpanningTree::HandleStats(const char** parameters, int pcnt, userrec* user)
{
	if (pcnt > 1)
	{
		if (match(ServerInstance->Config->ServerName, parameters[1]))
			return 0;

		/* Remote STATS, the server is within the 2nd parameter */
		std::deque<std::string> params;
		params.push_back(parameters[0]);
		params.push_back(parameters[1]);
		/* Send it out remotely, generate no reply yet */

		TreeServer* s = Utils->FindServerMask(parameters[1]);
		if (s)
		{
			params[1] = s->GetName();
			Utils->DoOneToOne(user->nick, "STATS", params, s->GetName());
		}
		else
		{
			user->WriteServ( "402 %s %s :No such server", user->nick, parameters[1]);
		}
		return 1;
	}
	return 0;
}
开发者ID:TuSuNaMi,项目名称:ircd-sakura,代码行数:27,代码来源:main.cpp


示例4: GetListOfServersForChannel

/* returns a list of DIRECT servernames for a specific channel */
void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list)
{
	unsigned int minrank = 0;
	if (status)
	{
		PrefixMode* mh = ServerInstance->Modes->FindPrefix(status);
		if (mh)
			minrank = mh->GetPrefixRank();
	}

	const UserMembList *ulist = c->GetUsers();

	for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++)
	{
		if (IS_LOCAL(i->first))
			continue;

		if (minrank && i->second->getRank() < minrank)
			continue;

		if (exempt_list.find(i->first) == exempt_list.end())
		{
			TreeServer* best = TreeServer::Get(i->first);
			list.insert(best->GetSocket());
		}
	}
	return;
}
开发者ID:GeeksIRC,项目名称:inspircd,代码行数:29,代码来源:utils.cpp


示例5: DelLine

bool TreeSocket::DelLine(const std::string &prefix, parameterlist &params)
{
	if (params.size() < 2)
		return true;

	std::string setter = "<unknown>";

	User* user = ServerInstance->FindNick(prefix);
	if (user)
		setter = user->nick;
	else
	{
		TreeServer* t = Utils->FindServer(prefix);
		if (t)
			setter = t->GetName();
	}


	/* NOTE: No check needed on 'user', this function safely handles NULL */
	if (ServerInstance->XLines->DelLine(params[1].c_str(), params[0], user))
	{
		ServerInstance->SNO->WriteToSnoMask('X',"%s removed %s%s on %s", setter.c_str(),
				params[0].c_str(), params[0].length() == 1 ? "-line" : "", params[1].c_str());
		Utils->DoOneToAllButSender(prefix,"DELLINE", params, prefix);
	}
	return true;
}
开发者ID:H7-25,项目名称:inspircd,代码行数:27,代码来源:delline.cpp


示例6: HandleSquit

int ModuleSpanningTree::HandleSquit(const char** parameters, int pcnt, userrec* user)
{
	TreeServer* s = Utils->FindServerMask(parameters[0]);
	if (s)
	{
		if (s == Utils->TreeRoot)
		{
			user->WriteServ("NOTICE %s :*** SQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)",user->nick,parameters[0]);
			return 1;
		}
		TreeSocket* sock = s->GetSocket();
		if (sock)
		{
			ServerInstance->SNO->WriteToSnoMask('l',"SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick);
			sock->Squit(s,std::string("Server quit by ") + user->GetFullRealHost());
			ServerInstance->SE->DelFd(sock);
			sock->Close();
		}
		else
		{
			if (IS_LOCAL(user))
				user->WriteServ("NOTICE %s :*** WARNING: Using SQUIT to split remote servers is deprecated. Please use RSQUIT instead.",user->nick);
		}
	}
	else
	{
		 user->WriteServ("NOTICE %s :*** SQUIT: The server \002%s\002 does not exist on the network.",user->nick,parameters[0]);
	}
	return 1;
}
开发者ID:TuSuNaMi,项目名称:ircd-sakura,代码行数:30,代码来源:main.cpp


示例7: ShowLinks

void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
{
	std::string Parent = Utils->TreeRoot->GetName();
	if (Current->GetParent())
	{
		Parent = Current->GetParent()->GetName();
	}

	const TreeServer::ChildServers& children = Current->GetChildren();
	for (TreeServer::ChildServers::const_iterator i = children.begin(); i != children.end(); ++i)
	{
		TreeServer* server = *i;
		if ((server->Hidden) || ((Utils->HideULines) && (server->IsULine())))
		{
			if (user->IsOper())
			{
				 ShowLinks(server, user, hops+1);
			}
		}
		else
		{
			ShowLinks(server, user, hops+1);
		}
	}
	/* Don't display the line if its a uline, hide ulines is on, and the user isnt an oper */
	if ((Utils->HideULines) && (Current->IsULine()) && (!user->IsOper()))
		return;
	/* Or if the server is hidden and they're not an oper */
	else if ((Current->Hidden) && (!user->IsOper()))
		return;

	user->WriteNumeric(RPL_LINKS, Current->GetName(),
			(((Utils->FlatLinks) && (!user->IsOper())) ? ServerInstance->Config->ServerName : Parent),
			InspIRCd::Format("%d %s", (((Utils->FlatLinks) && (!user->IsOper())) ? 0 : hops), Current->GetDesc().c_str()));
}
开发者ID:Adam-,项目名称:inspircd,代码行数:35,代码来源:main.cpp


示例8: HandleSquit

ModResult ModuleSpanningTree::HandleSquit(const std::vector<std::string>& parameters, User* user)
{
	TreeServer* s = Utils->FindServerMask(parameters[0]);
	if (s)
	{
		if (s == Utils->TreeRoot)
		{
			user->WriteNotice("*** SQUIT: Foolish mortal, you cannot make a server SQUIT itself! (" + parameters[0] + " matches local server name)");
			return MOD_RES_DENY;
		}

		TreeSocket* sock = s->GetSocket();

		if (sock)
		{
			ServerInstance->SNO->WriteToSnoMask('l',"SQUIT: Server \002%s\002 removed from network by %s",parameters[0].c_str(),user->nick.c_str());
			sock->Squit(s,"Server quit by " + user->GetFullRealHost());
			ServerInstance->SE->DelFd(sock);
			sock->Close();
		}
		else
		{
			user->WriteNotice("*** SQUIT may not be used to remove remote servers. Please use RSQUIT instead.");
		}
	}
	else
	{
		 user->WriteNotice("*** SQUIT: The server \002" + parameters[0] + "\002 does not exist on the network.");
	}
	return MOD_RES_DENY;
}
开发者ID:Paciik,项目名称:inspircd,代码行数:31,代码来源:override_squit.cpp


示例9: DoOneToOne

void SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, Server* server)
{
	TreeServer* ts = static_cast<TreeServer*>(server);
	TreeSocket* sock = ts->GetSocket();
	if (sock)
		sock->WriteLine(params);
}
开发者ID:CardboardAqueduct,项目名称:inspircd,代码行数:7,代码来源:utils.cpp


示例10: HandleVersion

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;
}
开发者ID:Adam-,项目名称:inspircd,代码行数:30,代码来源:main.cpp


示例11: CmdBuilder

void ModuleSpanningTree::OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
{
	if (IS_LOCAL(user))
	{
		if (oper_message != reason)
			ServerInstance->PI->SendMetaData(user, "operquit", oper_message);

		CmdBuilder(user, "QUIT").push_last(reason).Broadcast();
	}
	else
	{
		// Hide the message if one of the following is true:
		// - User is being quit due to a netsplit and quietbursts is on
		// - Server is a silent uline
		TreeServer* server = TreeServer::Get(user);
		bool hide = (((server->IsDead()) && (Utils->quiet_bursts)) || (server->IsSilentULine()));
		if (!hide)
		{
			ServerInstance->SNO.WriteToSnoMask('Q', "Client exiting on server %s: %s (%s) [%s]",
				user->server->GetName().c_str(), user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_message.c_str());
		}
	}

	// Regardless, update the UserCount
	TreeServer::Get(user)->UserCount--;
}
开发者ID:Adam-,项目名称:inspircd,代码行数:26,代码来源:main.cpp


示例12: HandleVersion

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;
}
开发者ID:NikosPapakonstantinou,项目名称:inspircd,代码行数:26,代码来源:main.cpp


示例13: encap

bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const parameterlist& params, User* source)
{
	if (!source)
		source = ServerInstance->FakeClient;

	CmdBuilder encap(source, "ENCAP");

	// Are there any wildcards in the target string?
	if (targetmask.find_first_of("*?") != std::string::npos)
	{
		// Yes, send the target string as-is; servers will decide whether or not it matches them
		encap.push(targetmask).push(cmd).insert(params).Broadcast();
	}
	else
	{
		// No wildcards which means the target string has to be the name of a known server
		TreeServer* server = Utils->FindServer(targetmask);
		if (!server)
			return false;

		// Use the SID of the target in the message instead of the server name
		encap.push(server->GetID()).push(cmd).insert(params).Unicast(server->ServerUser);
	}

	return true;
}
开发者ID:GGXY,项目名称:inspircd,代码行数:26,代码来源:protocolinterface.cpp


示例14: OnGetServerDescription

void ModuleSpanningTree::OnGetServerDescription(const std::string &servername,std::string &description)
{
	TreeServer* s = Utils->FindServer(servername);
	if (s)
	{
		description = s->GetDesc();
	}
}
开发者ID:AliSharifi,项目名称:inspircd,代码行数:8,代码来源:main.cpp


示例15: DoOneToOne

bool SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, const std::string& target)
{
	TreeServer* Route = this->BestRouteTo(target);
	if (!Route)
		return false;

	Route->GetSocket()->WriteLine(params);
	return true;
}
开发者ID:novas0x2a,项目名称:inspircd,代码行数:9,代码来源:utils.cpp


示例16: DoOneToOne

bool SpanningTreeUtilities::DoOneToOne(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& target)
{
	TreeServer* Route = this->BestRouteTo(target);
	if (!Route)
		return false;

	Route->GetSocket()->WriteLine(ConstructLine(prefix, command, params));
	return true;
}
开发者ID:krsnapc,项目名称:inspircd,代码行数:9,代码来源:utils.cpp


示例17: SetNextPingTime

void TreeServer::FinishBurstInternal()
{
	this->bursting = false;
	SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
	SetPingFlag();
	for (ChildServers::const_iterator i = Children.begin(); i != Children.end(); ++i)
	{
		TreeServer* child = *i;
		child->FinishBurstInternal();
	}
}
开发者ID:interiortechnologyinc,项目名称:inspircd,代码行数:11,代码来源:treeserver.cpp


示例18: SetNextPingTime

void TreeServer::FinishBurstInternal()
{
	this->bursting = false;
	SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
	SetPingFlag();
	for(unsigned int q=0; q < ChildCount(); q++)
	{
		TreeServer* child = GetChild(q);
		child->FinishBurstInternal();
	}
}
开发者ID:Paciik,项目名称:inspircd,代码行数:11,代码来源:treeserver.cpp


示例19: MapOperInfo

void CommandMap::ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats)
{
	ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "ShowMap depth %d on line %d", depth, line);
	float percent;

	if (ServerInstance->Users->clientlist->size() == 0)
	{
		// If there are no users, WHO THE HELL DID THE /MAP?!?!?!
		percent = 0;
	}
	else
	{
		percent = Current->UserCount * 100.0 / ServerInstance->Users->clientlist->size();
	}

	const std::string operdata = user->IsOper() ? MapOperInfo(Current) : "";

	char* myname = names + 100 * line;
	char* mystat = stats + 50 * line;
	memset(myname, ' ', depth);
	int w = depth;

	if (user->IsOper())
	{
		w += snprintf(myname + depth, 99 - depth, "%s (%s)", Current->GetName().c_str(), Current->GetID().c_str());
	}
	else
	{
		w += snprintf(myname + depth, 99 - depth, "%s", Current->GetName().c_str());
	}
	memset(myname + w, ' ', 100 - w);
	if (w > maxnamew)
		maxnamew = w;
	snprintf(mystat, 49, "%5d [%5.2f%%]%s", Current->UserCount, percent, operdata.c_str());

	line++;

	if (user->IsOper() || !Utils->FlatLinks)
		depth = depth + 2;

	const TreeServer::ChildServers& servers = Current->GetChildren();
	for (TreeServer::ChildServers::const_iterator i = servers.begin(); i != servers.end(); ++i)
	{
		TreeServer* child = *i;
		if (!user->IsOper()) {
			if (child->Hidden)
				continue;
			if ((Utils->HideULines) && (ServerInstance->ULine(child->GetName())))
				continue;
		}
		ShowMap(child, user, depth, line, names, maxnamew, stats);
	}
}
开发者ID:Cronus89,项目名称:inspircd,代码行数:53,代码来源:override_map.cpp


示例20: MapOperInfo

void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats)
{
	ServerInstance->Logs->Log("map",LOG_DEBUG,"ShowMap depth %d on line %d", depth, line);
	float percent;

	if (ServerInstance->Users->clientlist->size() == 0)
	{
		// If there are no users, WHO THE HELL DID THE /MAP?!?!?!
		percent = 0;
	}
	else
	{
		percent = Current->UserCount * 100.0 / ServerInstance->Users->clientlist->size();
	}

	const std::string operdata = user->IsOper() ? MapOperInfo(Current) : "";

	char* myname = names + 100 * line;
	char* mystat = stats + 50 * line;
	memset(myname, ' ', depth);
	int w = depth;

	std::string servername = Current->GetName();
	if (user->IsOper())
	{
		w += snprintf(myname + depth, 99 - depth, "%s (%s)", servername.c_str(), Current->GetID().c_str());
	}
	else
	{
		w += snprintf(myname + depth, 99 - depth, "%s", servername.c_str());
	}
	memset(myname + w, ' ', 100 - w);
	if (w > maxnamew)
		maxnamew = w;
	snprintf(mystat, 49, "%5d [%5.2f%%]%s", Current->UserCount, percent, operdata.c_str());

	line++;

	if (user->IsOper() || !Utils->FlatLinks)
		depth = depth + 2;
	for (unsigned int q = 0; q < Current->ChildCount(); q++)
	{
		TreeServer* child = Current->GetChild(q);
		if (!user->IsOper()) {
			if (child->Hidden)
				continue;
			if ((Utils->HideULines) && (ServerInstance->ULine(child->GetName())))
				continue;
		}
		ShowMap(child, user, depth, line, names, maxnamew, stats);
	}
}
开发者ID:bandicot,项目名称:inspircd,代码行数:52,代码来源:override_map.cpp



注:本文中的TreeServer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TreeSocket类代码示例发布时间:2022-05-31
下一篇:
C++ TreeScope类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap