(self, type, opts, cb)
| 1333 | |
| 1334 | |
| 1335 | function 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 | |
| 1375 | function compareNumbers(a, b) { |
| 1376 | return a - b; |
no test coverage detected
searching dependent graphs…