1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use failure::Fail;
#[derive(Fail, Debug)]
pub enum Error {
#[fail(display = "{}", _0)]
Io(#[cause] std::io::Error),
#[fail(display = "{}", _0)]
ParseError(#[cause] std::string::ParseError),
#[fail(display = "Target address is invalid: {}", _0)]
InvalidTargetAddress(&'static str),
#[fail(display = "Proxy server unreachable")]
ProxyServerUnreachable,
#[fail(display = "Invalid response version")]
InvalidResponseVersion,
#[fail(display = "No acceptable auth methods")]
NoAcceptableAuthMethods,
#[fail(display = "Unknown auth method")]
UnknownAuthMethod,
#[fail(display = "General SOCKS server failure")]
GeneralSocksServerFailure,
#[fail(display = "Connection not allowed by ruleset")]
ConnectionNotAllowedByRuleset,
#[fail(display = "Network unreachable")]
NetworkUnreachable,
#[fail(display = "Host unreachable")]
HostUnreachable,
#[fail(display = "Connection refused")]
ConnectionRefused,
#[fail(display = "TTL expired")]
TtlExpired,
#[fail(display = "Command not supported")]
CommandNotSupported,
#[fail(display = "Address type not supported")]
AddressTypeNotSupported,
#[fail(display = "Unknown error")]
UnknownError,
#[fail(display = "Invalid reserved byte")]
InvalidReservedByte,
#[fail(display = "Unknown address type")]
UnknownAddressType,
#[fail(display = "Invalid auth values: {}", _0)]
InvalidAuthValues(&'static str),
#[fail(display = "Password auth failure, code: {}", _0)]
PasswordAuthFailure(u8),
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Error {
Error::Io(err)
}
}
pub type Result<T> = std::result::Result<T, Error>;