tokio-rs / tokio-socks5 Goto Github PK
View Code? Open in Web Editor NEWAn example SOCKSv5 server implementation with tokio
License: Apache License 2.0
An example SOCKSv5 server implementation with tokio
License: Apache License 2.0
Hi, I use the latest version in macOS 10.13, tokio-socks5 cpu usage is very high。
some log:
Listening for socks5 proxy connections on 127.0.0.1:8080
error for 127.0.0.1:58096: timeout during handshake
error for 127.0.0.1:58100: Connection reset by peer (os error 54)
error for 127.0.0.1:58101: Connection reset by peer (os error 54)
proxied 568/168 bytes for 127.0.0.1:58099
proxied 568/168 bytes for 127.0.0.1:58120
error for 127.0.0.1:58122: Socket is not connected (os error 57)
error for 127.0.0.1:58108: Connection reset by peer (os error 54)
error for 127.0.0.1:58127: timeout during handshake
error for 127.0.0.1:58128: timeout during handshake
error for 127.0.0.1:58134: timeout during handshake
connection may RST by firewall . use dtruss trace:
sudo dtruss -p 9794
recvfrom(0xB, 0x10EC82980, 0x10000) = -1 Err#35
recvfrom(0x1B, 0x10EC82980, 0x10000) = -1 Err#35
recvfrom(0x1A, 0x10EC82980, 0x10000) = -1 Err#35
recvfrom(0xA, 0x10EC82980, 0x10000) = -1 Err#35
recvfrom(0xE, 0x10EC82980, 0x10000) = -1 Err#35
...
...
add some log in: https://github.com/tokio-rs/tokio-socks5/blob/master/src/main.rs#L557
println!("poll.......");
and https://github.com/tokio-rs/tokio-core/blob/master/src/net/tcp.rs#L344
if let Async::Ready(x) = r {
println!("poll read {:?}", x)
}
log output:
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
...
...
It looks like HUP, poll read and poll write both Ready but read returns WouldBlock.
let read_ready = self.reader.poll_read().is_ready();
let write_ready = self.writer.poll_write().is_ready();
if !read_ready || !write_ready {
return Ok(Async::NotReady)
}
let n = try_nb!((&*self.reader).read(&mut buffer));
some help?
this project is still using old api. Is there any plan to rewrite this example using new tokio?
clia-mbp:~ clia$ RUST_BACKTRACE=1 tokio-socks5
Listening for socks5 proxy connections on 0.0.0.0:1090
error for 192.168.1.165:39268: unknown version
proxied 3193/3165 bytes for 192.168.1.165:47486
proxied 3133/3089 bytes for 192.168.1.165:47618
proxied 3925/5301 bytes for 192.168.1.165:54040
thread 'main' panicked at 'assertion failed: (left == right)
left: 65536
,
right: 4360
', src/main.rs:636:13
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::continue_panic_fmt
6: std::panicking::begin_panic_fmt
7: <tokio_socks5::Transfer as futures::future::Future>::poll
8: <futures::future::join::MaybeDone>::poll
9: <futures::future::join::Join<A, B> as futures::future::Future>::poll
10: <futures::future::chain::Chain<A, B, C>>::poll
11: <futures::future::and_then::AndThen<A, B, F> as futures::future::Future>::poll
12: <futures::future::chain::Chain<A, B, C>>::poll
13: <futures::future::and_then::AndThen<A, B, F> as futures::future::Future>::poll
14: <futures::future::chain::Chain<A, B, C>>::poll
15: futures::task_impl::std::set
16: tokio_current_thread::CurrentRunner::set_spawn
17: <tokio_current_thread::scheduler::Scheduler>::tick
18: <scoped_tls::ScopedKey>::set
19: <std::thread::local::LocalKey>::with
20: <std::thread::local::LocalKey>::with
21: <std::thread::local::LocalKey>::with
22: tokio_core::reactor::Core::poll
23: tokio_core::reactor::Core::run
24: tokio_socks5::main
25: std::rt::lang_start::{{closure}}
26: std::panicking::try::do_call
27: __rust_maybe_catch_panic
28: std::rt::lang_start_internal
29: main
My OS is macOS Mojave version 10.14.2
Here is the error, with the complete command, running on rustc 1.20.0-nightly (9475ae477 2017-07-11):
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-allocator.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-arc.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-borrow.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-heap.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-raw_vec.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-slice.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-str.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.alloc-vec.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-any.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-array.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-cmp.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-convert.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-fmt-builders.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-fmt.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-nonzero.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-ptr.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-result.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.core-slice.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.curl-easy.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.smoke.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.smoke-__test.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-collections-hash-table.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-io-error.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-net-addr.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-net-tcp.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-net.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-panic.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-panicking.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-path.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-process.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-sync-mutex.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-sys_common-backtrace.volatile.o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.std-thread.volatile.o" "-o" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/smoke-9e4ed3045f2c9c03.crate.allocator.o" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps" "-L" "/usr/lib" "-L" "/usr/lib" "-L" "/usr/lib" "-L" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/build/backtrace-sys-5cb185e52a30e43c/out/.libs" "-L" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/libcurl-c2ddb7519ea99d1f.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-f810631b1b7e6a95.rlib" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/libcurl_sys-366b61fdb4cd2acb.rlib" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/liblibz_sys-afc6cab14c210a41.rlib" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/libopenssl_sys-682483b06fd60e73.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-1b892f4587025614.rlib" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/liblibc-10310e83a4a4a93b.rlib" "/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/libopenssl_probe-e71eb66f2bb158bd.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm-15040a509e79d2c3.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-e18aff57b2094f45.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-3dafff1bd2cd5f82.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-57bcc55715463b4b.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-382b1b0334de8b04.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-3b051e112a4598f3.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-ec14a360d4d3acaf.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-33f7e2439faf585a.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-66d49f9f7e114d5c.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-6c8f8c6ff7d1a169.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2f52d9d1a3ebf41c.rlib" "/home/linkmauve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-c5920ad7de4f466c.rlib" "-Wl,-Bdynamic" "-l" "curl" "-l" "z" "-l" "ssl" "-l" "crypto" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util"
= note: /home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/libopenssl_sys-682483b06fd60e73.rlib(openssl_sys-682483b06fd60e73.1.o): In function `openssl_sys::set_id_callback':
/home/linkmauve/data/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.7.17/src/lib.rs:544: undefined reference to `CRYPTO_set_id_callback'
/home/linkmauve/dev/rust/tokio-socks5/target/debug/deps/libopenssl_sys-682483b06fd60e73.rlib(openssl_sys-682483b06fd60e73.2.o): In function `openssl_sys::init::{{closure}}':
/home/linkmauve/data/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.7.17/src/lib.rs:517: undefined reference to `SSL_library_init'
/home/linkmauve/data/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.7.17/src/lib.rs:518: undefined reference to `SSL_load_error_strings'
/home/linkmauve/data/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.7.17/src/lib.rs:519: undefined reference to `OPENSSL_add_all_algorithms_noconf'
/home/linkmauve/data/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.7.17/src/lib.rs:521: undefined reference to `CRYPTO_num_locks'
/home/linkmauve/data/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.7.17/src/lib.rs:531: undefined reference to `CRYPTO_set_locking_callback'
collect2: error: ld returned 1 exit status
I’m not sure which dependency is trying to link against it though.
Since the first version of tokio-socks5
, a couple of futures-based DNS crates appeared, and an example of using one of them for name resolution ought to be helpful as a demonstration of integrating disparate futures-based code bases.
I've adapted the code to use @bluejekyll's TRust-DNS library (with his generous help; thanks!) and would like to open a PR, but since the thread-pool resolver example is valuable, I'd prefer to base the PR on a different branch (the README in master could be updated to announce its existence). Do you agree with that approach, and if so, could you create a new branch?
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.