MCPcopy Create free account
hub / github.com/mscdex/ssh2 / disconnect

Method disconnect

lib/protocol/Protocol.js:324–342  ·  view source on GitHub ↗
(reason)

Source from the content-addressed store, hash-verified

322 // Global
323 // ------
324 disconnect(reason) {
325 const pktLen = 1 + 4 + 4 + 4;
326 // We don't use _packetRW.write.* here because we need to make sure that
327 // we always get a full packet allocated because this message can be sent
328 // at any time -- even during a key exchange
329 let p = this._packetRW.write.allocStartKEX;
330 const packet = this._packetRW.write.alloc(pktLen, true);
331 const end = p + pktLen;
332
333 if (!VALID_DISCONNECT_REASONS.has(reason))
334 reason = DISCONNECT_REASON.PROTOCOL_ERROR;
335
336 packet[p] = MESSAGE.DISCONNECT;
337 writeUInt32BE(packet, reason, ++p);
338 packet.fill(0, p += 4, end);
339
340 this._debug && this._debug(`Outbound: Sending DISCONNECT (${reason})`);
341 sendPacket(this, this._packetRW.write.finalize(packet, true), true);
342 }
343 ping() {
344 const p = this._packetRW.write.allocStart;
345 const packet = this._packetRW.write.alloc(PING_PAYLOAD.length);

Callers 4

endMethod · 0.80
constructorMethod · 0.80
endMethod · 0.80
utils.jsFile · 0.80

Calls 3

writeUInt32BEFunction · 0.85
allocMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected