From 11811e5f48e94c7bac37e87384a4c9a319f92d29 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Fri, 6 Jul 2018 09:18:27 +0300 Subject: [PATCH] Only lookup FQDN at configuration (re)loading --- rebar.config | 2 +- src/ejabberd_config.erl | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rebar.config b/rebar.config index 35dfb3553..7c77b6561 100644 --- a/rebar.config +++ b/rebar.config @@ -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"}}}, diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 5dcb24711..a31651430 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -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() ->