From 311bf4dbb1083bdf05fa9bb80cdb268b22fac057 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Fri, 13 Nov 2009 16:19:46 +0000 Subject: [PATCH] fixes allow_host/2 on subdomains. added hook s2s_allow_host: the hook should return deny or allow SVN Revision: 2738 --- src/ejabberd_s2s.erl | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/ejabberd_s2s.erl b/src/ejabberd_s2s.erl index d1c6303b7..02b2f8d16 100644 --- a/src/ejabberd_s2s.erl +++ b/src/ejabberd_s2s.erl @@ -486,15 +486,31 @@ update_tables() -> %% Check if host is in blacklist or white list allow_host(MyServer, S2SHost) -> - case ejabberd_config:get_local_option({{s2s_host, S2SHost},MyServer}) of - deny -> false; - allow -> true; - _ -> - case ejabberd_config:get_local_option({s2s_default_policy, MyServer}) of - deny -> false; - allow -> true; - _ -> true %% The default s2s policy is allow - end + case lists:filter( + fun(Host) -> + is_subdomain(MyServer, Host) + end, ?MYHOSTS) of + [MyHost|_] -> + allow_host1(MyHost, S2SHost); + [] -> + allow_host1(MyServer, S2SHost) + end. + +allow_host1(MyHost, S2SHost) -> + case ejabberd_config:get_local_option({{s2s_host, S2SHost}, MyHost}) of + deny -> false; + allow -> true; + _ -> + case ejabberd_config:get_local_option({s2s_default_policy, MyHost}) of + deny -> false; + _ -> + case ejabberd_hooks:run_fold(s2s_allow_host, MyHost, + allow, [MyHost, S2SHost]) of + deny -> false; + allow -> true; + _ -> true + end + end end. %% Get information about S2S connections of the specified type.