mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Introduce 'access' option for mod_block_stranger
The option is supposed to be used when `allow_local_users` and `allow_transports` are not enough. It's an ACL where `deny` means the message will be rejected (or a CAPTCHA would be generated for a presence), and `allow` means the sender is whitelisted and the stanza will pass through. The default value is `none`, which means nothing is whitelisted.
This commit is contained in:
parent
cffdb06b66
commit
5704a980c5
@ -199,7 +199,9 @@ need_check(Pkt) ->
|
|||||||
false
|
false
|
||||||
end,
|
end,
|
||||||
AllowLocalUsers = gen_mod:get_module_opt(LServer, ?MODULE, allow_local_users),
|
AllowLocalUsers = gen_mod:get_module_opt(LServer, ?MODULE, allow_local_users),
|
||||||
not (IsEmpty orelse ((AllowLocalUsers orelse From#jid.luser == <<"">>)
|
Access = gen_mod:get_module_opt(LServer, ?MODULE, access),
|
||||||
|
not (IsEmpty orelse acl:match_rule(LServer, Access, From) == allow
|
||||||
|
orelse ((AllowLocalUsers orelse From#jid.luser == <<"">>)
|
||||||
andalso ejabberd_router:is_my_host(From#jid.lserver))).
|
andalso ejabberd_router:is_my_host(From#jid.lserver))).
|
||||||
|
|
||||||
-spec check_subscription(jid(), jid()) -> boolean().
|
-spec check_subscription(jid(), jid()) -> boolean().
|
||||||
@ -265,10 +267,14 @@ mod_opt_type(allow_local_users) ->
|
|||||||
mod_opt_type(allow_transports) ->
|
mod_opt_type(allow_transports) ->
|
||||||
fun (B) when is_boolean(B) -> B end;
|
fun (B) when is_boolean(B) -> B end;
|
||||||
mod_opt_type(captcha) ->
|
mod_opt_type(captcha) ->
|
||||||
fun (B) when is_boolean(B) -> B end.
|
fun (B) when is_boolean(B) -> B end;
|
||||||
|
mod_opt_type(access) ->
|
||||||
|
fun acl:access_rules_validator/1.
|
||||||
|
|
||||||
|
|
||||||
mod_options(_) ->
|
mod_options(_) ->
|
||||||
[{drop, true},
|
[{access, none},
|
||||||
|
{drop, true},
|
||||||
{log, false},
|
{log, false},
|
||||||
{captcha, false},
|
{captcha, false},
|
||||||
{allow_local_users, true},
|
{allow_local_users, true},
|
||||||
|
Loading…
Reference in New Issue
Block a user