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

Function openChannel

lib/server.js:1335–1373  ·  view source on GitHub ↗
(self, type, opts, cb)

Source from the content-addressed store, hash-verified

1333
1334
1335function openChannel(self, type, opts, cb) {
1336 // Ask the client to open a channel for some purpose (e.g. a forwarded TCP
1337 // connection)
1338 const initWindow = MAX_WINDOW;
1339 const maxPacket = PACKET_SIZE;
1340
1341 if (typeof opts === 'function') {
1342 cb = opts;
1343 opts = {};
1344 }
1345
1346 const wrapper = (err, stream) => {
1347 cb(err, stream);
1348 };
1349 wrapper.type = type;
1350
1351 const localChan = self._chanMgr.add(wrapper);
1352
1353 if (localChan === -1) {
1354 cb(new Error('No free channels available'));
1355 return;
1356 }
1357
1358 switch (type) {
1359 case 'forwarded-tcpip':
1360 self._protocol.forwardedTcpip(localChan, initWindow, maxPacket, opts);
1361 break;
1362 case 'x11':
1363 self._protocol.x11(localChan, initWindow, maxPacket, opts);
1364 break;
1365 case 'forwarded-streamlocal@openssh.com':
1366 self._protocol.openssh_forwardedStreamLocal(
1367 localChan, initWindow, maxPacket, opts
1368 );
1369 break;
1370 default:
1371 throw new Error(`Unsupported channel type: ${type}`);
1372 }
1373}
1374
1375function compareNumbers(a, b) {
1376 return a - b;

Callers 3

x11Method · 0.70
forwardOutMethod · 0.70

Calls 4

addMethod · 0.80
forwardedTcpipMethod · 0.80
x11Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…