-
Notifications
You must be signed in to change notification settings - Fork 10
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
session.set_tcp_stream #4
Comments
What would be the benefit for using tokio::net::TcpStream here? I am sure that the way I introduced async within the file |
Function wouldn't block on initialization of tcp connection. Sometimes it takes several minutes, if there troubles with network |
The connect is handled by the |
Ok, I got what you mean, I forgot that the stream is created with a synchronous connect method. I'll change that. |
My suggestion for this is to submit a PR to ssh2 that:
#[cfg(unix)]
pub fn set_tcp_stream<S: AsRawFd>(&mut self, stream: S) {}
#[cfg(windows)]
pub fn set_tcp_stream<S: AsRawSocket>(&mut self, stream: S) {} Initially I was thinking that Then I think we need to change the tcp_stream method to return |
I think the windows version will only work as soon as |
On that matter, I'm trying to figure out how to use this library in the context of socks proxys. From what I've read about the C library, one would need to connect to the SOCKS proxy externally, then create a socket for the communication, pipe the communication to that socket and pass the other end of the socket to the C library. Obviously, this won't work at the moment here.
|
@0xd34b33f I ported the library to use use async_ssh2::Session;
use std::net::TcpStream;
use smol::Async;
#[tokio::main]
async fn main() {
let stream = Async::<TcpStream>::connect("127.0.0.1:22").await.unwrap();
let mut sess = async_ssh2::Session::new().unwrap();
sess.set_tcp_stream(stream).unwrap();
} |
That is amazing! With sticnarf/tokio-socks#18 you can now easily wire-up this library to use async_ssh2::Session;
use tokio_socks::{tcp::Socks5Stream};
fn main() -> Result<(), Box<dyn std::error::Error>> {
smol::run( async {
let stream = Socks5Stream::connect("localhost:33712", "10.101.120.23:22").await?.into_inner().?;
let mut sess = async_ssh2::Session::new()?;
sess.set_tcp_stream(stream)?;
})
} |
That's really nice to hear! I think I'll publish a beta soon on crates.io. |
async-ssh2::Session::set_tcp_stream
Why not to use
tokio::net::TcpStream
instead ofstd::net::TcpStream
?The text was updated successfully, but these errors were encountered: