diff --git a/big_tests/tests/dynamic_domains_SUITE.erl b/big_tests/tests/dynamic_domains_SUITE.erl index 183846055a2..7093c59f8cf 100644 --- a/big_tests/tests/dynamic_domains_SUITE.erl +++ b/big_tests/tests/dynamic_domains_SUITE.erl @@ -39,7 +39,7 @@ end_per_suite(Config0) -> uncluster_nodes(?CLUSTER_NODES, Config). init_per_group(with_mod_dynamic_domains_test, Config) -> - MockedModules = [mod_dynamic_domains_test, ejabberd_router], + MockedModules = [mod_dynamic_domains_test, mongoose_router], [ok = rpc(mim(), meck, new, [Module, [passthrough, no_link]]) || Module <- MockedModules], dynamic_modules:start(?HOST_TYPE, mod_dynamic_domains_test, @@ -127,7 +127,7 @@ packet_handling_for_subdomain(Config) -> %% check that subdomain is not served after the parent domain removal remove_domains(?TEST_NODES, [NewDomain]), - rpc(mim(), meck, wait, [ejabberd_router, unregister_route, [NewSubdomain], 500]), + rpc(mim(), meck, wait, [mongoose_router, unregister_route, [NewSubdomain], 500]), IQ = escalus_stanza:iq(NewSubdomain, <<"get">>, [QueryEl]), escalus:send(Alice, IQ), Stanza = escalus:wait_for_stanza(Alice, 10000), @@ -157,7 +157,7 @@ iq_handling_for_domain(Config) -> %% check that domain is not served removal remove_domains(?TEST_NODES, [NewDomain]), - rpc(mim(), meck, wait, [ejabberd_router, unregister_route, [NewDomain], 500]), + rpc(mim(), meck, wait, [mongoose_router, unregister_route, [NewDomain], 500]), IQ = escalus_stanza:iq(NewDomain, <<"get">>, [QueryEl]), escalus:send(Alice, IQ), Stanza = escalus:wait_for_stanza(Alice, 10000), @@ -189,7 +189,7 @@ iq_handling_for_subdomain(Config) -> %% check that subdomain is not served after the parent domain removal remove_domains(?TEST_NODES, [NewDomain]), - rpc(mim(), meck, wait, [ejabberd_router, unregister_route, [NewSubdomain], 500]), + rpc(mim(), meck, wait, [mongoose_router, unregister_route, [NewSubdomain], 500]), IQ = escalus_stanza:iq(NewSubdomain, <<"get">>, [QueryEl]), escalus:send(Alice, IQ), Stanza = escalus:wait_for_stanza(Alice, 10000), diff --git a/big_tests/tests/push_SUITE.erl b/big_tests/tests/push_SUITE.erl index e1ced2f8a83..0da41965642 100644 --- a/big_tests/tests/push_SUITE.erl +++ b/big_tests/tests/push_SUITE.erl @@ -696,12 +696,12 @@ start_route_listener(Config) -> push_form_ns => push_helper:push_form_type() }, Handler = rpc(mongoose_packet_handler, new, [?MODULE, #{state => State}]), Domain = pubsub_domain(Config), - rpc(ejabberd_router, register_route, [Domain, Handler]), + rpc(mongoose_router, register_route, [Domain, Handler]), Config. stop_route_listener(Config) -> Domain = pubsub_domain(Config), - rpc(ejabberd_router, unregister_route, [Domain]). + rpc(mongoose_router, unregister_route, [Domain]). process_packet(_Acc, _From, To, El, #{state := State}) -> #{ pid := TestCasePid, pub_options_ns := PubOptionsNS, push_form_ns := PushFormNS } = State, diff --git a/src/config/mongoose_config_spec.erl b/src/config/mongoose_config_spec.erl index 27542f437e7..be7c5937e4f 100644 --- a/src/config/mongoose_config_spec.erl +++ b/src/config/mongoose_config_spec.erl @@ -230,7 +230,7 @@ general_defaults() -> <<"sm_backend">> => {mnesia, []}, <<"rdbms_server_type">> => generic, <<"mongooseimctl_access_commands">> => [], - <<"routing_modules">> => ejabberd_router:default_routing_modules(), + <<"routing_modules">> => mongoose_router:default_routing_modules(), <<"replaced_wait_timeout">> => 2000, <<"hide_service_name">> => false}. diff --git a/src/domain/mongoose_lazy_routing.erl b/src/domain/mongoose_lazy_routing.erl index 53460b206a1..673788102ce 100644 --- a/src/domain/mongoose_lazy_routing.erl +++ b/src/domain/mongoose_lazy_routing.erl @@ -363,7 +363,7 @@ add_subdomain(#{subdomain := Subdomain, host_type := HostType, IQs = get_iqs(#iq_table_key{host_type = HostType, subdomain_pattern = SubdomainPattern}), register_iqs(IQs, [SubdomainElement]), - ejabberd_router:register_route(Subdomain, PacketHandler); + mongoose_router:register_route(Subdomain, PacketHandler); false -> %% we should never get here, but it's ok to just ignore this. ok @@ -385,7 +385,7 @@ handle_maybe_remove_subdomain(#{subdomain := Subdomain, host_type := HostType, subdomain_pattern := SubdomainPattern}) -> case ets:lookup(?ROUTING_TABLE, Subdomain) of [{Domain, {HostType, SubdomainPattern}} = SubdomainElement] -> - ejabberd_router:unregister_route(Domain), + mongoose_router:unregister_route(Domain), IQs = get_iqs(#iq_table_key{host_type = HostType, subdomain_pattern = SubdomainPattern}), unregister_iqs(IQs, [SubdomainElement]), diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index c4d3318067e..9e1b2bf97b3 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -53,6 +53,7 @@ start(normal, _Args) -> mongoose_commands:init(), mongoose_service:start(), mongoose_config:start(), + mongoose_router:start(), mongoose_logs:set_global_loglevel(mongoose_config:get_opt(loglevel)), mongoose_deprecations:start(), {ok, _} = Sup = ejabberd_sup:start_link(), diff --git a/src/ejabberd_local.erl b/src/ejabberd_local.erl index 79419b6a4b9..88b5f9af6c4 100644 --- a/src/ejabberd_local.erl +++ b/src/ejabberd_local.erl @@ -467,7 +467,7 @@ cancel_timer(TRef) -> end. do_register_host(Host) -> - ejabberd_router:register_route(Host, mongoose_packet_handler:new(?MODULE)). + mongoose_router:register_route(Host, mongoose_packet_handler:new(?MODULE)). do_unregister_host(Host) -> - ejabberd_router:unregister_route(Host). + mongoose_router:unregister_route(Host). diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index cbeb9437788..0c73243322f 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -32,14 +32,7 @@ route/4, route_error/4, route_error_reply/4, - register_route/2, - register_routes/2, - unregister_route/1, - unregister_routes/1, - dirty_get_all_routes/0, - dirty_get_all_domains/0, - dirty_get_all_routes/1, - dirty_get_all_domains/1, + is_component_dirty/1, dirty_get_all_components/1, register_components/2, register_components/3, @@ -52,30 +45,26 @@ unregister_component/1, unregister_component/2, unregister_components/1, - unregister_components/2, - default_routing_modules/0 + unregister_components/2 ]). -export([start_link/0]). -export([routes_cleanup_on_nodedown/2]). %% gen_server callbacks --export([init/1, handle_call/3, handle_cast/2, handle_info/2, - terminate/2, code_change/3]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). %% debug exports for tests -export([update_tables/0]). --ignore_xref([dirty_get_all_domains/1, dirty_get_all_routes/0, dirty_get_all_routes/1, - register_component/2, register_component/3, register_component/4, - register_components/2, register_components/3, register_routes/2, +-ignore_xref([register_component/2, register_component/3, register_component/4, + register_components/2, register_components/3, route_error/4, routes_cleanup_on_nodedown/2, start_link/0, unregister_component/1, unregister_component/2, unregister_components/2, unregister_routes/1, update_tables/0]). -include("mongoose.hrl"). -include("jlib.hrl"). --include("route.hrl"). -include("external_component.hrl"). -record(state, {}). @@ -93,10 +82,6 @@ %%==================================================================== %% API %%==================================================================== -%%-------------------------------------------------------------------- -%% Description: Starts the server -%%-------------------------------------------------------------------- - -spec start_link() -> 'ignore' | {'error', _} | {'ok', pid()}. start_link() -> @@ -258,41 +243,23 @@ check_component(LDomain, Node) -> end. check_dynamic_domains(LDomain)-> - case mongoose_domain_api:get_host_type(LDomain) of - {error, not_found} -> false; - {ok, _} -> true - end. + {error, not_found} =/= mongoose_domain_api:get_host_type(LDomain). +%% check that route for this domain is not already registered check_component_route(LDomain) -> - %% check that route for this domain is not already registered - case mnesia:read(route, LDomain) of - [] -> - false; - _ -> - true - end. + no_route =/= mongoose_router:lookup_route(LDomain). +%% check that there is no local component for domain:node pair check_component_local(LDomain, Node) -> - %% check that there is no local component for domain:node pair NDomain = {LDomain, Node}, - case mnesia:read(external_component, NDomain) of - [] -> - false; - _ -> - true - end. + [] =/= mnesia:read(external_component, NDomain). +%% check that there is no component registered globally for this node check_component_global(LDomain, Node) -> - %% check that there is no component registered globally for this node - case get_global_component(LDomain, Node) of - undefined -> - false; - _ -> - true - end. + undefined =/= get_global_component(LDomain, Node). +%% Find a component registered globally for this node (internal use) get_global_component([], _) -> - %% Find a component registered globally for this node (internal use) undefined; get_global_component([Comp|Tail], Node) -> case Comp of @@ -340,77 +307,16 @@ unregister_component(Domain, Node) -> %% @doc Returns a list of components registered for this domain by any node, %% the choice is yours. --spec lookup_component(Domain :: domain()) -> [external_component()]. +-spec lookup_component(Domain :: jid:lserver()) -> [external_component()]. lookup_component(Domain) -> mnesia:dirty_read(external_component_global, Domain). %% @doc Returns a list of components registered for this domain at the given node. %% (must be only one, or nothing) --spec lookup_component(Domain :: domain(), Node :: node()) -> [external_component()]. +-spec lookup_component(Domain :: jid:lserver(), Node :: node()) -> [external_component()]. lookup_component(Domain, Node) -> mnesia:dirty_read(external_component, {Domain, Node}). --spec register_route(Domain :: domain(), - Handler :: mongoose_packet_handler:t()) -> any(). -register_route(Domain, Handler) -> - register_route_to_ldomain(jid:nameprep(Domain), Domain, Handler). - --spec register_routes([domain()], mongoose_packet_handler:t()) -> 'ok'. -register_routes(Domains, Handler) -> - lists:foreach(fun(Domain) -> - register_route(Domain, Handler) - end, - Domains). - --spec register_route_to_ldomain(binary(), domain(), mongoose_packet_handler:t()) -> any(). -register_route_to_ldomain(error, Domain, _) -> - erlang:error({invalid_domain, Domain}); -register_route_to_ldomain(LDomain, _, Handler) -> - mnesia:dirty_write(#route{domain = LDomain, handler = Handler}), - % No support for hidden routes yet - mongoose_hooks:register_subhost(LDomain, false). - -unregister_route(Domain) -> - case jid:nameprep(Domain) of - error -> - erlang:error({invalid_domain, Domain}); - LDomain -> - mnesia:dirty_delete(route, LDomain), - mongoose_hooks:unregister_subhost(LDomain) - end. - -unregister_routes(Domains) -> - lists:foreach(fun(Domain) -> - unregister_route(Domain) - end, - Domains). - - --spec dirty_get_all_routes() -> [jid:lserver()]. -dirty_get_all_routes() -> - dirty_get_all_routes(all). - --spec dirty_get_all_domains() -> [jid:lserver()]. -dirty_get_all_domains() -> - dirty_get_all_domains(all). - --spec dirty_get_all_routes(return_hidden()) -> [jid:lserver()]. -dirty_get_all_routes(ReturnHidden) -> - lists:usort(all_routes(ReturnHidden)) -- ?MYHOSTS. - --spec dirty_get_all_domains(return_hidden()) -> [jid:lserver()]. -dirty_get_all_domains(ReturnHidden) -> - lists:usort(all_routes(ReturnHidden)). - --spec all_routes(return_hidden()) -> [jid:lserver()]. -all_routes(all) -> - mnesia:dirty_all_keys(route) ++ mnesia:dirty_all_keys(external_component_global); -all_routes(only_public) -> - MatchNonHidden = {#external_component{ domain = '$1', is_hidden = false, _ = '_' }, [], ['$1']}, - mnesia:dirty_all_keys(route) - ++ - mnesia:dirty_select(external_component_global, [MatchNonHidden]). - -spec dirty_get_all_components(return_hidden()) -> [jid:lserver()]. dirty_get_all_components(all) -> mnesia:dirty_all_keys(external_component_global); @@ -418,24 +324,16 @@ dirty_get_all_components(only_public) -> MatchNonHidden = {#external_component{ domain = '$1', is_hidden = false, _ = '_' }, [], ['$1']}, mnesia:dirty_select(external_component_global, [MatchNonHidden]). +-spec is_component_dirty(jid:lserver()) -> boolean(). +is_component_dirty(Domain) -> + [] =/= lookup_component(Domain). %%==================================================================== %% gen_server callbacks %%==================================================================== -%%-------------------------------------------------------------------- -%% Function: init(Args) -> {ok, State} | -%% {ok, State, Timeout} | -%% ignore | -%% {stop, Reason} -%% Description: Initiates the server -%%-------------------------------------------------------------------- init([]) -> update_tables(), - mnesia:create_table(route, - [{attributes, record_info(fields, route)}, - {local_content, true}]), - mnesia:add_table_copy(route, node(), ram_copies), %% add distributed service_component routes mnesia:create_table(external_component, @@ -452,74 +350,29 @@ init([]) -> {ok, #state{}}. -%%-------------------------------------------------------------------- -%% Function: handle_call(Request, From, State) -%% -> {reply, Reply, State} | -%% {reply, Reply, State, Timeout} | -%% {noreply, State} | -%% {noreply, State, Timeout} | -%% {stop, Reason, Reply, State} | -%% {stop, Reason, State} -%% Description: Handling call messages -%%-------------------------------------------------------------------- handle_call(_Request, _From, State) -> Reply = ok, {reply, Reply, State}. -%%-------------------------------------------------------------------- -%% Function: handle_cast(Msg, State) -> {noreply, State} | -%% {noreply, State, Timeout} | -%% {stop, Reason, State} -%% Description: Handling cast messages -%%-------------------------------------------------------------------- handle_cast(_Msg, State) -> {noreply, State}. -%%-------------------------------------------------------------------- -%% Function: handle_info(Info, State) -> {noreply, State} | -%% {noreply, State, Timeout} | -%% {stop, Reason, State} -%% Description: Handling all non call/cast messages -%%-------------------------------------------------------------------- -handle_info({route, From, To, Packet}, State) -> - route(From, To, Packet), - {noreply, State}; handle_info(_Info, State) -> {noreply, State}. -%%-------------------------------------------------------------------- -%% Function: terminate(Reason, State) -> void() -%% Description: This function is called by a gen_server when it is about to -%% terminate. It should be the opposite of Module:init/1 and do any necessary -%% cleaning up. When it returns, the gen_server terminates with Reason. -%% The return value is ignored. -%%-------------------------------------------------------------------- terminate(_Reason, _State) -> ejabberd_hooks:delete(node_cleanup, global, ?MODULE, routes_cleanup_on_nodedown, 90), ok. -%%-------------------------------------------------------------------- -%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState} -%% Description: Convert process state when code is changed -%%-------------------------------------------------------------------- code_change(_OldVsn, State, _Extra) -> {ok, State}. %%-------------------------------------------------------------------- %%% Internal functions %%-------------------------------------------------------------------- - routing_modules_list() -> mongoose_config:get_opt(routing_modules). -default_routing_modules() -> - [mongoose_router_global, - mongoose_router_localdomain, - mongoose_router_external_localnode, - mongoose_router_external, - mongoose_router_dynamic_domains, - ejabberd_s2s]. - -spec route(From :: jid:jid(), To :: jid:jid(), Acc :: mongoose_acc:t(), @@ -554,24 +407,6 @@ route(OrigFrom, OrigTo, Acc0, OrigPacket, [M|Tail]) -> end. update_tables() -> - case catch mnesia:table_info(route, attributes) of - [domain, node, pid] -> - mnesia:delete_table(route); - [domain, pid] -> - mnesia:delete_table(route); - [domain, pid, local_hint] -> - mnesia:delete_table(route); - [domain, handler] -> - ok; - {'EXIT', _} -> - ok - end, - case lists:member(local_route, mnesia:system_info(tables)) of - true -> - mnesia:delete_table(local_route); - false -> - ok - end, case catch mnesia:table_info(external_component, attributes) of [domain, handler, node] -> mnesia:delete_table(external_component); diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index 828ef21e03d..79a7c9bce8c 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -311,7 +311,8 @@ stream_established({xmlstreamelement, El}, StateData) -> %% Checks if the from domain is allowed and if the to %% domain is handled by this server: case {ejabberd_s2s:allow_host(LTo, LFrom), - lists:member(LTo, ejabberd_router:dirty_get_all_domains())} of + mongoose_router:is_registered_route(LTo) + orelse ejabberd_router:is_component_dirty(LTo)} of {true, true} -> ejabberd_s2s_out:terminate_if_waiting_delay(LTo, LFrom), ejabberd_s2s_out:start(LTo, LFrom, @@ -426,7 +427,8 @@ route_incoming_stanza(From, To, El, StateData) -> is_s2s_authenticated(_, _, #state{authenticated = false}) -> false; is_s2s_authenticated(LFrom, LTo, #state{auth_domain = LFrom}) -> - lists:member(LTo, ejabberd_router:dirty_get_all_domains()); + mongoose_router:is_registered_route(LTo) + orelse ejabberd_router:is_component_dirty(LTo); is_s2s_authenticated(_, _, _) -> false. diff --git a/src/mongoose_router.erl b/src/mongoose_router.erl new file mode 100644 index 00000000000..8c9c7979a4b --- /dev/null +++ b/src/mongoose_router.erl @@ -0,0 +1,57 @@ +-module(mongoose_router). + +-define(TABLE, ?MODULE). + +-export([start/0, default_routing_modules/0]). + +-export([get_all_domains/0, lookup_route/1, is_registered_route/1, + register_route/2, unregister_route/1]). + +-spec get_all_domains() -> [jid:lserver()]. +get_all_domains() -> + ets:select(?TABLE, [{{'$1', '_'}, [], ['$1']}]). + +-spec lookup_route(jid:lserver()) -> no_route | mongoose_packet_handler:t(). +lookup_route(LDomain) -> + case ets:lookup(?TABLE, LDomain) of + [] -> no_route; + [{_, Handler}] -> + Handler + end. + +-spec register_route(jid:server(), mongoose_packet_handler:t()) -> any(). +register_route(Domain, Handler) -> + case jid:nameprep(Domain) of + error -> + {error, invalid_domain, Domain}; + LDomain -> + ets:insert(?TABLE, {LDomain, Handler}), + mongoose_hooks:register_subhost(LDomain, false) + end. + +-spec unregister_route(jid:server()) -> any(). +unregister_route(Domain) -> + case jid:nameprep(Domain) of + error -> + {error, invalid_domain, Domain}; + LDomain -> + ets:delete(?TABLE, LDomain), + mongoose_hooks:unregister_subhost(LDomain) + end. + +-spec is_registered_route(jid:lserver()) -> boolean(). +is_registered_route(LDomain) -> + ets:member(?TABLE, LDomain). + +%% start/stop +start() -> + ets:new(?TABLE, [named_table, public, set, {read_concurrency, true}]), + mongoose_metrics:ensure_metric(global, routingErrors, spiral). + +default_routing_modules() -> + [mongoose_router_global, + mongoose_router_localdomain, + mongoose_router_external_localnode, + mongoose_router_external, + mongoose_router_dynamic_domains, + ejabberd_s2s]. diff --git a/src/mongoose_router_localdomain.erl b/src/mongoose_router_localdomain.erl index 5215f3e7b49..b41659297e8 100644 --- a/src/mongoose_router_localdomain.erl +++ b/src/mongoose_router_localdomain.erl @@ -10,9 +10,7 @@ -behaviour(xmpp_router). -include("jlib.hrl"). --include("route.hrl"). -%% API %% xmpp_router callback -export([filter/4, route/4]). @@ -21,9 +19,9 @@ filter(From, To, Acc, Packet) -> route(From, To, Acc0, Packet) -> LDstDomain = To#jid.lserver, - case mnesia:dirty_read(route, LDstDomain) of - [] -> {From, To, Acc0, Packet}; - [#route{handler = Handler}] -> + case mongoose_router:lookup_route(LDstDomain) of + no_route -> {From, To, Acc0, Packet}; + Handler -> Acc1 = mongoose_local_delivery:do_route(From, To, Acc0, Packet, Handler), {done, Acc1} end. diff --git a/src/system_metrics/mongoose_system_metrics_collector.erl b/src/system_metrics/mongoose_system_metrics_collector.erl index 5a01b14e4cb..fa659b8b490 100644 --- a/src/system_metrics/mongoose_system_metrics_collector.erl +++ b/src/system_metrics/mongoose_system_metrics_collector.erl @@ -116,7 +116,7 @@ get_version() -> end. get_components() -> - Domains = ejabberd_router:dirty_get_all_domains(), + Domains = mongoose_router:get_all_domains() ++ ejabberd_router:dirty_get_all_components(all), Components = [ejabberd_router:lookup_component(D, node()) || D <- Domains], LenComponents = length(lists:flatten(Components)), #{report_name => cluster, key => number_of_components, value => LenComponents}. diff --git a/test/component_reg_SUITE.erl b/test/component_reg_SUITE.erl index c8ead535ee1..0f045c14fb6 100644 --- a/test/component_reg_SUITE.erl +++ b/test/component_reg_SUITE.erl @@ -23,6 +23,7 @@ init_per_suite(C) -> C. init_per_testcase(_, C) -> + mongoose_router:start(), gen_hook:start_link(), C. diff --git a/test/config_parser_SUITE.erl b/test/config_parser_SUITE.erl index fce8ec3ae53..3e66f8651a9 100644 --- a/test/config_parser_SUITE.erl +++ b/test/config_parser_SUITE.erl @@ -435,7 +435,7 @@ mongooseimctl_access_commands(_Config) -> [<<"none">>]}}}}). routing_modules(_Config) -> - ?cfg(routing_modules, ejabberd_router:default_routing_modules(), #{}), % default + ?cfg(routing_modules, mongoose_router:default_routing_modules(), #{}), % default ?cfg(routing_modules, [mongoose_router_global, mongoose_router_localdomain], #{<<"general">> => #{<<"routing_modules">> => [<<"mongoose_router_global">>, <<"mongoose_router_localdomain">>]}}), diff --git a/test/config_parser_helper.erl b/test/config_parser_helper.erl index 7613cf1a425..4b680a66684 100644 --- a/test/config_parser_helper.erl +++ b/test/config_parser_helper.erl @@ -20,7 +20,7 @@ options("host_types") -> {mongooseimctl_access_commands, []}, {rdbms_server_type, generic}, {registration_timeout, 600}, - {routing_modules, ejabberd_router:default_routing_modules()}, + {routing_modules, mongoose_router:default_routing_modules()}, {sm_backend, {mnesia, []}}, {{auth, <<"another host type">>}, auth_with_methods(#{})}, {{auth, <<"localhost">>}, @@ -98,7 +98,7 @@ options("modules") -> {mongooseimctl_access_commands, []}, {rdbms_server_type, generic}, {registration_timeout, 600}, - {routing_modules, ejabberd_router:default_routing_modules()}, + {routing_modules, mongoose_router:default_routing_modules()}, {sm_backend, {mnesia, []}}, {{auth, <<"dummy_host">>}, default_auth()}, {{auth, <<"localhost">>}, default_auth()}, @@ -230,7 +230,7 @@ options("mongooseim-pgsql") -> {outgoing_s2s_port, 5299}, {rdbms_server_type, generic}, {registration_timeout, infinity}, - {routing_modules, ejabberd_router:default_routing_modules()}, + {routing_modules, mongoose_router:default_routing_modules()}, {s2s_certfile, "tools/ssl/mongooseim/server.pem"}, {s2s_use_starttls, optional}, {services, @@ -354,7 +354,7 @@ options("outgoing_pools") -> {cacertfile, "path/to/cacert.pem"}]}]}, {rdbms_server_type, generic}, {registration_timeout, 600}, - {routing_modules, ejabberd_router:default_routing_modules()}, + {routing_modules, mongoose_router:default_routing_modules()}, {sm_backend, {mnesia, []}}, {{auth, <<"anonymous.localhost">>}, default_auth()}, {{auth, <<"localhost">>}, default_auth()}, @@ -380,7 +380,7 @@ options("s2s_only") -> {outgoing_s2s_timeout, 10000}, {rdbms_server_type, generic}, {registration_timeout, 600}, - {routing_modules, ejabberd_router:default_routing_modules()}, + {routing_modules, mongoose_router:default_routing_modules()}, {s2s_certfile, "tools/ssl/mongooseim/server.pem"}, {s2s_ciphers, "TLSv1.2:TLSv1.3"}, {s2s_dns_options, [{retries, 1}, {timeout, 30}]}, diff --git a/test/mongoose_config_SUITE.erl b/test/mongoose_config_SUITE.erl index 0fbd65a669a..77b3c3b5740 100644 --- a/test/mongoose_config_SUITE.erl +++ b/test/mongoose_config_SUITE.erl @@ -127,7 +127,7 @@ minimal_config_opts() -> {mongooseimctl_access_commands, []}, {rdbms_server_type, generic}, {registration_timeout, 600}, - {routing_modules, ejabberd_router:default_routing_modules()}, + {routing_modules, mongoose_router:default_routing_modules()}, {sm_backend, {mnesia, []}}, {{auth, <<"localhost">>}, config_parser_helper:default_auth()}, {{modules, <<"localhost">>}, #{}}, diff --git a/test/mongoose_lazy_routing_SUITE.erl b/test/mongoose_lazy_routing_SUITE.erl index b164c51bb33..52a5219e065 100644 --- a/test/mongoose_lazy_routing_SUITE.erl +++ b/test/mongoose_lazy_routing_SUITE.erl @@ -75,7 +75,7 @@ can_add_and_remove_domain_or_subdomain(_Config) -> get_all_registered_subdomains()), ?assertEqual([], get_all_unregistered_domains()), ?assertEqual([], get_all_unregistered_subdomains()), - [meck:reset(M) || M <- [ejabberd_local, ejabberd_router]], + [meck:reset(M) || M <- [ejabberd_local, mongoose_router]], %% remove 2 domains, one of them remove twice maybe_remove_domain(domain_host_type(?DOMAIN_1), ?DOMAIN_1), maybe_remove_domain(domain_host_type(?DOMAIN_2), ?DOMAIN_2), @@ -112,7 +112,7 @@ registers_top_level_domain_in_case_domain_subdomain_conflicts(_Config) -> ?assertEqualLists([], get_all_registered_subdomains()), ?assertEqual([], get_all_unregistered_domains()), ?assertEqual([], get_all_unregistered_subdomains()), - [meck:reset(M) || M <- [ejabberd_local, ejabberd_router]], + [meck:reset(M) || M <- [ejabberd_local, mongoose_router]], %% try to remove that domain and subdomain maybe_remove_domain(domain_host_type(?DOMAIN_X), ?DOMAIN_X), maybe_remove_subdomain(subdomain_info(?DOMAIN_X)), @@ -353,14 +353,14 @@ handles_double_iq_handler_registration_deregistration_for_subdomain(_Config) -> %% internal functions %%------------------------------------------------------------------- setup_meck() -> - Modules = [ejabberd_local, ejabberd_router, gen_iq_component, + Modules = [ejabberd_local, mongoose_router, gen_iq_component, mongoose_domain_core, mongoose_subdomain_core], [meck:new(M, [no_link]) || M <- Modules], meck:new(mongoose_lazy_routing, [no_link, passthrough]), meck:expect(ejabberd_local, register_host, fun(_) -> ok end), meck:expect(ejabberd_local, unregister_host, fun(_) -> ok end), - meck:expect(ejabberd_router, unregister_route, fun(_) -> ok end), - meck:expect(ejabberd_router, register_route, fun(_, _) -> ok end), + meck:expect(mongoose_router, unregister_route, fun(_) -> ok end), + meck:expect(mongoose_router, register_route, fun(_, _) -> ok end), meck:expect(gen_iq_component, register_iq_handler, fun(_, _, _, _) -> ok end), meck:expect(gen_iq_component, sync, fun(_) -> ok end), meck:expect(gen_iq_component, unregister_iq_handler, fun(_, _, _) -> ok end), @@ -450,13 +450,13 @@ get_all_unregistered_domains() -> Func =:= unregister_host]. get_all_registered_subdomains() -> - History = meck:history(ejabberd_router), + History = meck:history(mongoose_router), [{Subdomain, PacketHandler} || {_Pid, {_Mod, Func, [Subdomain, PacketHandler] = _Args}, _Result} <- History, Func =:= register_route]. get_all_unregistered_subdomains() -> - History = meck:history(ejabberd_router), + History = meck:history(mongoose_router), [Subdomain || {_Pid, {_Mod, Func, [Subdomain] = _Args}, _Result} <- History, Func =:= unregister_route].