mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Ensure the default virtual host "localhost" is defined and is the first
This commit is contained in:
parent
d4316558de
commit
fa9b8d63f9
@ -167,7 +167,8 @@ search_hosts(Term, State) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
add_hosts_to_option(Hosts, State) ->
|
add_hosts_to_option(Hosts, State) ->
|
||||||
PrepHosts = normalize_hosts(Hosts),
|
PrepHosts1 = normalize_hosts(Hosts),
|
||||||
|
PrepHosts = ensure_localhost_is_first(PrepHosts1),
|
||||||
mnesia:transaction(
|
mnesia:transaction(
|
||||||
fun() ->
|
fun() ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
@ -193,6 +194,17 @@ normalize_hosts([Host|Hosts], PrepHosts) ->
|
|||||||
exit("invalid hostname")
|
exit("invalid hostname")
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
ensure_localhost_is_first(["localhost" | _] = Hosts) ->
|
||||||
|
Hosts;
|
||||||
|
ensure_localhost_is_first(Hosts) ->
|
||||||
|
case lists:member("localhost", Hosts) of
|
||||||
|
true ->
|
||||||
|
["localhost" | lists:delete("localhost", Hosts)];
|
||||||
|
false ->
|
||||||
|
?INFO_MSG("ejabberd added the default virtual host \"localhost\""
|
||||||
|
"to the list of hosts.", []),
|
||||||
|
["localhost" | Hosts]
|
||||||
|
end.
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%%% Errors reading the config file
|
%%% Errors reading the config file
|
||||||
@ -628,6 +640,8 @@ get_global_option({Opt1, Host} = Opt) when is_list(Host) ->
|
|||||||
end;
|
end;
|
||||||
get_global_option(Opt) ->
|
get_global_option(Opt) ->
|
||||||
case ets:lookup(config, Opt) of
|
case ets:lookup(config, Opt) of
|
||||||
|
[#config{value = Val}] when Opt == hosts ->
|
||||||
|
ensure_localhost_is_first(Val);
|
||||||
[#config{value = Val}] ->
|
[#config{value = Val}] ->
|
||||||
Val;
|
Val;
|
||||||
_ ->
|
_ ->
|
||||||
|
Loading…
Reference in New Issue
Block a user