MCPcopy Index your code
hub / github.com/Q16G/memory-shell / forward

Method forward

src/main/java/org/example/Socks5Server.java:234–251  ·  view source on GitHub ↗
(SocketChannel source, SocketChannel destination)

Source from the content-addressed store, hash-verified

232 }
233
234 private void forward(SocketChannel source, SocketChannel destination) {
235 ByteBuffer buffer = ByteBuffer.allocate(8192);
236 try {
237 while (source.isOpen() && destination.isOpen()) {
238 buffer.clear();
239 int read = source.read(buffer);
240 if (read == -1) {
241 break;
242 }
243 buffer.flip();
244 writeFully(destination, buffer);
245 }
246 } catch (IOException e) {
247 // 连接已断开,关闭通道
248 closeQuietly(source);
249 closeQuietly(destination);
250 }
251 }
252
253 private void sendResponse(SocketChannel channel, byte status) throws IOException {
254 ByteBuffer response = ByteBuffer.allocate(10);

Callers 1

startForwardingMethod · 0.95

Calls 3

writeFullyMethod · 0.95
closeQuietlyMethod · 0.95
readMethod · 0.80

Tested by

no test coverage detected