]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_version.erl: Added option to hide OS version (thanks to
authorAlexey Shchepin <alexey@process-one.net>
Tue, 31 Jul 2007 04:13:58 +0000 (04:13 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Tue, 31 Jul 2007 04:13:58 +0000 (04:13 +0000)
Badlop)
* doc/guide.tex: Updated

SVN Revision: 848

ChangeLog
doc/guide.tex
src/mod_version.erl

index ea4c3d8894a553fb03c0f184789064ebdf4a14fb..99017e5d38686b66b11d05e71beb590b70272d0a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-07-31  Alexey Shchepin  <alexey@sevcom.net>
 
+       * src/mod_version.erl: Added option to hide OS version (thanks to
+       Badlop)
+       * doc/guide.tex: Updated
+
        * src/msgs/zh.msg: Updated (thanks to Shelley Shyan)
 
        * src/msgs/es.msg: Updated (thanks to Badlop)
index dc42f6bc839507026182f12a1b18adb64d6f5fd8..685389eda45c84680d397c8bb9e2e2deaf309e7b 100644 (file)
@@ -2946,6 +2946,8 @@ answers \ejabberd{}'s version when queried.
 
 Options:
 \begin{description}
+\titem{show\_os}\ind{options!showos}Should the operating system be revealed or not.
+  The default value is \term{true}.
 \iqdiscitem{Software Version (\ns{jabber:iq:version})}
 \end{description}
 
index c62e27a0df0893158630a17761e68930910e16b7..236f2de7f7938836a531869b6b7d55c2d1da6f82 100644 (file)
@@ -1,14 +1,12 @@
 %%%----------------------------------------------------------------------
 %%% File    : mod_version.erl
 %%% Author  : Alexey Shchepin <alexey@sevcom.net>
-%%% Purpose : 
+%%% Purpose : XEP-0092: Software Version
 %%% Created : 18 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
-%%% Id      : $Id$
 %%%----------------------------------------------------------------------
 
 -module(mod_version).
 -author('alexey@sevcom.net').
--vsn('$Revision$ ').
 
 -behaviour(gen_mod).
 
@@ -36,32 +34,38 @@ process_local_iq(From, To, #iq{id = ID, type = Type,
        set ->
            IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
        get ->
-           OSType = case os:type() of
-                        {Osfamily, Osname} ->
-                            atom_to_list(Osfamily) ++ "/" ++
-                                atom_to_list(Osname);
-                        Osfamily ->
-                            atom_to_list(Osfamily)
-                    end,
-           OSVersion = case os:version() of
-                           {Major, Minor, Release} ->
-                               lists:flatten(
-                                 io_lib:format("~w.~w.~w",
-                                               [Major, Minor, Release]));
-                           VersionString ->
-                               VersionString
-                       end,
-           OS = OSType ++ " " ++ OSVersion,
+           Host = To#jid.server,
+           OS = case gen_mod:get_module_opt(Host, ?MODULE, show_os, true) of
+                    true -> [get_os()];
+                    false -> []
+                end,
            IQ#iq{type = result,
                  sub_el = [{xmlelement, "query",
                             [{"xmlns", ?NS_VERSION}],
                             [{xmlelement, "name", [],
                               [{xmlcdata, "ejabberd"}]},
                              {xmlelement, "version", [],
-                              [{xmlcdata, ?VERSION}]},
-                             {xmlelement, "os", [],
-                              [{xmlcdata, OS}]}
-                            ]}]}
+                              [{xmlcdata, ?VERSION}]}
+                            ] ++ OS
+                           }]}
     end.
 
 
+get_os() ->
+    OSType = case os:type() of
+                {Osfamily, Osname} ->
+                    atom_to_list(Osfamily) ++ "/" ++
+                        atom_to_list(Osname);
+                Osfamily ->
+                    atom_to_list(Osfamily)
+            end,
+    OSVersion = case os:version() of
+                   {Major, Minor, Release} ->
+                       lists:flatten(
+                         io_lib:format("~w.~w.~w",
+                                       [Major, Minor, Release]));
+                   VersionString ->
+                       VersionString
+               end,
+    OS = OSType ++ " " ++ OSVersion,
+    {xmlelement, "os", [], [{xmlcdata, OS}]}.