@@ -37,10 +37,7 @@ fn read_addr<R: Read>(socket: &mut R) -> io::Result<TargetAddr> {
3737 ip, port, 0 , 0 ,
3838 ) ) ) )
3939 }
40- _ => Err ( io:: Error :: new (
41- io:: ErrorKind :: Other ,
42- "unsupported address type" ,
43- ) ) ,
40+ _ => Err ( io:: Error :: other ( "unsupported address type" ) ) ,
4441 }
4542}
4643
@@ -54,35 +51,15 @@ fn read_response(socket: &mut TcpStream) -> io::Result<TargetAddr> {
5451
5552 match socket. read_u8 ( ) ? {
5653 0 => { }
57- 1 => {
58- return Err ( io:: Error :: new (
59- io:: ErrorKind :: Other ,
60- "general SOCKS server failure" ,
61- ) )
62- }
63- 2 => {
64- return Err ( io:: Error :: new (
65- io:: ErrorKind :: Other ,
66- "connection not allowed by ruleset" ,
67- ) )
68- }
69- 3 => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "network unreachable" ) ) ,
70- 4 => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "host unreachable" ) ) ,
71- 5 => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "connection refused" ) ) ,
72- 6 => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "TTL expired" ) ) ,
73- 7 => {
74- return Err ( io:: Error :: new (
75- io:: ErrorKind :: Other ,
76- "command not supported" ,
77- ) )
78- }
79- 8 => {
80- return Err ( io:: Error :: new (
81- io:: ErrorKind :: Other ,
82- "address kind not supported" ,
83- ) )
84- }
85- _ => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "unknown error" ) ) ,
54+ 1 => return Err ( io:: Error :: other ( "general SOCKS server failure" ) ) ,
55+ 2 => return Err ( io:: Error :: other ( "connection not allowed by ruleset" ) ) ,
56+ 3 => return Err ( io:: Error :: other ( "network unreachable" ) ) ,
57+ 4 => return Err ( io:: Error :: other ( "host unreachable" ) ) ,
58+ 5 => return Err ( io:: Error :: other ( "connection refused" ) ) ,
59+ 6 => return Err ( io:: Error :: other ( "TTL expired" ) ) ,
60+ 7 => return Err ( io:: Error :: other ( "command not supported" ) ) ,
61+ 8 => return Err ( io:: Error :: other ( "address kind not supported" ) ) ,
62+ _ => return Err ( io:: Error :: other ( "unknown error" ) ) ,
8663 }
8764
8865 if socket. read_u8 ( ) ? != 0 {
@@ -227,14 +204,11 @@ impl Socks5Stream {
227204 }
228205
229206 if selected_method == 0xff {
230- return Err ( io:: Error :: new (
231- io:: ErrorKind :: Other ,
232- "no acceptable auth methods" ,
233- ) ) ;
207+ return Err ( io:: Error :: other ( "no acceptable auth methods" ) ) ;
234208 }
235209
236210 if selected_method != auth. id ( ) && selected_method != Authentication :: None . id ( ) {
237- return Err ( io:: Error :: new ( io :: ErrorKind :: Other , "unknown auth method" ) ) ;
211+ return Err ( io:: Error :: other ( "unknown auth method" ) ) ;
238212 }
239213
240214 match * auth {
0 commit comments