aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2010-08-05 22:19:41 +0200
committerBadlop <badlop@process-one.net>2010-08-05 22:19:41 +0200
commitfa9b8d63f95d6459849e69b3d4c0575f1ba89361 (patch)
tree599971fc75310d1ef62f3a8361d9151fb3c19ec2
parentWhen an obsolete ODBC module is starting, switch to the normal one (diff)
Ensure the default virtual host "localhost" is defined and is the first
-rw-r--r--src/ejabberd_config.erl16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl
index 1cbc2352d..76e69c4d2 100644
--- a/src/ejabberd_config.erl
+++ b/src/ejabberd_config.erl
@@ -167,7 +167,8 @@ search_hosts(Term, State) ->
end.
add_hosts_to_option(Hosts, State) ->
- PrepHosts = normalize_hosts(Hosts),
+ PrepHosts1 = normalize_hosts(Hosts),
+ PrepHosts = ensure_localhost_is_first(PrepHosts1),
mnesia:transaction(
fun() ->
lists:foreach(
@@ -193,6 +194,17 @@ normalize_hosts([Host|Hosts], PrepHosts) ->
exit("invalid hostname")
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
@@ -628,6 +640,8 @@ get_global_option({Opt1, Host} = Opt) when is_list(Host) ->
end;
get_global_option(Opt) ->
case ets:lookup(config, Opt) of
+ [#config{value = Val}] when Opt == hosts ->
+ ensure_localhost_is_first(Val);
[#config{value = Val}] ->
Val;
_ ->