-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
[QUESTION] - Passive mode with custom provided TcpStream #89
Comments
Hi, I'm not sure how it should work though. The TcpStream is instantiated using the addr returned by |
The current flow is as follows: let stream = Socks5Stream::connect("localhost:1080", address)?;
let mut client = FtpStream::connect_with_stream(stream.into_inner())?;
client.set_mode(Mode::Passive);
client.login(username, password)?;
let mut file_to_write = std::fs::File::create(format!("dl/{}", filename))?;
let mut retr_stream = client.retr_as_stream(filename)?;
std::io::copy(&mut retr_stream, &mut file_to_write)?;
client.finalize_retr_stream(retr_stream)?;
client.quit()?; For solving this my idea would be that one could provide a optional function that creates a let stream = Socks5Stream::connect("localhost:1080", address)?;
let mut client = FtpStream::connect_with_stream(stream.into_inner())?;
client.stream_builder(|address| {
let stream = TcpStream::connect(address)?;
Ok(stream)
// or if you want to use a socks5 proxy
let stream = Socks5Stream::connect("localhost:1080", address)?;
Ok(stream.into_inner())
});
client.set_mode(Mode::Passive);
client.login(username, password)?;
let mut file_to_write = std::fs::File::create(format!("dl/{}", filename))?;
let mut retr_stream = client.retr_as_stream(filename)?;
std::io::copy(&mut retr_stream, &mut file_to_write)?;
client.finalize_retr_stream(retr_stream)?;
client.quit()?; This function would be called whenever the client needs to create a new What do you think of this? BTW, i would be happy to provide the implementation in a PR once we agree on a solution. |
I guess it could work. I'll try to implement this. |
Mind if I submit a Pull Request with my proposed changes? |
I actually was already implementing it 😅 |
No problem, go on! 😄 |
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())?
wherestream
is my SOCKS5TcpStream
.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 doingretr_as_stream
?Best regards,
Mark
The text was updated successfully, but these errors were encountered: