diff --git a/include/mod_antispam.hrl b/include/mod_antispam.hrl new file mode 100644 index 000000000..7f681046e --- /dev/null +++ b/include/mod_antispam.hrl @@ -0,0 +1,26 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2025 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + +-define(MODULE_ANTISPAM, mod_antispam). + +-type url() :: binary(). +-type filename() :: binary() | none | false. +-type jid_set() :: sets:set(ljid()). +-type url_set() :: sets:set(url()). diff --git a/src/mod_antispam.erl b/src/mod_antispam.erl index ef2106219..a48f7235c 100644 --- a/src/mod_antispam.erl +++ b/src/mod_antispam.erl @@ -63,15 +63,11 @@ -include("ejabberd_commands.hrl"). -include("logger.hrl"). +-include("mod_antispam.hrl"). -include("translate.hrl"). -include_lib("xmpp/include/xmpp.hrl"). --type url() :: binary(). --type filename() :: binary() | none | false. --type jid_set() :: sets:set(ljid()). --type url_set() :: sets:set(url()). - -record(state, {host = <<>> :: binary(), dump_fd = undefined :: file:io_device() | undefined, diff --git a/src/mod_antispam_dump.erl b/src/mod_antispam_dump.erl index 04a671f05..f92ac0bf1 100644 --- a/src/mod_antispam_dump.erl +++ b/src/mod_antispam_dump.erl @@ -38,14 +38,11 @@ -export([dump_spam_stanza/1, reopen_log/0]). -include("logger.hrl"). +-include("mod_antispam.hrl"). -include("translate.hrl"). -include_lib("xmpp/include/xmpp.hrl"). --type filename() :: binary() | none | false. - --define(MODULE_PARENT, mod_antispam). - %%-------------------------------------------------------------------- %%| Exported @@ -157,7 +154,7 @@ write_stanza_dump(Fd, XML) -> %%| Auxiliary get_path_option(Host) -> - Opts = gen_mod:get_module_opts(Host, ?MODULE_PARENT), + Opts = gen_mod:get_module_opts(Host, ?MODULE_ANTISPAM), get_path_option(Host, Opts). get_path_option(Host, Opts) -> @@ -178,11 +175,11 @@ get_path_option(Host, Opts) -> -spec get_proc_name(binary()) -> atom(). get_proc_name(Host) -> - gen_mod:get_module_proc(Host, ?MODULE_PARENT). + gen_mod:get_module_proc(Host, ?MODULE_ANTISPAM). -spec get_spam_filter_hosts() -> [binary()]. get_spam_filter_hosts() -> - [H || H <- ejabberd_option:hosts(), gen_mod:is_loaded(H, ?MODULE_PARENT)]. + [H || H <- ejabberd_option:hosts(), gen_mod:is_loaded(H, ?MODULE_ANTISPAM)]. %%-------------------------------------------------------------------- diff --git a/src/mod_antispam_filter.erl b/src/mod_antispam_filter.erl index 9fd8abf36..7367c2ba8 100644 --- a/src/mod_antispam_filter.erl +++ b/src/mod_antispam_filter.erl @@ -38,13 +38,12 @@ -include("logger.hrl"). -include("translate.hrl"). +-include("mod_antispam.hrl"). -include_lib("xmpp/include/xmpp.hrl"). --type url() :: binary(). -type s2s_in_state() :: ejabberd_s2s_in:state(). --define(MODULE_PARENT, mod_antispam). -define(HTTPC_TIMEOUT, timer:seconds(3)). %%-------------------------------------------------------------------- @@ -128,9 +127,9 @@ s2s_in_handle_info(State, _) -> -spec needs_checking(jid(), jid()) -> boolean(). needs_checking(#jid{lserver = FromHost} = From, #jid{lserver = LServer} = To) -> - case gen_mod:is_loaded(LServer, ?MODULE_PARENT) of + case gen_mod:is_loaded(LServer, ?MODULE_ANTISPAM) of true -> - Access = gen_mod:get_module_opt(LServer, ?MODULE_PARENT, access_spam), + Access = gen_mod:get_module_opt(LServer, ?MODULE_ANTISPAM, access_spam), case acl:match_rule(LServer, Access, To) of allow -> ?DEBUG("Spam not filtered for ~s", [jid:encode(To)]), @@ -144,7 +143,7 @@ needs_checking(#jid{lserver = FromHost} = From, #jid{lserver = LServer} = To) -> To) % likely a gateway end; false -> - ?DEBUG("~s not loaded for ~s", [?MODULE_PARENT, LServer]), + ?DEBUG("~s not loaded for ~s", [?MODULE_ANTISPAM, LServer]), false end. @@ -292,7 +291,7 @@ reject(_) -> -spec get_proc_name(binary()) -> atom(). get_proc_name(Host) -> - gen_mod:get_module_proc(Host, ?MODULE_PARENT). + gen_mod:get_module_proc(Host, ?MODULE_ANTISPAM). %%-------------------------------------------------------------------- diff --git a/src/mod_antispam_rtbl.erl b/src/mod_antispam_rtbl.erl index 93b346631..246b59dfa 100644 --- a/src/mod_antispam_rtbl.erl +++ b/src/mod_antispam_rtbl.erl @@ -27,6 +27,7 @@ -include_lib("xmpp/include/xmpp.hrl"). -include("logger.hrl"). +-include("mod_antispam.hrl"). -define(SERVICE_MODULE, mod_antispam). -define(SERVICE_JID_PREFIX, "rtbl-").