diff --git a/policyd_rate_limit/policyd-rate-limit.conf b/policyd_rate_limit/policyd-rate-limit.conf index f8db71d..e50e33a 100644 --- a/policyd_rate_limit/policyd-rate-limit.conf +++ b/policyd_rate_limit/policyd-rate-limit.conf @@ -45,6 +45,9 @@ limits_by_id = {} limit_by_sasl = True limit_by_ip = False +# If enabled, filters based on recipient address +limit_by_recipient = False + limited_networks = [] # actions return to postfix, see http://www.postfix.org/access.5.html for a list of actions. diff --git a/policyd_rate_limit/policyd-rate-limit.yaml b/policyd_rate_limit/policyd-rate-limit.yaml index 696a67a..9a8d365 100644 --- a/policyd_rate_limit/policyd-rate-limit.yaml +++ b/policyd_rate_limit/policyd-rate-limit.yaml @@ -61,6 +61,8 @@ limit_by_sasl: True limit_by_sender: False # If sasl username and sender address not found or disabled, apply limits by ip addresses. limit_by_ip: False +# If enabled, filters based on recipient address +limit_by_recipient: False # A list of ip networks in cidr notation on which limits are applied. An empty list is equal # to limit_by_ip: False, put "0.0.0.0/0" and "::/0" for every ip addresses. diff --git a/policyd_rate_limit/policyd.py b/policyd_rate_limit/policyd.py index 5ad8747..341be97 100644 --- a/policyd_rate_limit/policyd.py +++ b/policyd_rate_limit/policyd.py @@ -230,6 +230,9 @@ def action(self, connection, request): # else, if activated, we filter by sender elif config.limit_by_sender and u'sender' in request: id = request[u'sender'] + # else, if activated, we filter by recipient + elif config.limit_by_recipient and u'recipient' in request: + id = request[u'recipient'] # else, if activated, we filter by ip source addresse elif ( config.limit_by_ip and