summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/xmpp/biboumi_component.cpp36
-rw-r--r--src/xmpp/biboumi_component.hpp4
2 files changed, 39 insertions, 1 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index fad87f9..4a741f3 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -399,9 +399,10 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
const XmlNode* query;
if ((query = stanza.get_child("query", DISCO_INFO_NS)))
{ // Disco info
+ Iid iid(to.local, {});
+ const std::string node = query->get_tag("node");
if (to_str == this->served_hostname)
{
- const std::string node = query->get_tag("node");
if (node.empty())
{
// On the gateway itself
@@ -409,6 +410,14 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
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)))
{
@@ -684,6 +693,31 @@ void BiboumiComponent::send_self_disco_info(const std::string& id, const std::st
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,
const std::string& jid_to)
{
diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp
index 1844451..8b2ac78 100644
--- a/src/xmpp/biboumi_component.hpp
+++ b/src/xmpp/biboumi_component.hpp
@@ -62,6 +62,10 @@ public:
*/
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
*/
void send_iq_version_request(const std::string& from,