{"id":19387716,"url":"https://github.com/haraka/haraka-plugin-limit","last_synced_at":"2025-10-15T03:19:23.256Z","repository":{"id":16515876,"uuid":"80091289","full_name":"haraka/haraka-plugin-limit","owner":"haraka","description":"Enforce many types of limits on a Haraka mail server.","archived":false,"fork":false,"pushed_at":"2025-06-02T16:58:31.000Z","size":101,"stargazers_count":10,"open_issues_count":6,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-07T02:25:36.819Z","etag":null,"topics":["haraka","haraka-plugin","limit","mta","rate-limits","recipients","sender","smtp"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/haraka-plugin-limit","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haraka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["msimerson"],"patreon":["mattsimerson"]}},"created_at":"2017-01-26T06:28:02.000Z","updated_at":"2025-06-02T16:58:22.000Z","dependencies_parsed_at":"2023-12-28T02:32:09.829Z","dependency_job_id":"fbdec746-3c6f-493b-a722-bf887108e2a4","html_url":"https://github.com/haraka/haraka-plugin-limit","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/haraka/haraka-plugin-limit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haraka%2Fharaka-plugin-limit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haraka%2Fharaka-plugin-limit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haraka%2Fharaka-plugin-limit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haraka%2Fharaka-plugin-limit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haraka","download_url":"https://codeload.github.com/haraka/haraka-plugin-limit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haraka%2Fharaka-plugin-limit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264734233,"owners_count":23655625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haraka","haraka-plugin","limit","mta","rate-limits","recipients","sender","smtp"],"created_at":"2024-11-10T10:10:16.915Z","updated_at":"2025-10-15T03:19:18.202Z","avatar_url":"https://github.com/haraka.png","language":"JavaScript","funding_links":["https://github.com/sponsors/msimerson","https://patreon.com/[\"mattsimerson\"]"],"categories":[],"sub_categories":[],"readme":"# haraka-plugin-limit\n\n[![Tests][ci-img]][ci-url]\n[![Code Climate][clim-img]][clim-url]\n\nApply many types of limits to SMTP connections:\n\n    - concurrent connections\n    - max recipients\n    - max unrecognized commands\n    - max SMTP errors\n    - outbound concurrency\n    - rate limits\n        - max connections / period\n        - max recipients / period\n            - by host\n            - by sender\n        - max null recipients / period\n\n## Installation\n\n```sh\ncd /etc/haraka\nnpm i haraka-plugin-limit\ngrep -q ^redis config/plugins || echo 'redis' \u003e\u003e config/plugins\necho 'limit' \u003e\u003e config/plugins\n```\n\n## Configure\n\nEach limit type has values that can be defined in [limit.ini](https://github.com/haraka/haraka-plugin-limit/blob/master/config/limit.ini). See the default [limit.ini](https://github.com/haraka/haraka-plugin-limit) in this packages config directory.\n\nEach limit type is disabled until `enabled=true` is set within its block in limit.ini.\n\nHaraka's config loader loads the defaults from limit.ini within this plugins installed config directory and applies any overrides found in the limit.ini within your Haraka install/config directory.\n\n### [main]\n\n\u003c!-- prettier-ignore --\u003e\n- tarpit_delay = seconds _(optional)_\n\nSet this to the length in seconds that you want to delay every SMTP response to a remote client that has exceeded the rate limits.\n\n## [redis]\n\nRedis is the cluster-safe storage backend for maintaining the counters necessary to impose limits reliably.\n\n- host (default: 127.0.0.1)\n- port (default: 6379)\n- db (default: 0)\n\nIf this [redis] section or any values are missing, the defaults from redis.ini are used.\n\n## concurrency\n\nWhen `[concurrency]max` is defined, it limits the maximum number of simultaneous connections per IP address. Connection attempts in excess of the limit are optionally delayed before being disconnected.\n\nThis works well in conjunction with a history / reputation database, so that one can assign very low concurrency (1) to bad or unknown senders and higher limits for reputable mail servers.\n\n### History\n\nHistory: when enabled, the `history` setting is the name of a plugin that stores IP history / reputation results. The result store must have a positive value for good connections and negative integers for poor / undesirable connections. Karma is one such plugin.\n\n## recipients\n\nWhen `[recipients]max` is defined, each connection is limited to that number of recipients. The limit is imposed against **all** recipient attempts. Attempts in excess of the limit are issued a temporary failure.\n\n## unrecognized_commands\n\nWhen `[unrecognized_commands]max` is set, a connection that exceeeds the limit is disconnected.\n\nUnrecognized commands are normally SMTP verbs invalidly issued by the client. Examples:\n\n- issuing AUTH when we didn't advertise AUTH extension\n- issuing STARTTLS when we didn't advertise STARTTLS\n- invalid SMTP verbs\n\n### Limitations\n\nThe unrecognized_command hook is used by the `tls` and `auth` plugins, so running this plugin before those would result in valid operations getting counted against that connections limits. The solution is simple: list `limit` in config/plugins after those.\n\n## errors\n\nWhen `[errors]max` is set, a connection that exceeeds the limit is disconnected. Errors that count against this limit include:\n\n- issuing commands out of turn (MAIL before EHLO, RCPT before MAIL, etc)\n- attempting MAIL on port 465/587 without AUTH\n- MAIL or RCPT addresses that fail to parse\n\n# Rate Limits\n\nBy default DENYSOFT will be returned when rate limits are exceeded. You can\nalso tarpit the connection delaying every response.\n\nMissing sections disable that particular test.\n\nThey all use a common configuration format:\n\n- \\\u003clookup\\\u003e = \\\u003climit\\\u003e[/time[unit]] _(optional)_\n\n'lookup' is based upon the limit being enforced and is either an IP address, rDNS name, sender address or recipient address either in full or part.\n\nThe lookup order is as follows and the first match in this order is returned and is used as the record key in Redis (except for 'default' which always uses the full lookup for that test as the record key):\n\n**IPv4/IPv6 address or rDNS hostname:**\n\n```\n   fe80:0:0:0:202:b3ff:fe1e:8329\n   fe80:0:0:0:202:b3ff:fe1e\n   fe80:0:0:0:202:b3ff\n   fe80:0:0:0:202\n   fe80:0:0:0\n   fe80:0:0\n   fe80:0\n   fe80\n   1.2.3.4\n   1.2.3\n   1.2\n   1\n   host.part.domain.com\n   part.domain.com\n   domain.com\n   com\n   default\n```\n\n**Sender or Recipient address:**\n\n```\n   user@host.sub.part.domain.com\n   host.sub.part.domain.com\n   sub.part.domain.com\n   part.domain.com\n   domain.com\n   com\n   default\n```\n\nIn all tests 'default' is used to specify a default limit if nothing else has matched.\n\n'limit' specifies the limit for this lookup. Specify 0 (zero) to disable limits on a matching lookup.\n\n'time' is optional and if missing defaults to 60 seconds. You can optionally specify the following time units (case-insensitive):\n\n- s (seconds)\n- m (minutes)\n- h (hours)\n- d (days)\n\n### [rate_conn]\n\nThis section limits the number of connections per interval from a given host or set of hosts.\n\nIP and rDNS names are looked up by this test.\n\n### [rate_rcpt_host]\n\nThis section limits the number of recipients per interval from a given host or set of hosts.\n\nIP and rDNS names are looked up by this test.\n\n### [rate_rcpt_sender]\n\nThis section limits the number of recipients per interval from a sender or sender domain.\n\nThe sender is looked up by this test.\n\n### [rate_rcpt]\n\nThis section limits the rate which a recipient or recipient domain can receive messages over an interval.\n\nEach recipient is looked up by this test.\n\n### [rate_rcpt_null]\n\nThis section limits the rate at which a recipient can receive messages from a null sender (e.g. DSN, MDN etc.) over an interval.\n\nEach recipient is looked up by this test.\n\n### [outbound]\n\nenabled=true\n; delay=30\n;example.com=10\n\nThe number after the domain is the maximum concurrency limit for that domain.\n\nDelay is the number of seconds to wait before retrying this message. Outbound concurrency is checked on every attempt to deliver.\n\n## CAUTION\n\nApplying strict connection and rate limits is an effective way to reduce spam delivery. It's also an effective way to inflict a stampeding herd on your mail server. When spam/malware is delivered by MTAs that have queue retries, if you disconnect early (which the rate limits do) with a 400 series code (a sane default), the remote is likely to try again. And again. And again. And again. This can cause an obscene rise in the number of connections your mail server handles. Plan a strategy for handling that.\n\n## Strategies\n\n- Don't enforce limits early. I use karma and wait until DATA before disconnecting. By then, the score of the connection is determinate and I can return a 500 series code telling the remote not to try again.\n- enforce rate limits with your firewall instead\n\n[ci-img]: https://github.com/haraka/haraka-plugin-limit/actions/workflows/ci.yml/badge.svg\n[ci-url]: https://github.com/haraka/haraka-plugin-limit/actions/workflows/ci.yml\n[clim-img]: https://codeclimate.com/github/haraka/haraka-plugin-limit/badges/gpa.svg\n[clim-url]: https://codeclimate.com/github/haraka/haraka-plugin-limit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharaka%2Fharaka-plugin-limit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharaka%2Fharaka-plugin-limit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharaka%2Fharaka-plugin-limit/lists"}