()
| 35 | } |
| 36 | |
| 37 | connect(): Promise<void> { |
| 38 | return new Promise((resolve, reject) => { |
| 39 | this.socket = net.connect({ host: this.host, port: this.port }) |
| 40 | this.socket.once('error', reject) |
| 41 | this.socket.once('data', (data) => { |
| 42 | if (/^250/.test(data.toString())) { resolve() } |
| 43 | else { reject(new Error(`Tor auth failed: ${data}`)) } |
| 44 | }) |
| 45 | this.socket.write(`AUTHENTICATE "${this.password}"\r\n`) |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | private isCompleteTorReply(buffer: string): boolean { |
| 50 | if (!buffer.endsWith('\r\n')) { |
no test coverage detected