mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 17:59:31 +02:00
Support to block IPs in a vhost using append_host_config (#4038)
This commit is contained in:
parent
c2d4f73893
commit
15d73b9d20
1 changed files with 6 additions and 6 deletions
|
@ -573,24 +573,24 @@ may_remove_resource(From) -> From.
|
||||||
get_ip_access(Host) ->
|
get_ip_access(Host) ->
|
||||||
mod_register_opt:ip_access(Host).
|
mod_register_opt:ip_access(Host).
|
||||||
|
|
||||||
check_ip_access({User, Server, Resource}, IPAccess) ->
|
check_ip_access(Server, {User, Server, Resource}, IPAccess) ->
|
||||||
case ejabberd_sm:get_user_ip(User, Server, Resource) of
|
case ejabberd_sm:get_user_ip(User, Server, Resource) of
|
||||||
{IPAddress, _PortNumber} ->
|
{IPAddress, _PortNumber} ->
|
||||||
check_ip_access(IPAddress, IPAccess);
|
check_ip_access(Server, IPAddress, IPAccess);
|
||||||
_ ->
|
_ ->
|
||||||
deny
|
deny
|
||||||
end;
|
end;
|
||||||
check_ip_access(undefined, _IPAccess) ->
|
check_ip_access(_Server, undefined, _IPAccess) ->
|
||||||
deny;
|
deny;
|
||||||
check_ip_access(IPAddress, IPAccess) ->
|
check_ip_access(Server, IPAddress, IPAccess) ->
|
||||||
acl:match_rule(global, IPAccess, IPAddress).
|
acl:match_rule(Server, IPAccess, IPAddress).
|
||||||
|
|
||||||
check_access(User, Server, Source) ->
|
check_access(User, Server, Source) ->
|
||||||
JID = jid:make(User, Server),
|
JID = jid:make(User, Server),
|
||||||
Access = mod_register_opt:access(Server),
|
Access = mod_register_opt:access(Server),
|
||||||
IPAccess = get_ip_access(Server),
|
IPAccess = get_ip_access(Server),
|
||||||
case acl:match_rule(Server, Access, JID) of
|
case acl:match_rule(Server, Access, JID) of
|
||||||
allow -> check_ip_access(Source, IPAccess);
|
allow -> check_ip_access(Server, Source, IPAccess);
|
||||||
deny -> deny
|
deny -> deny
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue