@@ -37,8 +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 ,
40+ _ => Err ( io:: Error :: other (
4241 "unsupported address type" ,
4342 ) ) ,
4443 }
@@ -55,34 +54,30 @@ fn read_response(socket: &mut TcpStream) -> io::Result<TargetAddr> {
5554 match socket. read_u8 ( ) ? {
5655 0 => { }
5756 1 => {
58- return Err ( io:: Error :: new (
59- io:: ErrorKind :: Other ,
57+ return Err ( io:: Error :: other (
6058 "general SOCKS server failure" ,
6159 ) )
6260 }
6361 2 => {
64- return Err ( io:: Error :: new (
65- io:: ErrorKind :: Other ,
62+ return Err ( io:: Error :: other (
6663 "connection not allowed by ruleset" ,
6764 ) )
6865 }
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" ) ) ,
66+ 3 => return Err ( io:: Error :: other ( "network unreachable" ) ) ,
67+ 4 => return Err ( io:: Error :: other ( "host unreachable" ) ) ,
68+ 5 => return Err ( io:: Error :: other ( "connection refused" ) ) ,
69+ 6 => return Err ( io:: Error :: other ( "TTL expired" ) ) ,
7370 7 => {
74- return Err ( io:: Error :: new (
75- io:: ErrorKind :: Other ,
71+ return Err ( io:: Error :: other (
7672 "command not supported" ,
7773 ) )
7874 }
7975 8 => {
80- return Err ( io:: Error :: new (
81- io:: ErrorKind :: Other ,
76+ return Err ( io:: Error :: other (
8277 "address kind not supported" ,
8378 ) )
8479 }
85- _ => return Err ( io:: Error :: new ( io :: ErrorKind :: Other , "unknown error" ) ) ,
80+ _ => return Err ( io:: Error :: other ( "unknown error" ) ) ,
8681 }
8782
8883 if socket. read_u8 ( ) ? != 0 {
@@ -227,14 +222,13 @@ impl Socks5Stream {
227222 }
228223
229224 if selected_method == 0xff {
230- return Err ( io:: Error :: new (
231- io:: ErrorKind :: Other ,
225+ return Err ( io:: Error :: other (
232226 "no acceptable auth methods" ,
233227 ) ) ;
234228 }
235229
236230 if selected_method != auth. id ( ) && selected_method != Authentication :: None . id ( ) {
237- return Err ( io:: Error :: new ( io :: ErrorKind :: Other , "unknown auth method" ) ) ;
231+ return Err ( io:: Error :: other ( "unknown auth method" ) ) ;
238232 }
239233
240234 match * auth {
0 commit comments