Only lookup FQDN at configuration (re)loading

This commit is contained in:
Evgeniy Khramtsov 2018-07-06 09:18:27 +03:00
parent 0bb14d16c7
commit 11811e5f48
2 changed files with 14 additions and 2 deletions

View File

@ -25,7 +25,7 @@
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.23"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.12"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.32"}}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "2a5193c"}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "64fbddd"}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.15"}}},
{jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}},
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.3"}}},

View File

@ -57,6 +57,7 @@
-include("logger.hrl").
-include("ejabberd_config.hrl").
-include_lib("kernel/include/file.hrl").
-include_lib("kernel/include/inet.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-callback opt_type(atom()) -> function() | [atom()].
@ -786,7 +787,18 @@ set_opts(State) ->
set_log_level().
set_fqdn() ->
FQDNs = get_option(fqdn, []),
FQDNs = case get_option(fqdn, []) of
[] ->
{ok, Hostname} = inet:gethostname(),
case inet:gethostbyname(Hostname) of
{ok, #hostent{h_name = FQDN}} ->
[iolist_to_binary(FQDN)];
{error, _} ->
[]
end;
Domains ->
Domains
end,
xmpp:set_config([{fqdn, FQDNs}]).
set_log_level() ->