mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Use maps instead of dict
This commit is contained in:
parent
92ab59a581
commit
83e6741117
@ -107,7 +107,7 @@ init([State, Opts]) ->
|
|||||||
xmlns => ?NS_COMPONENT,
|
xmlns => ?NS_COMPONENT,
|
||||||
lang => ejabberd_option:language(),
|
lang => ejabberd_option:language(),
|
||||||
server => ejabberd_config:get_myname(),
|
server => ejabberd_config:get_myname(),
|
||||||
host_opts => dict:from_list(HostOpts1),
|
host_opts => maps:from_list(HostOpts1),
|
||||||
stream_version => undefined,
|
stream_version => undefined,
|
||||||
tls_options => TLSOpts,
|
tls_options => TLSOpts,
|
||||||
global_routes => GlobalRoutes,
|
global_routes => GlobalRoutes,
|
||||||
@ -123,13 +123,13 @@ handle_stream_start(_StreamStart,
|
|||||||
Txt = ?T("Unable to register route on existing local domain"),
|
Txt = ?T("Unable to register route on existing local domain"),
|
||||||
xmpp_stream_in:send(State, xmpp:serr_conflict(Txt, Lang));
|
xmpp_stream_in:send(State, xmpp:serr_conflict(Txt, Lang));
|
||||||
false ->
|
false ->
|
||||||
NewHostOpts = case dict:is_key(RemoteServer, HostOpts) of
|
NewHostOpts = case maps:is_key(RemoteServer, HostOpts) of
|
||||||
true ->
|
true ->
|
||||||
HostOpts;
|
HostOpts;
|
||||||
false ->
|
false ->
|
||||||
case dict:find(global, HostOpts) of
|
case maps:find(global, HostOpts) of
|
||||||
{ok, GlobalPass} ->
|
{ok, GlobalPass} ->
|
||||||
dict:from_list([{RemoteServer, GlobalPass}]);
|
maps:from_list([{RemoteServer, GlobalPass}]);
|
||||||
error ->
|
error ->
|
||||||
HostOpts
|
HostOpts
|
||||||
end
|
end
|
||||||
@ -142,7 +142,7 @@ get_password_fun(#{remote_server := RemoteServer,
|
|||||||
socket := Socket, ip := IP,
|
socket := Socket, ip := IP,
|
||||||
host_opts := HostOpts}) ->
|
host_opts := HostOpts}) ->
|
||||||
fun(_) ->
|
fun(_) ->
|
||||||
case dict:find(RemoteServer, HostOpts) of
|
case maps:find(RemoteServer, HostOpts) of
|
||||||
{ok, Password} ->
|
{ok, Password} ->
|
||||||
{Password, undefined};
|
{Password, undefined};
|
||||||
error ->
|
error ->
|
||||||
@ -163,7 +163,7 @@ handle_auth_success(_, Mech, _,
|
|||||||
[xmpp_socket:pp(Socket), Mech, RemoteServer,
|
[xmpp_socket:pp(Socket), Mech, RemoteServer,
|
||||||
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
Routes = if GlobalRoutes ->
|
Routes = if GlobalRoutes ->
|
||||||
dict:fetch_keys(HostOpts);
|
maps:keys(HostOpts);
|
||||||
true ->
|
true ->
|
||||||
[RemoteServer]
|
[RemoteServer]
|
||||||
end,
|
end,
|
||||||
@ -245,7 +245,7 @@ check_from(_From, #{check_from := false}) ->
|
|||||||
check_from(From, #{host_opts := HostOpts}) ->
|
check_from(From, #{host_opts := HostOpts}) ->
|
||||||
%% The default is the standard behaviour in XEP-0114
|
%% The default is the standard behaviour in XEP-0114
|
||||||
Server = From#jid.lserver,
|
Server = From#jid.lserver,
|
||||||
dict:is_key(Server, HostOpts).
|
maps:is_key(Server, HostOpts).
|
||||||
|
|
||||||
random_password() ->
|
random_password() ->
|
||||||
str:sha(p1_rand:bytes(20)).
|
str:sha(p1_rand:bytes(20)).
|
||||||
|
@ -131,7 +131,7 @@ initialize(Host, Opts) ->
|
|||||||
UserAccess = case UserAccess0 of
|
UserAccess = case UserAccess0 of
|
||||||
[] -> none;
|
[] -> none;
|
||||||
_ ->
|
_ ->
|
||||||
dict:from_list(UserAccess0)
|
maps:from_list(UserAccess0)
|
||||||
end,
|
end,
|
||||||
ContentTypes = build_list_content_types(
|
ContentTypes = build_list_content_types(
|
||||||
mod_http_fileserver_opt:content_types(Opts),
|
mod_http_fileserver_opt:content_types(Opts),
|
||||||
@ -285,7 +285,7 @@ serve(LocalPath, Auth, DocRoot, DirectoryIndices, CustomHeaders, DefaultContentT
|
|||||||
CanProceed = case {UserAccess, Auth} of
|
CanProceed = case {UserAccess, Auth} of
|
||||||
{none, _} -> true;
|
{none, _} -> true;
|
||||||
{_, {User, Pass}} ->
|
{_, {User, Pass}} ->
|
||||||
case dict:find(User, UserAccess) of
|
case maps:find(User, UserAccess) of
|
||||||
{ok, Pass} -> true;
|
{ok, Pass} -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user