mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
ejabberd_stun: Add 'stun_get_password' hook
Add a hook that allows modules to offer a password for STUN/TURN authentication.
This commit is contained in:
parent
1a3533e4a2
commit
1db70edcf8
@ -46,7 +46,8 @@ start_link(_, _, _) ->
|
||||
fail().
|
||||
-else.
|
||||
-export([tcp_init/2, udp_init/2, udp_recv/5, start/3,
|
||||
start_link/3, accept/1, listen_opt_type/1, listen_options/0]).
|
||||
start_link/3, accept/1, listen_opt_type/1, listen_options/0,
|
||||
get_password/2]).
|
||||
|
||||
-include("logger.hrl").
|
||||
|
||||
@ -74,6 +75,14 @@ start_link(_SockMod, Socket, Opts) ->
|
||||
accept(_Pid) ->
|
||||
ok.
|
||||
|
||||
get_password(User, Realm) ->
|
||||
case ejabberd_hooks:run_fold(stun_get_password, <<>>, [User, Realm]) of
|
||||
Password when byte_size(Password) > 0 ->
|
||||
Password;
|
||||
<<>> ->
|
||||
ejabberd_auth:get_password_s(User, Realm)
|
||||
end.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
@ -95,7 +104,7 @@ prepare_turn_opts(Opts, _UseTurn = true) ->
|
||||
_ ->
|
||||
ok
|
||||
end,
|
||||
AuthFun = fun ejabberd_auth:get_password_s/2,
|
||||
AuthFun = fun ejabberd_stun:get_password/2,
|
||||
Shaper = proplists:get_value(shaper, Opts, none),
|
||||
AuthType = proplists:get_value(auth_type, Opts, user),
|
||||
Realm = case proplists:get_value(auth_realm, Opts) of
|
||||
|
Loading…
Reference in New Issue
Block a user