conblem / ppp-stream Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi,
I am trying to implement AsyncWrite for PPPRefStream
, so I can run the following code:
let mut local = stream.remote_addr_unpin().await?;
let mut remote = TcpStream::connect("myip:22").await.context("could not connect to remote")?;
tokio::io::copy_bidirectional(&mut local, &mut remote).await.context("copying streams")?;
I have the following implementation:
impl <'a, T> AsyncWrite for PPPRefStream<'a, T> where T: AsyncWrite {
fn poll_write(
self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
buf: &[u8],
) -> std::task::Poll<std::result::Result<usize, std::io::Error>> {
let this = self.get_mut();
this.inner.as_mut().poll_write(cx, buf)
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<std::result::Result<(), std::io::Error>> {
let this = self.get_mut();
this.inner.as_mut().poll_flush(cx)
}
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<std::result::Result<(), std::io::Error>> {
let this = self.get_mut();
this.inner.as_mut().poll_shutdown(cx)
}
}
This works sometimes. It always works with http, proxying the request, but with ssh sometimes I get errors when trying to connect, like:
ssh client error:
Bad packet length 1231976033.
rust app error:
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: copying streams
Caused by:
Connection reset by peer (os error 104)', src/main.rs:55:34
Am I missing something in my implementation?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.