2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
9 local st = require "util.stanza";
11 module:add_feature("jabber:iq:version");
15 local query = st.stanza("query", {xmlns = "jabber:iq:version"})
16 :tag("name"):text("Prosody"):up()
17 :tag("version"):text(prosody.version):up();
19 if not module:get_option("hide_os_type") then
20 if os.getenv("WINDIR") then
23 local os_version_command = module:get_option("os_version_command");
24 local ok pposix = pcall(require, "pposix");
25 if not os_version_command and (ok and pposix and pposix.uname) then
26 version = pposix.uname().sysname;
29 local uname = io.popen(os_version_command or "uname");
31 version = uname:read("*a");
37 version = version:match("^%s*(.-)%s*$") or version;
38 query:tag("os"):text(version):up();
42 module:hook("iq/host/jabber:iq:version:query", function(event)
43 local stanza = event.stanza;
44 if stanza.attr.type == "get" and stanza.attr.to == module.host then
45 event.origin.send(st.reply(stanza):add_child(query));