-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Rate Limit per remote #155
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,22 @@ | |||
FROM golang:1.22-alpine AS build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -10,12 +10,16 @@ require ( | |||
) | |||
|
|||
require ( | |||
github.com/Hepri/rate_limiter v0.0.0-20170628005159-cf154f46b333 // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm where is that dependency coming from?
@@ -195,7 +195,7 @@ func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error { | |||
environ = append(environ, fmt.Sprintf("%s=%s", "SMTPRELAY_PEER", peerIP)) | |||
|
|||
cmd := exec.Cmd{ | |||
Env: environ, | |||
Env: environ, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace change?
@@ -321,6 +324,13 @@ var testHookStartTLS func(*tls.Config) // nil, except for tests | |||
// functionality. Higher-level packages exist outside of the standard | |||
// library. | |||
func SendMail(r *Remote, from string, to []string, msg []byte) error { | |||
if r.RateLimiter != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy from upstream Golang net/smtp and touching it should be avoided if possible.
I've added a rate limiter per remote configuration with an optional url parameter.
I've also added a Dockerfile to build a container image.