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

Method forwardedTcpip

lib/protocol/Protocol.js:1550–1586  ·  view source on GitHub ↗
(chan, initWindow, maxPacket, cfg)

Source from the content-addressed store, hash-verified

1548 }
1549 // 'ssh-connection' service-specific
1550 forwardedTcpip(chan, initWindow, maxPacket, cfg) {
1551 if (!this._server)
1552 throw new Error('Server-only method called in client mode');
1553
1554 const boundAddrLen = Buffer.byteLength(cfg.boundAddr);
1555 const remoteAddrLen = Buffer.byteLength(cfg.remoteAddr);
1556 let p = this._packetRW.write.allocStart;
1557 const packet = this._packetRW.write.alloc(
1558 1 + 4 + 15 + 4 + 4 + 4 + 4 + boundAddrLen + 4 + 4 + remoteAddrLen + 4
1559 );
1560
1561 packet[p] = MESSAGE.CHANNEL_OPEN;
1562
1563 writeUInt32BE(packet, 15, ++p);
1564 packet.utf8Write('forwarded-tcpip', p += 4, 15);
1565
1566 writeUInt32BE(packet, chan, p += 15);
1567
1568 writeUInt32BE(packet, initWindow, p += 4);
1569
1570 writeUInt32BE(packet, maxPacket, p += 4);
1571
1572 writeUInt32BE(packet, boundAddrLen, p += 4);
1573 packet.utf8Write(cfg.boundAddr, p += 4, boundAddrLen);
1574
1575 writeUInt32BE(packet, cfg.boundPort, p += boundAddrLen);
1576
1577 writeUInt32BE(packet, remoteAddrLen, p += 4);
1578 packet.utf8Write(cfg.remoteAddr, p += 4, remoteAddrLen);
1579
1580 writeUInt32BE(packet, cfg.remotePort, p += remoteAddrLen);
1581
1582 this._debug && this._debug(
1583 `Outbound: Sending CHANNEL_OPEN (r:${chan}, forwarded-tcpip)`
1584 );
1585 sendPacket(this, this._packetRW.write.finalize(packet));
1586 }
1587 x11(chan, initWindow, maxPacket, cfg) {
1588 if (!this._server)
1589 throw new Error('Server-only method called in client mode');

Callers 1

openChannelFunction · 0.80

Calls 3

writeUInt32BEFunction · 0.85
allocMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected