(client: net.Socket, dst: { port: number, addr: string }, request: Buffer, timeout: number)
| 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 | } |
no test coverage detected