* Handle authentication response
()
| 247 | * Handle authentication response |
| 248 | */ |
| 249 | handleAuthResponse () { |
| 250 | if (this.buffer.length < 2) { |
| 251 | return // Not enough data yet |
| 252 | } |
| 253 | |
| 254 | const version = this.buffer[0] |
| 255 | const status = this.buffer[1] |
| 256 | |
| 257 | if (version !== 0x01) { |
| 258 | throw new Socks5ProxyError(`Invalid auth sub-negotiation version: ${version}`, 'UND_ERR_SOCKS5_AUTH_VERSION') |
| 259 | } |
| 260 | |
| 261 | if (status !== 0x00) { |
| 262 | throw new Socks5ProxyError('Authentication failed', 'UND_ERR_SOCKS5_AUTH_FAILED') |
| 263 | } |
| 264 | |
| 265 | this.buffer = this.buffer.subarray(2) |
| 266 | debug('authentication successful') |
| 267 | this.markAuthenticated() |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Send CONNECT command |
no test coverage detected