Fail early when loading unavailable SIP or STUN modules

This commit is contained in:
Evgeny Khramtsov 2018-09-18 18:19:42 +03:00
parent 1866b56e3b
commit 7ff5f2d3fa
2 changed files with 18 additions and 20 deletions

View File

@ -29,20 +29,19 @@
-ifndef(SIP).
-include("logger.hrl").
-export([accept/1, start/2, start_link/2, listen_options/0]).
log_error() ->
?CRITICAL_MSG("ejabberd is not compiled with SIP support", []).
fail() ->
?CRITICAL_MSG("Listening module ~s is not available: "
"ejabberd is not compiled with SIP support",
[?MODULE]),
erlang:error(sip_not_compiled).
accept(_) ->
log_error(),
ok.
fail().
listen_options() ->
log_error(),
[].
fail().
start(_, _) ->
log_error(),
{error, sip_not_compiled}.
fail().
start_link(_, _) ->
log_error(),
{error, sip_not_compiled}.
fail().
-else.
%% API
-export([tcp_init/2, udp_init/2, udp_recv/5, start/2,

View File

@ -31,20 +31,19 @@
-ifndef(STUN).
-include("logger.hrl").
-export([accept/1, start/2, start_link/2, listen_options/0]).
log_error() ->
?CRITICAL_MSG("ejabberd is not compiled with STUN/TURN support", []).
fail() ->
?CRITICAL_MSG("Listening module ~s is not available: "
"ejabberd is not compiled with STUN/TURN support",
[?MODULE]),
erlang:error(stun_not_compiled).
accept(_) ->
log_error(),
ok.
fail().
listen_options() ->
log_error(),
[];
fail().
start(_, _) ->
log_error(),
{error, sip_not_compiled}.
fail().
start_link(_, _) ->
log_error(),
{error, sip_not_compiled}.
fail().
-else.
-export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
start_link/2, accept/1, listen_opt_type/1, listen_options/0]).