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

fix: Passive mode with custom provided TcpStream #91

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

veeso
Copy link
Owner

@veeso veeso commented Oct 14, 2024

Hi, i'm trying to connect to a FTP server over a SOCKS5 proxy. Connecting works fine.
I just connect with FtpStream::connect_with_stream(stream.into_inner())? where stream is my SOCKS5 TcpStream.
The problem is now: In passive mode, when i want to retrieve a file, the connection to the server is not done via the proxy (provided TcpStream).
It instantiates a new TcpStream internally.
Is there a way to achieve connecting over a custom provided TcpStream when doing retr_as_stream?
Best regards,
Mark

The implementation consists in being able to provide a Fn to set the TcpStream from the SocketAddr when passive mode is initialized.

@veeso veeso linked an issue Oct 14, 2024 that may be closed by this pull request
@veeso veeso added the new feature A new feature request label Oct 14, 2024
@veeso veeso marked this pull request as ready for review October 14, 2024 12:52
@veeso
Copy link
Owner Author

veeso commented Oct 14, 2024

@markhaehnel Does it fit your needs?

@markhaehnel
Copy link

@markhaehnel Does it fit your needs?

This is exactly what i imagined! Thank you very much!

@veeso veeso merged commit d328e6c into main Oct 14, 2024
6 of 8 checks passed
@veeso veeso deleted the 89-passive-mode-with-custom-provided-tcpstream branch October 14, 2024 12:59
///
/// The stream builder is a function that takes a `SocketAddr` and returns a `TcpStream` and it's used
/// to create the [`TcpStream`] for the data connection in passive mode.
pub fn passive_stream_builder<F>(mut self, stream_builder: F) -> Self

Choose a reason for hiding this comment

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

@veeso I think you missed something here. It should be &mut self, right?

Otherwise you get a value borrowed here after move when using it.

image

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's designed to be used in the constructor. So like connect().passive_stream_builder().other()

Choose a reason for hiding this comment

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

Oh, nevermind!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[QUESTION] - Passive mode with custom provided TcpStream
2 participants