File tree 5 files changed +77
-0
lines changed
src/client/legacy/connect/proxy/socks
5 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 57
57
}
58
58
}
59
59
60
+ impl < C > std:: fmt:: Display for SocksError < C > {
61
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
62
+ f. write_str ( "SOCKS error: " ) ?;
63
+
64
+ match self {
65
+ Self :: Inner ( _) => f. write_str ( "failed to create underlying connection" ) ,
66
+ Self :: Io ( _) => f. write_str ( "io error during SOCKS handshake" ) ,
67
+
68
+ Self :: DnsFailure => f. write_str ( "could not resolve to acceptable address type" ) ,
69
+ Self :: MissingHost => f. write_str ( "missing destination host" ) ,
70
+ Self :: MissingPort => f. write_str ( "missing destination port" ) ,
71
+
72
+ Self :: Parsing ( _) => f. write_str ( "failed parsing server response" ) ,
73
+ Self :: Serialize ( _) => f. write_str ( "failed serialize request" ) ,
74
+
75
+ Self :: V4 ( e) => e. fmt ( f) ,
76
+ Self :: V5 ( e) => e. fmt ( f) ,
77
+ }
78
+ }
79
+ }
80
+
60
81
impl < C > From < std:: io:: Error > for SocksError < C > {
61
82
fn from ( err : std:: io:: Error ) -> Self {
62
83
Self :: Io ( err)
Original file line number Diff line number Diff line change @@ -11,3 +11,12 @@ impl From<Status> for SocksV4Error {
11
11
Self :: Command ( err)
12
12
}
13
13
}
14
+
15
+ impl std:: fmt:: Display for SocksV4Error {
16
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
17
+ match self {
18
+ Self :: IpV6 => f. write_str ( "IPV6 is not supported" ) ,
19
+ Self :: Command ( status) => status. fmt ( f) ,
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change @@ -123,3 +123,14 @@ impl TryFrom<u8> for Status {
123
123
} )
124
124
}
125
125
}
126
+
127
+ impl std:: fmt:: Display for Status {
128
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
129
+ f. write_str ( match self {
130
+ Self :: Success => "success" ,
131
+ Self :: Failed => "server failed to execute command" ,
132
+ Self :: IdentFailure => "server ident service failed" ,
133
+ Self :: IdentMismatch => "server ident service did not recognise client identifier" ,
134
+ } )
135
+ }
136
+ }
Original file line number Diff line number Diff line change @@ -25,3 +25,23 @@ impl From<AuthError> for SocksV5Error {
25
25
Self :: Auth ( err)
26
26
}
27
27
}
28
+
29
+ impl std:: fmt:: Display for SocksV5Error {
30
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
31
+ match self {
32
+ Self :: HostTooLong => f. write_str ( "host address is more than 255 characters" ) ,
33
+ Self :: Command ( e) => e. fmt ( f) ,
34
+ Self :: Auth ( e) => e. fmt ( f) ,
35
+ }
36
+ }
37
+ }
38
+
39
+ impl std:: fmt:: Display for AuthError {
40
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
41
+ f. write_str ( match self {
42
+ Self :: Unsupported => "server does not support user/pass authentication" ,
43
+ Self :: MethodMismatch => "server implements authentication incorrectly" ,
44
+ Self :: Failed => "credentials not accepted" ,
45
+ } )
46
+ }
47
+ }
Original file line number Diff line number Diff line change @@ -329,3 +329,19 @@ impl TryFrom<u8> for AuthMethod {
329
329
} )
330
330
}
331
331
}
332
+
333
+ impl std:: fmt:: Display for Status {
334
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
335
+ f. write_str ( match self {
336
+ Self :: Success => "success" ,
337
+ Self :: GeneralServerFailure => "general server failure" ,
338
+ Self :: ConnectionNotAllowed => "connection not allowed" ,
339
+ Self :: NetworkUnreachable => "network unreachable" ,
340
+ Self :: HostUnreachable => "host unreachable" ,
341
+ Self :: ConnectionRefused => "connection refused" ,
342
+ Self :: TtlExpired => "ttl expired" ,
343
+ Self :: CommandNotSupported => "command not supported" ,
344
+ Self :: AddressTypeNotSupported => "address type not supported" ,
345
+ } )
346
+ }
347
+ }
You can’t perform that action at this time.
0 commit comments