Skip to content
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

Merged
merged 1 commit into from
Dec 28, 2017

Conversation

marshallbrekka
Copy link
Collaborator

@marshallbrekka marshallbrekka commented Dec 26, 2017

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

Copy link
Owner

@fclairamb fclairamb left a 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
Copy link
Owner

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 ?

Copy link
Collaborator Author

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comment

@marshallbrekka marshallbrekka force-pushed the injectable-listener branch 2 times, most recently from 754e528 to 7b96678 Compare December 27, 2017 18:29
@marshallbrekka
Copy link
Collaborator Author

@fclairamb fixed linter issues

Copy link
Collaborator

@mgenov mgenov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@fclairamb fclairamb merged commit 976aca6 into fclairamb:master Dec 28, 2017
@marshallbrekka marshallbrekka deleted the injectable-listener branch December 30, 2017 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants