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

Method handleHandshakeResponse

deps/undici/undici.js:10705–10727  ·  view source on GitHub ↗

* Handle handshake response from server

()

Source from the content-addressed store, hash-verified

10703 * Handle handshake response from server
10704 */
10705 handleHandshakeResponse() {
10706 if (this.buffer.length < 2) {
10707 return;
10708 }
10709 const version = this.buffer[0];
10710 const method = this.buffer[1];
10711 if (version !== SOCKS_VERSION) {
10712 throw new Socks5ProxyError(`Invalid SOCKS version: ${version}`, "UND_ERR_SOCKS5_VERSION");
10713 }
10714 if (method === AUTH_METHODS.NO_ACCEPTABLE) {
10715 throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
10716 }
10717 this.buffer = this.buffer.subarray(2);
10718 debug("server selected auth method", method);
10719 if (method === AUTH_METHODS.NO_AUTH) {
10720 this.markAuthenticated();
10721 } else if (method === AUTH_METHODS.USERNAME_PASSWORD) {
10722 this.state = STATES.AUTHENTICATING;
10723 this.sendAuthRequest();
10724 } else {
10725 throw new Socks5ProxyError(`Unsupported authentication method: ${method}`, "UND_ERR_SOCKS5_AUTH_METHOD");
10726 }
10727 }
10728 /**
10729 * Send username/password authentication request
10730 */

Callers 1

onDataMethod · 0.45

Calls 3

debugFunction · 0.50
markAuthenticatedMethod · 0.45
sendAuthRequestMethod · 0.45

Tested by

no test coverage detected