summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bridge/bridge.cpp5
-rw-r--r--src/bridge/bridge.hpp4
-rw-r--r--src/irc/irc_client.cpp2
-rw-r--r--src/xmpp/xmpp_component.cpp19
-rw-r--r--src/xmpp/xmpp_component.hpp5
5 files changed, 35 insertions, 0 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index aa88262..6c85722 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -304,3 +304,8 @@ void Bridge::send_affiliation_role_change(const Iid& iid, const std::string& tar
std::tie(role, affiliation) = get_role_affiliation_from_irc_mode(mode);
this->xmpp->send_affiliation_role_change(iid.chan + "%" + iid.server, target, affiliation, role, this->user_jid);
}
+
+void Bridge::send_iq_version_request(const std::string& nick, const std::string& hostname)
+{
+ this->xmpp->send_iq_version_request(nick + "%" + hostname, this->user_jid);
+}
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index e16ea39..f2da8d7 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -99,6 +99,10 @@ public:
* Send a role/affiliation change, matching the change of mode for that user
*/
void send_affiliation_role_change(const Iid& iid, const std::string& target, const char mode);
+ /**
+ * Send an iq version request coming from nick%hostname@
+ */
+ void send_iq_version_request(const std::string& nick, const std::string& hostname);
/**
* Misc
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index da5a947..5f70efb 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -348,6 +348,8 @@ void IrcClient::on_channel_message(const IrcMessage& message)
if (body.substr(1, 6) == "ACTION")
this->bridge->send_message(iid, nick,
"/me"s + body.substr(7, body.size() - 8), muc);
+ else if (body.substr(1, 8) == "VERSION\01")
+ this->bridge->send_iq_version_request(nick, this->hostname);
}
else
this->bridge->send_message(iid, nick, body, muc);
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 9f62514..7e00346 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -28,6 +28,9 @@
#define XHTMLIM_NS "http://jabber.org/protocol/xhtml-im"
#define STANZA_NS "urn:ietf:params:xml:ns:xmpp-stanzas"
#define STREAMS_NS "urn:ietf:params:xml:ns:xmpp-streams"
+#define VERSION_NS "jabber:iq:version"
+
+using namespace std::string_literals;
unsigned long XmppComponent::current_id = 0;
@@ -786,6 +789,22 @@ void XmppComponent::send_self_disco_info(const std::string& id, const std::strin
this->send_stanza(iq);
}
+void XmppComponent::send_iq_version_request(const std::string& from,
+ const std::string& jid_to)
+{
+ Stanza iq("iq");
+ iq["type"] = "get";
+ iq["id"] = "version_"s + XmppComponent::next_id();
+ iq["from"] = from + "@" + this->served_hostname;
+ iq["to"] = jid_to;
+ XmlNode query("query");
+ query["xmlns"] = VERSION_NS;
+ query.close();
+ iq.add_child(std::move(query));
+ iq.close();
+ this->send_stanza(iq);
+}
+
std::string XmppComponent::next_id()
{
return std::to_string(XmppComponent::current_id++);
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index f54ebd7..fdf068b 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -155,6 +155,11 @@ public:
*/
void send_self_disco_info(const std::string& id, const std::string& jid_to);
/**
+ * Send an iq version request
+ */
+ void send_iq_version_request(const std::string& from,
+ const std::string& jid_to);
+ /**
* Handle the various stanza types
*/
void handle_handshake(const Stanza& stanza);