-
Notifications
You must be signed in to change notification settings - Fork 229
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
Add function to get connection RemoteAddr #15
Comments
I've been thinking about this. Having access to I guess the best way to do this would be to add a new parameter to I'm okay with breaking the API, the package is explicitly marked as unstable. Are you willing to send a PR to add this feature? |
Hi,
ok I'll work on this PR. I'll update you ASAP
Bye
Il 17/09/18 13:40, emersion ha scritto:
…
I've been thinking about this. Having access to |RemoteAddr| is indeed
required for filters and SPF/DMARC.
I guess the best way to do this would be to add a new parameter to
|Login| and |AnonymousLogin|. We could also add in a |TLS
*tls.ConnectionState| field for TLS information. I'm not sure about
the name though, maybe |LoginRequest| would be a better one? (For
consistency with |http.Request|)
I'm okay with breaking the API, the package is explicitly marked as
unstable. Are you willing to send a PR to add this feature?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEeLGAUvhmW5AeUXTJiCX7gm3UO7FRM7ks5ub4oVgaJpZM4Wg9x2>.
|
Another way might be to make type dataReader struct {
r. io.Reader
conn net.Conn
limited bool
n int64
}
func (d *dataReader) Hijack() net.Conn {
return d.conn
} It would be possible to get for ex. client remote address without breaking API: func (u *user) Send(from string, to []string, r io.Reader) error {
type hijacker interface {
Hijack() net.Conn
}
conn := r.(hijacker).Hijack()
fmt.Println("Addr:", conn.RemoteAddr().String())
// ...
} What do you guys think? |
That's an interesting proposal, but the semantics are a little different from Another issue is that you can't access the connection prior to the |
It would also be nice to have access to the hostname reported in EHLO/HELO command. For server-server communication, we may want to check it against rDNS and actual IP of the peer. IMO, it would be best to define a structure that contains all useful information about connection state and pass it to AnonymousLogin/Login as a third argument. type ConnInfo struct {
Hostname string
RemoteAddr net.Addr
TLS *tls.ConnectionState
} |
Hi,
it would be useful to have the remote address of the connection to implement a filter based on sender IP.
I think it could be implemented defining User struct (UserData as User is already ad interface) with RemoteAddr field filled during init of connection.
This change will impact how User is defined as at this moment the Login functions are responsible of User creation. With this change the User object is created by the connection filling all relevant data and passing it to Login functions. Is this doable?
The text was updated successfully, but these errors were encountered: