From 14d102b7502e15ff091bd4d14a4d5d5ead9eddb3 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sat, 19 May 2012 12:21:02 +0200 Subject: m_spanningtree Fix various bugs related to protocol interface and ENCAP handling Most importantly: - Match the server name not the SID for determining if an incoming ENCAP should be processed by us - Handle the ? wildcard properly in the server name parameter of an ENCAP - Send single target ENCAPs to the destination only instead of broadcasting it - Make ProtocolInterface::SendMetaData accept TYPE_OTHER as target_type (on par with ProtoSendMetaData) instead of throwing an exception --- src/modules/m_spanningtree/protocolinterface.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/modules/m_spanningtree/protocolinterface.cpp') diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index 6e68e2a52..9bd0263dc 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -48,7 +48,14 @@ void SpanningTreeProtocolInterface::GetServerList(ProtoServerList &sl) void SpanningTreeProtocolInterface::SendEncapsulatedData(parameterlist &encap) { - Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ENCAP", encap); + if (encap.size() < 2) + return; + + const std::string& target = encap[0]; + if (target.find_first_of("*?") == std::string::npos) + Utils->DoOneToOne(ServerInstance->Config->GetSID(), "ENCAP", encap, target); + else + Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ENCAP", encap); } void SpanningTreeProtocolInterface::SendMetaData(void* target, TargetTypeFlags type, const std::string &key, const std::string &data) @@ -63,12 +70,10 @@ void SpanningTreeProtocolInterface::SendMetaData(void* target, TargetTypeFlags t case TYPE_CHANNEL: params.push_back(((Channel*)target)->name); break; + case TYPE_OTHER: case TYPE_SERVER: params.push_back("*"); break; - default: - throw CoreException("I don't know how to handle TYPE_OTHER."); - break; } params.push_back(key); params.push_back(":" + data); @@ -179,7 +184,7 @@ void SpanningTreeProtocolInterface::SendUserPrivmsg(User* target, const std::str TreeSocket* sock = serv->GetSocket(); if (sock) { - sock->WriteLine(":" + ServerInstance->Config->GetSID() + " PRIVMSG " + target->nick + " :"+text); + sock->WriteLine(":" + ServerInstance->Config->GetSID() + " PRIVMSG " + target->uuid + " :"+text); } } } @@ -192,7 +197,7 @@ void SpanningTreeProtocolInterface::SendUserNotice(User* target, const std::stri TreeSocket* sock = serv->GetSocket(); if (sock) { - sock->WriteLine(":" + ServerInstance->Config->GetSID() + " NOTICE " + target->nick + " :"+text); + sock->WriteLine(":" + ServerInstance->Config->GetSID() + " NOTICE " + target->uuid + " :"+text); } } } -- cgit v1.3.1-10-gc9f91