1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.proxy.handlers.socks;
21
22
23
24
25
26
27
28 public class SocksProxyConstants {
29
30
31
32
33 public static final byte SOCKS_VERSION_4 = 0x04;
34
35
36 public static final byte SOCKS_VERSION_5 = 0x05;
37
38
39 public static final byte TERMINATOR = 0x00;
40
41
42
43
44 public static final int SOCKS_4_RESPONSE_SIZE = 8;
45
46
47
48
49
50 public static final byte[] FAKE_IP = new byte[] { 0, 0, 0, 10 };
51
52
53
54
55
56 public static final byte ESTABLISH_TCPIP_STREAM = 0x01;
57
58
59 public static final byte ESTABLISH_TCPIP_BIND = 0x02;
60
61
62 public static final byte ESTABLISH_UDP_ASSOCIATE = 0x03;
63
64
65
66
67
68 public static final byte V4_REPLY_REQUEST_GRANTED = 0x5a;
69
70
71 public static final byte V4_REPLY_REQUEST_REJECTED_OR_FAILED = 0x5b;
72
73
74 public static final byte V4_REPLY_REQUEST_FAILED_NO_IDENTD = 0x5c;
75
76
77 public static final byte V4_REPLY_REQUEST_FAILED_ID_NOT_CONFIRMED = 0x5d;
78
79
80
81
82
83 public static final byte V5_REPLY_SUCCEEDED = 0x00;
84
85
86 public static final byte V5_REPLY_GENERAL_FAILURE = 0x01;
87
88
89 public static final byte V5_REPLY_NOT_ALLOWED = 0x02;
90
91
92 public static final byte V5_REPLY_NETWORK_UNREACHABLE = 0x03;
93
94
95 public static final byte V5_REPLY_HOST_UNREACHABLE = 0x04;
96
97
98 public static final byte V5_REPLY_CONNECTION_REFUSED = 0x05;
99
100
101 public static final byte V5_REPLY_TTL_EXPIRED = 0x06;
102
103
104 public static final byte V5_REPLY_COMMAND_NOT_SUPPORTED = 0x07;
105
106
107 public static final byte V5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED = 0x08;
108
109
110 public static final byte IPV4_ADDRESS_TYPE = 0x01;
111
112
113 public static final byte DOMAIN_NAME_ADDRESS_TYPE = 0x03;
114
115
116 public static final byte IPV6_ADDRESS_TYPE = 0x04;
117
118
119
120
121
122 public static final int SOCKS5_GREETING_STEP = 0;
123
124
125 public static final int SOCKS5_AUTH_STEP = 1;
126
127
128 public static final int SOCKS5_REQUEST_STEP = 2;
129
130
131
132
133
134 public static final byte NO_AUTH = 0x00;
135
136
137 public static final byte GSSAPI_AUTH = 0x01;
138
139
140 public static final byte BASIC_AUTH = 0x02;
141
142
143 public static final byte NO_ACCEPTABLE_AUTH_METHOD = (byte) 0xFF;
144
145
146 public static final byte[] SUPPORTED_AUTH_METHODS = new byte[] { NO_AUTH, GSSAPI_AUTH, BASIC_AUTH };
147
148
149 public static final byte BASIC_AUTH_SUBNEGOTIATION_VERSION = 0x01;
150
151
152 public static final byte GSSAPI_AUTH_SUBNEGOTIATION_VERSION = 0x01;
153
154
155 public static final byte GSSAPI_MSG_TYPE = 0x01;
156
157
158
159
160
161 public static final String KERBEROS_V5_OID = "1.2.840.113554.1.2.2";
162
163
164 public static final String MS_KERBEROS_V5_OID = "1.2.840.48018.1.2.2";
165
166
167
168
169 public static final String NTLMSSP_OID = "1.3.6.1.4.1.311.2.2.10";
170
171 private SocksProxyConstants() {
172 }
173
174
175
176
177
178
179
180 public static final String getReplyCodeAsString(byte code) {
181 switch (code) {
182
183 case V4_REPLY_REQUEST_GRANTED:
184 return "Request granted";
185 case V4_REPLY_REQUEST_REJECTED_OR_FAILED:
186 return "Request rejected or failed";
187 case V4_REPLY_REQUEST_FAILED_NO_IDENTD:
188 return "Request failed because client is not running identd (or not reachable from the server)";
189 case V4_REPLY_REQUEST_FAILED_ID_NOT_CONFIRMED:
190 return "Request failed because client's identd could not confirm the user ID string in the request";
191
192
193 case V5_REPLY_SUCCEEDED:
194 return "Request succeeded";
195 case V5_REPLY_GENERAL_FAILURE:
196 return "Request failed: general SOCKS server failure";
197 case V5_REPLY_NOT_ALLOWED:
198 return "Request failed: connection not allowed by ruleset";
199 case V5_REPLY_NETWORK_UNREACHABLE:
200 return "Request failed: network unreachable";
201 case V5_REPLY_HOST_UNREACHABLE:
202 return "Request failed: host unreachable";
203 case V5_REPLY_CONNECTION_REFUSED:
204 return "Request failed: connection refused";
205 case V5_REPLY_TTL_EXPIRED:
206 return "Request failed: TTL expired";
207 case V5_REPLY_COMMAND_NOT_SUPPORTED:
208 return "Request failed: command not supported";
209 case V5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED:
210 return "Request failed: address type not supported";
211
212 default:
213 return "Unknown reply code";
214 }
215 }
216 }