File tree Expand file tree Collapse file tree 2 files changed +69
-1
lines changed
Expand file tree Collapse file tree 2 files changed +69
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,74 @@ SOCKS proxy support for Rust.
88
99Fork of [ sfackler/rust-socks] ( https://github.com/sfackler/rust-socks ) .
1010
11+ ## Using
12+
13+ ``` cargo add socks2 ```
14+
15+ ``` toml
16+ [dependencies ]
17+ socks2 = " 0.4"
18+ ```
19+
20+ ### Features
21+
22+ #### client
23+
24+ ``` toml
25+ [dependencies ]
26+ socks2 = { version = " 0.4" , default-features = false , features = [" client" ] }
27+ ```
28+
29+ ``` rust
30+ use socks2 :: Socks4Stream ;
31+ use socks2 :: Socks5Stream ;
32+ use std :: io :: Write ;
33+
34+ let mut connection = Socks4Stream :: connect (PROXY , & TARGET , " userid" ). unwrap ();
35+ let buf = [126_u8 ; 50 ]
36+ connection . write (& buf );
37+
38+ let mut connection = Socks5Stream :: connect (PROXY , & TARGET ). unwrap ();
39+ let buf = [126_u8 ; 50 ]
40+ connection . write (& buf );
41+ ```
42+
43+ #### bind
44+
45+ ``` toml
46+ [dependencies ]
47+ socks2 = { version = " 0.4" , default-features = false , features = [" bind" ] }
48+ ```
49+
50+ ``` rust
51+ use socks2 :: Socks4Listener ;
52+ use socks2 :: Socks5Listener ;
53+
54+ let mut connection = Socks4Listener :: bin (PROXY , & TARGET , " userid" )
55+ . unwrap ()
56+ . accept ();
57+
58+ let mut connection = Socks5Listener :: bind (PROXY , & TARGET )
59+ . unwrap ()
60+ . accept ();
61+ ```
62+
63+ #### udp
64+
65+ ``` toml
66+ [dependencies ]
67+ socks2 = { version = " 0.4" , default-features = false , features = [" udp" ] }
68+ ```
69+
70+ ``` rust
71+ use socks2 :: Socks5Datagram ;
72+ use std :: io :: Write ;
73+
74+ let mut connection = Socks5Datagram :: bind (PROXY , & TARGET ). unwrap ();
75+ let buf = [126_u8 ; 50 ]
76+ connection . send_to (& buf , & OTHER_ADDR );
77+ ```
78+
1179## License
1280
1381Licensed under either of
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ mod v4;
3232mod v5;
3333
3434/// A description of a connection target.
35- #[ derive( Debug , Clone ) ]
35+ #[ derive( Debug , Clone , Eq , PartialEq ) ]
3636pub enum TargetAddr {
3737 /// Connect to an IP address.
3838 Ip ( SocketAddr ) ,
You can’t perform that action at this time.
0 commit comments