Respond to disco#info requests on IRC server JIDs
This makes it possible to execute an ad-hoc command on a server, with clients like Gajim, for example.
This commit is contained in:
@@ -399,9 +399,10 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
|
|||||||
const XmlNode* query;
|
const XmlNode* query;
|
||||||
if ((query = stanza.get_child("query", DISCO_INFO_NS)))
|
if ((query = stanza.get_child("query", DISCO_INFO_NS)))
|
||||||
{ // Disco info
|
{ // Disco info
|
||||||
|
Iid iid(to.local, {});
|
||||||
|
const std::string node = query->get_tag("node");
|
||||||
if (to_str == this->served_hostname)
|
if (to_str == this->served_hostname)
|
||||||
{
|
{
|
||||||
const std::string node = query->get_tag("node");
|
|
||||||
if (node.empty())
|
if (node.empty())
|
||||||
{
|
{
|
||||||
// On the gateway itself
|
// On the gateway itself
|
||||||
@@ -409,6 +410,14 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
|
|||||||
stanza_error.disable();
|
stanza_error.disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (iid.type == Iid::Type::Server)
|
||||||
|
{
|
||||||
|
if (node.empty())
|
||||||
|
{
|
||||||
|
this->send_irc_server_disco_info(id, from, to_str);
|
||||||
|
stanza_error.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((query = stanza.get_child("query", VERSION_NS)))
|
else if ((query = stanza.get_child("query", VERSION_NS)))
|
||||||
{
|
{
|
||||||
@@ -684,6 +693,31 @@ void BiboumiComponent::send_self_disco_info(const std::string& id, const std::st
|
|||||||
this->send_stanza(iq);
|
this->send_stanza(iq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BiboumiComponent::send_irc_server_disco_info(const std::string& id, const std::string& jid_to, const std::string& jid_from)
|
||||||
|
{
|
||||||
|
Jid from(jid_from);
|
||||||
|
Stanza iq("iq");
|
||||||
|
iq["type"] = "result";
|
||||||
|
iq["id"] = id;
|
||||||
|
iq["to"] = jid_to;
|
||||||
|
iq["from"] = jid_from;
|
||||||
|
XmlNode query("query");
|
||||||
|
query["xmlns"] = DISCO_INFO_NS;
|
||||||
|
XmlNode identity("identity");
|
||||||
|
identity["category"] = "conference";
|
||||||
|
identity["type"] = "irc";
|
||||||
|
identity["name"] = "IRC server "s + from.local + " over Biboumi";
|
||||||
|
query.add_child(std::move(identity));
|
||||||
|
for (const char* ns: {DISCO_INFO_NS, ADHOC_NS, PING_NS, VERSION_NS})
|
||||||
|
{
|
||||||
|
XmlNode feature("feature");
|
||||||
|
feature["var"] = ns;
|
||||||
|
query.add_child(std::move(feature));
|
||||||
|
}
|
||||||
|
iq.add_child(std::move(query));
|
||||||
|
this->send_stanza(iq);
|
||||||
|
}
|
||||||
|
|
||||||
void BiboumiComponent::send_iq_version_request(const std::string& from,
|
void BiboumiComponent::send_iq_version_request(const std::string& from,
|
||||||
const std::string& jid_to)
|
const std::string& jid_to)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ public:
|
|||||||
* Send a result IQ with the gateway disco informations.
|
* Send a result IQ with the gateway disco informations.
|
||||||
*/
|
*/
|
||||||
void send_self_disco_info(const std::string& id, const std::string& jid_to);
|
void send_self_disco_info(const std::string& id, const std::string& jid_to);
|
||||||
|
/**
|
||||||
|
* Send a result IQ with the disco informations regarding IRC server JIDs.
|
||||||
|
*/
|
||||||
|
void send_irc_server_disco_info(const std::string& id, const std::string& jid_to, const std::string& jid_from);
|
||||||
/**
|
/**
|
||||||
* Send an iq version request
|
* Send an iq version request
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user