Skip to content

Commit

Permalink
Merge pull request #1 from fjalvarez09/feature/allow-filtering-by-rec…
Browse files Browse the repository at this point in the history
…ipient

Feature/allow filtering by recipient
  • Loading branch information
fjalvarez09 authored Feb 7, 2022
2 parents 6c155a6 + d5f4bd3 commit 78c188f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions policyd_rate_limit/policyd-rate-limit.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions policyd_rate_limit/policyd-rate-limit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions policyd_rate_limit/policyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 78c188f

Please sign in to comment.