MCPcopy Create free account
hub / github.com/UnsignedInt8/LightSword / connectServer

Method connectServer

client/socks5/localProxyServer.ts:86–112  ·  view source on GitHub ↗
(client: net.Socket, dst: { port: number, addr: string }, request: Buffer, timeout: number)

Source from the content-addressed store, hash-verified

84 }
85
86 static connectServer(client: net.Socket, dst: { port: number, addr: string }, request: Buffer, timeout: number) {
87
88 let proxySocket = net.createConnection(dst.port, dst.addr, async () => {
89 let reply = new Buffer(request.length);
90 request.copy(reply);
91 reply[0] = 0x05;
92 reply[1] = 0x00;
93
94 await client.writeAsync(reply);
95
96 proxySocket.pipe(client);
97 client.pipe(proxySocket);
98 });
99
100 function dispose() {
101 proxySocket.dispose();
102 client.dispose();
103 }
104
105 proxySocket.on('end', dispose);
106 proxySocket.on('error', dispose);
107 client.on('end', dispose);
108 client.on('error', dispose);
109
110 proxySocket.setTimeout(timeout);
111 client.setTimeout(timeout);
112 }
113
114}

Callers 2

handleRequestMethod · 0.80
handleRequestMethod · 0.80

Calls 5

copyMethod · 0.80
onMethod · 0.80
writeAsyncMethod · 0.65
pipeMethod · 0.65
setTimeoutMethod · 0.65

Tested by

no test coverage detected