1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 09:49:18 +02:00

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

View file

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