-
Notifications
You must be signed in to change notification settings - Fork 93
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
Allow passing in an existing net.Listener and a public ip resolver. #53
Conversation
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.
Very good idea, please execute ./prepare.sh
to fix the issues that travis is reporting.
@@ -74,6 +74,9 @@ type ClientContext interface { | |||
|
|||
// Client's address | |||
RemoteAddr() net.Addr | |||
|
|||
// Servers's address | |||
LocalAddr() net.Addr |
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.
Shouldn't we rename it to ListenAddr
to make it a bit more explicit ?
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.
Im open to a name change, but figured it would make more sense to expose it under the same name as the connection object it is coming from.
Its also not guaranteed that the address is actually the same as the listener address (again from my use case, it will be the private IP of the load balancer that is forwarding the request).
I had originally written this (when prototyping for my own uses) to pass the net.Conn object to the PublicIPResolver, but figured that exposed too much, and instead opted to abstract it behind the ClientContext.
server/driver.go
Outdated
@@ -90,11 +93,15 @@ type PortRange struct { | |||
End int // Range end | |||
} | |||
|
|||
type PublicIpResolver func(ClientContext) (string, error) |
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.
Missing comment
754e528
to
7b96678
Compare
7b96678
to
5890a0b
Compare
@fclairamb fixed linter issues |
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.
LGTM !
This allows the user to provide the mechanisms to get the PASV command to work when running behind a load balancer that supports the proxy protocol by supplying a proxy protocol enabled net.Listener, and a PublicIpResolver that takes the ClientContext and returns the public ip to return to the client.
fclairamb/ftpserver#54