MCPcopy Create free account
hub / github.com/Q16G/memory-shell / handleClient

Method handleClient

src/main/java/org/example/Socks5Server.java:24–53  ·  view source on GitHub ↗
(SocketChannel channel, SocketWrapperBase<?> wrapper)

Source from the content-addressed store, hash-verified

22 private int peekPosition;
23
24 public void handleClient(SocketChannel channel, SocketWrapperBase<?> wrapper) throws IOException {
25 this.socketWrapper = wrapper;
26 this.readBuffer = wrapper.getSocketBufferHandler().getReadBuffer();
27 if (channel == null) {
28 throw new IOException("不支持的socket类型");
29 }
30
31 try {
32 // 处理认证方法协商
33 if (!handleAuthenticationNegotiation(channel)) {
34 return;
35 }
36
37 // 处理连接请求
38 if (!handleConnectionRequest(channel)) {
39 return;
40 }
41
42 // 开始转发数据
43 handleDataTransfer(channel);
44 } catch (Exception exception) {
45 throw exception;
46 } finally {
47 try {
48 channel.close();
49 } catch (IOException e) {
50 // 忽略关闭时的异常
51 }
52 }
53 }
54
55 private boolean handleAuthenticationNegotiation(SocketChannel channel) throws IOException {
56 // 读取版本和方法数量

Callers 1

processMethod · 0.95

Calls 4

handleDataTransferMethod · 0.95
closeMethod · 0.80

Tested by

no test coverage detected