(SocketChannel channel, byte status)
| 251 | } |
| 252 | |
| 253 | private void sendResponse(SocketChannel channel, byte status) throws IOException { |
| 254 | ByteBuffer response = ByteBuffer.allocate(10); |
| 255 | response.put(SOCKS_VERSION); |
| 256 | response.put(status); |
| 257 | response.put((byte) 0x00); // 保留字节 |
| 258 | response.put(IPV4_ADDRESS); |
| 259 | response.put(new byte[]{0, 0, 0, 0}); // 绑定地址 |
| 260 | response.putShort((short) 0); // 绑定端口 |
| 261 | response.flip(); |
| 262 | writeFully(channel, response); |
| 263 | } |
| 264 | |
| 265 | private void readFully(SocketChannel channel, ByteBuffer buffer) throws IOException { |
| 266 | while (buffer.hasRemaining()) { |
no test coverage detected