aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-05-23 13:12:48 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-05-23 13:12:48 +0300
commit69de1780a0824afbd6d7e52e4df7cd4bfa931974 (patch)
tree243e430c51c7c9574ba065ea54e347be8077b3aa
parentGet rid of sql_queries.erl (diff)
Introduce --enable-stun and --enable-sip configure options
STUN/TURN and SIP is not compiled by default anymore. Use --enable-stun, --enable-sip or --enable-all to enable them.
-rw-r--r--configure.ac24
-rw-r--r--rebar.config8
-rw-r--r--src/ejabberd_sip.erl16
-rw-r--r--src/ejabberd_stun.erl16
-rw-r--r--src/mod_sip.erl17
-rw-r--r--src/mod_sip_proxy.erl5
-rw-r--r--src/mod_sip_registrar.erl5
-rw-r--r--vars.config.in2
8 files changed, 86 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index f5eee8cbf..aa92cf38e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,10 +101,10 @@ AC_ARG_ENABLE(mssql,
esac],[db_type=generic])
AC_ARG_ENABLE(all,
-[AC_HELP_STRING([--enable-all], [same as --enable-odbc --enable-mysql --enable-pgsql --enable-sqlite --enable-pam --enable-zlib --enable-riak --enable-redis --enable-elixir --enable-iconv --enable-debug --enable-tools (useful for Dialyzer checks, default: no)])],
+[AC_HELP_STRING([--enable-all], [same as --enable-odbc --enable-mysql --enable-pgsql --enable-sqlite --enable-pam --enable-zlib --enable-riak --enable-redis --enable-elixir --enable-iconv --enable-stun --enable-sip --enable-debug --enable-tools (useful for Dialyzer checks, default: no)])],
[case "${enableval}" in
- yes) odbc=true mysql=true pgsql=true sqlite=true pam=true zlib=true riak=true redis=true elixir=true iconv=true debug=true tools=true ;;
- no) odbc=false mysql=false pgsql=false sqlite=false pam=false zlib=false riak=false redis=false elixir=false iconv=false debug=false tools=false ;;
+ yes) odbc=true mysql=true pgsql=true sqlite=true pam=true zlib=true riak=true redis=true elixir=true iconv=true stun=true sip=true debug=true tools=true ;;
+ no) odbc=false mysql=false pgsql=false sqlite=false pam=false zlib=false riak=false redis=false elixir=false iconv=false stun=false sip=false debug=false tools=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-all) ;;
esac],[])
@@ -212,6 +212,22 @@ AC_ARG_ENABLE(latest_deps,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-latest-deps) ;;
esac],[if test "x$latest_deps" = "x"; then latest_deps=false; fi])
+AC_ARG_ENABLE(stun,
+[AC_HELP_STRING([--enable-stun], [enable STUN/TURN support (default: no)])],
+[case "${enableval}" in
+ yes) stun=true ;;
+ no) stun=false ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-stun) ;;
+esac],[if test "x$stun" = "x"; then stun=false; fi])
+
+AC_ARG_ENABLE(sip,
+[AC_HELP_STRING([--enable-sip], [enable SIP support (default: no)])],
+[case "${enableval}" in
+ yes) sip=true ;;
+ no) sip=false ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-sip) ;;
+esac],[if test "x$sip" = "x"; then sip=false; fi])
+
AC_CONFIG_FILES([Makefile
vars.config
src/ejabberd.app.src])
@@ -253,6 +269,8 @@ AC_SUBST(riak)
AC_SUBST(redis)
AC_SUBST(elixir)
AC_SUBST(iconv)
+AC_SUBST(stun)
+AC_SUBST(sip)
AC_SUBST(debug)
AC_SUBST(tools)
AC_SUBST(latest_deps)
diff --git a/rebar.config b/rebar.config
index acd737681..c67a86f67 100644
--- a/rebar.config
+++ b/rebar.config
@@ -25,12 +25,12 @@
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.8"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.21"}}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "e8dbfec277e7eb27b8130b13873b969cc346fafc"}},
- {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.10"}}},
- {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.11"}}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.9"}}},
{jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}},
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.1"}}},
{luerl, ".*", {git, "https://github.com/rvirding/luerl", {tag, "v0.2"}}},
+ {if_var_true, stun, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.10"}}}},
+ {if_var_true, sip, {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.11"}}}},
{if_var_true, mysql, {p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql",
"31e035b"}}},
{if_var_true, pgsql, {p1_pgsql, ".*", {git, "https://github.com/processone/p1_pgsql",
@@ -84,6 +84,8 @@
{i, "deps/p1_utils/include"},
{if_var_false, debug, no_debug_info},
{if_var_true, debug, debug_info},
+ {if_var_true, sip, {d, 'SIP'}},
+ {if_var_true, stun, {d, 'STUN'}},
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
{if_var_match, db_type, mssql, {d, 'mssql'}},
{if_var_true, elixir, {d, 'ELIXIR_ENABLED'}},
@@ -146,7 +148,7 @@
{post_hook_configure, [{"fast_tls", []},
{"stringprep", []},
{"fast_yaml", []},
- {"esip", []},
+ {if_var_true, sip, {"esip", []}},
{"fast_xml", [{if_var_true, full_xml, "--enable-full-xml"}]},
{if_var_true, pam, {"epam", []}},
{if_var_true, zlib, {"ezlib", []}},
diff --git a/src/ejabberd_sip.erl b/src/ejabberd_sip.erl
index d7404a30e..2c98aec16 100644
--- a/src/ejabberd_sip.erl
+++ b/src/ejabberd_sip.erl
@@ -22,6 +22,21 @@
%%%-------------------------------------------------------------------
-module(ejabberd_sip).
+-ifndef(SIP).
+-include("logger.hrl").
+-export([socket_type/0, start/2, listen_opt_type/1]).
+log_error() ->
+ ?CRITICAL_MSG("ejabberd is not compiled with SIP support", []).
+socket_type() ->
+ log_error(),
+ raw.
+listen_opt_type(_) ->
+ log_error(),
+ [].
+start(_, _) ->
+ log_error(),
+ {error, sip_not_compiled}.
+-else.
%% API
-export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
socket_type/0, listen_opt_type/1]).
@@ -59,3 +74,4 @@ listen_opt_type(_) ->
%%%===================================================================
%%% Internal functions
%%%===================================================================
+-endif.
diff --git a/src/ejabberd_stun.erl b/src/ejabberd_stun.erl
index 3611edba7..35a04ce45 100644
--- a/src/ejabberd_stun.erl
+++ b/src/ejabberd_stun.erl
@@ -27,6 +27,21 @@
-protocol({rfc, 5766}).
-protocol({xep, 176, '1.0'}).
+-ifndef(STUN).
+-include("logger.hrl").
+-export([socket_type/0, start/2, listen_opt_type/1]).
+log_error() ->
+ ?CRITICAL_MSG("ejabberd is not compiled with STUN/TURN support", []).
+socket_type() ->
+ log_error(),
+ raw.
+listen_opt_type(_) ->
+ log_error(),
+ [].
+start(_, _) ->
+ log_error(),
+ {error, sip_not_compiled}.
+-else.
-export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
socket_type/0, listen_opt_type/1]).
@@ -138,3 +153,4 @@ listen_opt_type(_) ->
[shaper, auth_type, auth_realm, tls, certfile, turn_min_port,
turn_max_port, turn_max_allocations, turn_max_permissions,
server_name].
+-endif.
diff --git a/src/mod_sip.erl b/src/mod_sip.erl
index eb5cbe545..7c3e60917 100644
--- a/src/mod_sip.erl
+++ b/src/mod_sip.erl
@@ -25,6 +25,20 @@
-module(mod_sip).
-protocol({rfc, 3261}).
+-include("logger.hrl").
+
+-ifndef(SIP).
+-export([start/2, stop/1, depends/2, mod_opt_type/1]).
+start(_, _) ->
+ ?CRITICAL_MSG("ejabberd is not compiled with SIP support", []),
+ {error, sip_not_compiled}.
+stop(_) ->
+ ok.
+depends(_, _) ->
+ [].
+mod_opt_type(_) ->
+ [].
+-else.
-behaviour(gen_mod).
-behaviour(esip).
@@ -37,7 +51,6 @@
locate/1, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
--include("logger.hrl").
-include_lib("esip/include/esip.hrl").
%%%===================================================================
@@ -350,3 +363,5 @@ mod_opt_type(via) ->
mod_opt_type(_) ->
[always_record_route, flow_timeout_tcp,
flow_timeout_udp, record_route, routes, via].
+
+-endif.
diff --git a/src/mod_sip_proxy.erl b/src/mod_sip_proxy.erl
index 5e0cfa25e..19a02e8e4 100644
--- a/src/mod_sip_proxy.erl
+++ b/src/mod_sip_proxy.erl
@@ -24,6 +24,9 @@
%%%-------------------------------------------------------------------
-module(mod_sip_proxy).
+-ifndef(SIP).
+-export([]).
+-else.
-define(GEN_FSM, p1_fsm).
-behaviour(?GEN_FSM).
@@ -424,3 +427,5 @@ safe_nameprep(S) ->
error -> S;
S1 -> S1
end.
+
+-endif.
diff --git a/src/mod_sip_registrar.erl b/src/mod_sip_registrar.erl
index 1bc819c08..0e131eee6 100644
--- a/src/mod_sip_registrar.erl
+++ b/src/mod_sip_registrar.erl
@@ -24,6 +24,9 @@
%%%-------------------------------------------------------------------
-module(mod_sip_registrar).
+-ifndef(SIP).
+-export([]).
+-else.
-ifndef(GEN_SERVER).
-define(GEN_SERVER, gen_server).
-endif.
@@ -580,3 +583,5 @@ process_ping(SIPSocket) ->
(_, Acc) ->
Acc
end, ErrResponse, Sessions).
+
+-endif.
diff --git a/vars.config.in b/vars.config.in
index 5eca4889a..94584dad4 100644
--- a/vars.config.in
+++ b/vars.config.in
@@ -40,6 +40,8 @@
{redis, @redis@}.
{elixir, @elixir@}.
{iconv, @iconv@}.
+{stun, @stun@}.
+{sip, @sip@}.
%% Version
{vsn, "@PACKAGE_VERSION@"}.