Skip to content

Commit

Permalink
Support to block IPs in a vhost using append_host_config (#4038)
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed Sep 24, 2024
1 parent c2d4f73 commit 15d73b9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/mod_register.erl
Original file line number Diff line number Diff line change
Expand Up @@ -573,24 +573,24 @@ may_remove_resource(From) -> From.
get_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
{IPAddress, _PortNumber} ->
check_ip_access(IPAddress, IPAccess);
check_ip_access(Server, IPAddress, IPAccess);
_ ->
deny
end;
check_ip_access(undefined, _IPAccess) ->
check_ip_access(_Server, undefined, _IPAccess) ->
deny;
check_ip_access(IPAddress, IPAccess) ->
acl:match_rule(global, IPAccess, IPAddress).
check_ip_access(Server, IPAddress, IPAccess) ->
acl:match_rule(Server, IPAccess, IPAddress).

check_access(User, Server, Source) ->
JID = jid:make(User, Server),
Access = mod_register_opt:access(Server),
IPAccess = get_ip_access(Server),
case acl:match_rule(Server, Access, JID) of
allow -> check_ip_access(Source, IPAccess);
allow -> check_ip_access(Server, Source, IPAccess);
deny -> deny
end.

Expand Down

0 comments on commit 15d73b9

Please sign in to comment.