-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathsocks_error_code.hpp
More file actions
178 lines (144 loc) · 4.61 KB
/
Copy pathsocks_error_code.hpp
File metadata and controls
178 lines (144 loc) · 4.61 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//
// socks_error_code.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2019 Jack (jack dot wgm at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef INCLUDE__2023_10_18__SOCKS_ERROR_CODE_HPP
#define INCLUDE__2023_10_18__SOCKS_ERROR_CODE_HPP
#include <boost/system/error_code.hpp>
namespace proxy {
class error_category_impl;
template<class error_category>
const boost::system::error_category& error_category_single()
{
static error_category error_category_instance;
return reinterpret_cast<const boost::system::error_category&>(
error_category_instance);
}
inline const boost::system::error_category& error_category()
{
return error_category_single<proxy::error_category_impl>();
}
namespace errc {
enum errc_t
{
/// SOCKS unsupported version.
socks_unsupported_version = 1000,
/// SOCKS username required.
socks_username_required,
/// SOCKS unsupported authentication version.
socks_unsupported_authentication_version,
/// SOCKS authentication error.
socks_authentication_error,
/// SOCKS general failure.
socks_general_failure,
/// connection not allowed by ruleset.
socks_connection_not_allowed_by_ruleset,
/// Network unreachable.
socks_network_unreachable,
/// Host unreachable.
socks_host_unreachable,
/// Connection refused.
socks_connection_refused,
/// TTL expired.
socks_ttl_expired,
/// SOCKS command not supported.
socks_command_not_supported,
/// Address type not supported.
socks_address_type_not_supported,
/// unassigned.
socks_unassigned,
/// socks invalid userid
socks_invalid_userid,
/// unknown error.
socks_unknown_error,
/// SOCKS no identd running.
socks_no_identd,
/// SOCKS no identd running.
socks_identd_error,
/// request rejected or failed.
socks_request_rejected_or_failed,
/// request rejected becasue SOCKS server
// cannot connect to identd on the client.
socks_request_rejected_cannot_connect,
/// request rejected because the client
// program and identd report different user - ids
socks_request_rejected_incorrect_userid,
};
inline boost::system::error_code make_error_code(errc_t e)
{
return boost::system::error_code(
static_cast<int>(e), proxy::error_category());
}
}
class error_category_impl
: public boost::system::error_category
{
const char* name() const noexcept override
{
return "SOCKS";
}
std::string message(int e) const override
{
switch (static_cast<errc::errc_t>(e))
{
case errc::socks_unsupported_version:
return "SOCKS unsupported version";
case errc::socks_username_required:
return "SOCKS username required";
case errc::socks_unsupported_authentication_version:
return "SOCKS unsupported authentication version";
case errc::socks_authentication_error:
return "SOCKS authentication error";
case errc::socks_general_failure:
return "SOCKS general failure";
case errc::socks_connection_not_allowed_by_ruleset:
return "SOCKS connection not allowed by ruleset";
case errc::socks_network_unreachable:
return "SOCKS network unreachable";
case errc::socks_host_unreachable:
return "SOCKS host unreachable";
case errc::socks_connection_refused:
return "SOCKS connection refused";
case errc::socks_ttl_expired:
return "SOCKS TTL expired";
case errc::socks_command_not_supported:
return "SOCKS command not supported";
case errc::socks_address_type_not_supported:
return "SOCKS Address type not supported";
case errc::socks_unassigned:
return "SOCKS unassigned";
case errc::socks_invalid_userid:
return "SOCKS invalid userid";
case errc::socks_unknown_error:
return "SOCKS unknown error";
case errc::socks_no_identd:
return "SOCKS no identd running";
case errc::socks_identd_error:
return "SOCKS no identd running";
case errc::socks_request_rejected_or_failed:
return "SOCKS request rejected or failed";
case errc::socks_request_rejected_cannot_connect:
return "SOCKS request rejected becasue SOCKS"
" server cannot connect to identd on the client";
case errc::socks_request_rejected_incorrect_userid:
return "SOCKS request rejected because the client"
" program and identd report different user";
default:
return "SOCKS Unknown PROXY error";
}
}
};
}
namespace boost::system {
template <>
struct is_error_code_enum<proxy::errc::errc_t>
{
static const inline bool value = true;
};
} // namespace boost
#endif // INCLUDE__2023_10_18__SOCKS_ERROR_CODE_HPP