mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Fix ejabberd_router:is_my_route/1
This commit is contained in:
parent
5f1f126613
commit
d110cbb6e2
@ -268,7 +268,7 @@ is_my_route(Domain) ->
|
||||
error ->
|
||||
erlang:error({invalid_domain, Domain});
|
||||
LDomain ->
|
||||
lists:member(LDomain, get_all_routes())
|
||||
find_routes(LDomain) /= []
|
||||
end.
|
||||
|
||||
-spec is_my_host(binary()) -> boolean().
|
||||
|
@ -38,6 +38,7 @@
|
||||
-record(state, {}).
|
||||
|
||||
-define(ROUTES_KEY, <<"ejabberd:routes">>).
|
||||
-define(DOMAINS_KEY, <<"ejabberd:domains">>).
|
||||
|
||||
%%%===================================================================
|
||||
%%% API
|
||||
@ -61,7 +62,12 @@ register_route(Domain, ServerHost, LocalHint, _, Pid) ->
|
||||
case ejabberd_redis:multi(
|
||||
fun() ->
|
||||
ejabberd_redis:hset(DomKey, PidKey, T),
|
||||
ejabberd_redis:sadd(?ROUTES_KEY, [Domain])
|
||||
ejabberd_redis:sadd(?DOMAINS_KEY, [Domain]),
|
||||
if Domain /= ServerHost ->
|
||||
ejabberd_redis:sadd(?ROUTES_KEY, [Domain]);
|
||||
true ->
|
||||
ok
|
||||
end
|
||||
end) of
|
||||
{ok, _} ->
|
||||
ok;
|
||||
@ -80,7 +86,8 @@ unregister_route(Domain, _, Pid) ->
|
||||
{ok, _} = ejabberd_redis:multi(
|
||||
fun() ->
|
||||
ejabberd_redis:del([DomKey]),
|
||||
ejabberd_redis:srem(?ROUTES_KEY, [Domain])
|
||||
ejabberd_redis:srem(?ROUTES_KEY, [Domain]),
|
||||
ejabberd_redis:srem(?DOMAINS_KEY, [Domain])
|
||||
end),
|
||||
ok;
|
||||
true ->
|
||||
@ -110,6 +117,14 @@ get_all_routes() ->
|
||||
{error, db_failure}
|
||||
end.
|
||||
|
||||
get_all_domains() ->
|
||||
case ejabberd_redis:smembers(?DOMAINS_KEY) of
|
||||
{ok, Domains} ->
|
||||
{ok, Domains};
|
||||
_ ->
|
||||
{error, db_failure}
|
||||
end.
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
@ -147,7 +162,7 @@ clean_table() ->
|
||||
end, find_routes()).
|
||||
|
||||
find_routes() ->
|
||||
case get_all_routes() of
|
||||
case get_all_domains() of
|
||||
{ok, Domains} ->
|
||||
lists:flatmap(
|
||||
fun(Domain) ->
|
||||
|
Loading…
Reference in New Issue
Block a user