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

Method exitSignal

lib/protocol/Protocol.js:1699–1752  ·  view source on GitHub ↗
(chan, name, coreDumped, msg)

Source from the content-addressed store, hash-verified

1697 sendPacket(this, this._packetRW.write.finalize(packet));
1698 }
1699 exitSignal(chan, name, coreDumped, msg) {
1700 if (!this._server)
1701 throw new Error('Server-only method called in client mode');
1702
1703 // Does not consume window space
1704
1705 const origSignal = name;
1706
1707 if (typeof origSignal !== 'string' || !origSignal)
1708 throw new Error(`Invalid signal: ${origSignal}`);
1709
1710 let signal = name.toUpperCase();
1711 if (signal.slice(0, 3) === 'SIG')
1712 signal = signal.slice(3);
1713
1714 if (SIGNALS[signal] !== 1)
1715 throw new Error(`Invalid signal: ${origSignal}`);
1716
1717 const nameLen = Buffer.byteLength(signal);
1718 const msgLen = (msg ? Buffer.byteLength(msg) : 0);
1719 let p = this._packetRW.write.allocStart;
1720 const packet = this._packetRW.write.alloc(
1721 1 + 4 + 4 + 11 + 1 + 4 + nameLen + 1 + 4 + msgLen + 4
1722 );
1723
1724 packet[p] = MESSAGE.CHANNEL_REQUEST;
1725
1726 writeUInt32BE(packet, chan, ++p);
1727
1728 writeUInt32BE(packet, 11, p += 4);
1729 packet.utf8Write('exit-signal', p += 4, 11);
1730
1731 packet[p += 11] = 0;
1732
1733 writeUInt32BE(packet, nameLen, ++p);
1734 packet.utf8Write(signal, p += 4, nameLen);
1735
1736 packet[p += nameLen] = (coreDumped ? 1 : 0);
1737
1738 writeUInt32BE(packet, msgLen, ++p);
1739
1740 p += 4;
1741 if (msgLen) {
1742 packet.utf8Write(msg, p, msgLen);
1743 p += msgLen;
1744 }
1745
1746 writeUInt32BE(packet, 0, p);
1747
1748 this._debug && this._debug(
1749 `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-signal: ${name})`
1750 );
1751 sendPacket(this, this._packetRW.write.finalize(packet));
1752 }
1753 // 'ssh-userauth' service-specific
1754 authFailure(authMethods, isPartial) {
1755 if (!this._server)

Callers 1

exitMethod · 0.80

Calls 3

writeUInt32BEFunction · 0.85
allocMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected