From a78ea8fb5415892378ec6f2a527e7fcf749aea91 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Tue, 31 Jul 2007 04:13:58 +0000 Subject: [PATCH] * src/mod_version.erl: Added option to hide OS version (thanks to Badlop) * doc/guide.tex: Updated SVN Revision: 848 --- ChangeLog | 4 ++++ doc/guide.tex | 2 ++ src/mod_version.erl | 50 ++++++++++++++++++++++++--------------------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea4c3d889..99017e5d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-07-31 Alexey Shchepin + * 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) diff --git a/doc/guide.tex b/doc/guide.tex index dc42f6bc8..685389eda 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -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} diff --git a/src/mod_version.erl b/src/mod_version.erl index c62e27a0d..236f2de7f 100644 --- a/src/mod_version.erl +++ b/src/mod_version.erl @@ -1,14 +1,12 @@ %%%---------------------------------------------------------------------- %%% File : mod_version.erl %%% Author : Alexey Shchepin -%%% Purpose : +%%% Purpose : XEP-0092: Software Version %%% Created : 18 Jan 2003 by Alexey Shchepin -%%% 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}]}.