MCPcopy Create free account
hub / github.com/nodejs/node / handleAuthResponse

Method handleAuthResponse

deps/undici/src/lib/core/socks5-client.js:249–268  ·  view source on GitHub ↗

* Handle authentication response

()

Source from the content-addressed store, hash-verified

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

Callers 1

onDataMethod · 0.95

Calls 2

markAuthenticatedMethod · 0.95
debugFunction · 0.50

Tested by

no test coverage detected