• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

processone / ejabberd / 1173

28 Oct 2025 11:02AM UTC coverage: 33.768% (-0.02%) from 33.79%
1173

push

github

badlop
CHANGELOG.md: Update to 25.10

15513 of 45940 relevant lines covered (33.77%)

1078.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.0
/src/mod_version.erl
1
%%%----------------------------------------------------------------------
2
%%% File    : mod_version.erl
3
%%% Author  : Alexey Shchepin <alexey@process-one.net>
4
%%% Purpose : XEP-0092: Software Version
5
%%% Created : 18 Jan 2003 by Alexey Shchepin <alexey@process-one.net>
6
%%%
7
%%%
8
%%% ejabberd, Copyright (C) 2002-2025   ProcessOne
9
%%%
10
%%% This program is free software; you can redistribute it and/or
11
%%% modify it under the terms of the GNU General Public License as
12
%%% published by the Free Software Foundation; either version 2 of the
13
%%% License, or (at your option) any later version.
14
%%%
15
%%% This program is distributed in the hope that it will be useful,
16
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
17
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
%%% General Public License for more details.
19
%%%
20
%%% You should have received a copy of the GNU General Public License along
21
%%% with this program; if not, write to the Free Software Foundation, Inc.,
22
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
%%%
24
%%%----------------------------------------------------------------------
25

26
-module(mod_version).
27

28
-author('alexey@process-one.net').
29

30
-protocol({xep, 92, '1.1', '0.1.0', "complete", ""}).
31

32
-behaviour(gen_mod).
33

34
-export([start/2, stop/1, reload/3, process_local_iq/1,
35
         mod_opt_type/1, mod_options/1, depends/2, mod_doc/0]).
36

37
-include("logger.hrl").
38
-include_lib("xmpp/include/xmpp.hrl").
39
-include("translate.hrl").
40

41
start(Host, _Opts) ->
42
    gen_iq_handler:add_iq_handler(ejabberd_local, Host,
99✔
43
                                  ?NS_VERSION, ?MODULE, process_local_iq).
44

45
stop(Host) ->
46
    gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
99✔
47
                                     ?NS_VERSION).
48

49
reload(_Host, _NewOpts, _OldOpts) ->
50
    ok.
×
51

52
process_local_iq(#iq{type = set, lang = Lang} = IQ) ->
53
    Txt = ?T("Value 'set' of 'type' attribute is not allowed"),
×
54
    xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang));
×
55
process_local_iq(#iq{type = get, to = To} = IQ) ->
56
    Host = To#jid.lserver,
1✔
57
    OS = case mod_version_opt:show_os(Host) of
1✔
58
             true -> get_os();
1✔
59
             false -> undefined
×
60
         end,
61
    xmpp:make_iq_result(IQ, #version{name = <<"ejabberd">>,
1✔
62
                                     ver = ejabberd_option:version(),
63
                                     os = OS}).
64

65
get_os() ->
66
    {Osfamily, Osname} = os:type(),
1✔
67
    OSType = list_to_binary([atom_to_list(Osfamily), $/, atom_to_list(Osname)]),
1✔
68
    OSVersion = case os:version() of
1✔
69
                  {Major, Minor, Release} ->
70
                      (str:format("~w.~w.~w",
1✔
71
                                                     [Major, Minor, Release]));
72
                  VersionString -> VersionString
×
73
                end,
74
    <<OSType/binary, " ", OSVersion/binary>>.
1✔
75

76
depends(_Host, _Opts) ->
77
    [].
117✔
78

79
mod_opt_type(show_os) ->
80
    econf:bool().
117✔
81

82
mod_options(_Host) ->
83
    [{show_os, true}].
117✔
84

85
mod_doc() ->
86
    #{desc =>
×
87
          ?T("This module implements "
88
             "https://xmpp.org/extensions/xep-0092.html"
89
             "[XEP-0092: Software Version]. Consequently, "
90
             "it answers ejabberd's version when queried."),
91
      opts =>
92
          [{show_os,
93
            #{value => "true | false",
94
              desc =>
95
                  ?T("Should the operating system be revealed or not. "
96
                     "The default value is 'true'.")}}]}.
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc