Crates.io | socksv5_future |
lib.rs | socksv5_future |
version | 0.2.5 |
source | src |
created_at | 2018-02-17 11:29:32.632605 |
updated_at | 2018-03-04 13:32:14.899447 |
description | Socks v5 futures for Server and Client |
homepage | https://github.com/gin66/socksv5_future |
repository | https://github.com/gin66/socksv5_future |
max_upload_size | |
id | 51580 |
size | 26,231 |
The socks5 protocol consists of a handshake in these steps:
This is the implementation of two Futures:
As per RFC 1928, this is not a compliant socks5 implementation, because GSSAPI authentication method is not supported.
This is the server side implementation. It implements the step 2 to 4. Step 5 is not performed by this future. Instead the socks5 request is part of the future result.
This is the client side implementation. It performs step 2-5.
The socks5 request from the client is used unchanged and sent to the forwarded socks proxy. Here short code segment to show the principal idea (this code will not compile):
let mut lp = Core::new().unwrap();
let handle = lp.handle();
let addr = "127.0.0.1:8888".parse::<SocketAddr>().unwrap();
let listener = TcpListener::bind(&addr, &handle2).unwrap();
let server = listener.incoming().for_each(move |(socket, _addr)| {
handle.spawn(
socks_handshake(socket)
.and_then(move |(source,request)| {
let proxy = "xx.xx.xx.xx:8888".parse::<SocketAddr>().unwrap();
let connect = TcpStream::connect(&proxy,&handle);
connect.and_then(move |dest|{
socks_connect_handshake(dest,request)
})
.and_then(|(stream,req_answer)|{
write_all(source,req_answer)
})
.and_then(|(stream,buf)|{
// perform transfer source<->stream
});
})
);
Ok(())
});
handle.spawn(server)