Skip to content

feat: Ability to pass in ssh2 client to transport - #319

Open
abmusse wants to merge 2 commits into
masterfrom
ssh-transport-use-existing-client
Open

feat: Ability to pass in ssh2 client to transport#319
abmusse wants to merge 2 commits into
masterfrom
ssh-transport-use-existing-client

Conversation

@abmusse

@abmusseabmusse commented Jan 15, 2021

Copy link
Copy Markdown
Member

Part of #315

Here is an example on how this could be used:

/** * Example using an existing ssh2 client with itoolkit's ssh transport */const{ Connection, CommandCall }=require('itoolkit');const{ Client }=require('ssh2');const{ parseString }=require('xml2js');constclient=newClient();// add ready listener// then call itoolkit after client is connected and readyclient.on('ready',()=>{constconnection=newConnection({transport: 'ssh',transportOptions: {sshClient: client,},});constcommand=newCommandCall({type: 'cl',command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)'});connection.add(command);connection.run((error,xmlOutput)=>{if(error){throwerror;}parseString(xmlOutput,(parseError,result)=>{if(parseError){throwparseError;}console.log(JSON.stringify(result));});// user closes the connection as neededclient.end();client.destroy();});});client.connect({host: process.env.HOST,username: process.env.USER,password: process.env.PASS,});

@abmusseabmusse added this to the Version 1.1 milestone Jan 15, 2021
@abmusse
abmusse marked this pull request as ready for review January 19, 2021 16:37
@abmusse
abmusse requested a review from kadlerJanuary 20, 2021 20:20
@github-actions

Copy link
Copy Markdown

👋 Hi! This pull request has been marked stale due to inactivity. If no further activity occurs, it will automatically be closed.

@abmusseabmusse added keep-open Exempts stale action from auto closing the issue/pr. and removed stale labels Feb 20, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

keep-openExempts stale action from auto closing the issue/pr.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@abmusse