Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

telnet-client

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telnet-client - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

.travis.yml

23

lib/telnet-client.js

@@ -167,4 +167,6 @@ // Node.js Telnet client

for (var i = 0; i < telnetObj.cmdOutput.length; i++) {
if (telnetObj.cmdOutput[i].search(telnetObj.pageSeparator) !== -1)
telnetObj.cmdOutput.splice(i, 1);
if (telnetObj.cmdOutput[i].search(telnetObj.pageSeparator) !== -1) {
telnetObj.cmdOutput[i] = telnetObj.cmdOutput[i].replace(telnetObj.pageSeparator, '');
if (telnetObj.cmdOutput[i].length === 0) telnetObj.cmdOutput.splice(i, 1);
}
}

@@ -183,16 +185,7 @@

function login(telnetObj, handle) {
if (handle === 'username') {
if (telnetObj.telnetSocket.writable) {
telnetObj.telnetSocket.write(telnetObj.username + telnetObj.ors, function() {
telnetObj.telnetState = 'getprompt';
});
}
if ((handle === 'username' || handle === 'password') && telnetObj.telnetSocket.writable) {
telnetObj.telnetSocket.write(telnetObj[handle] + telnetObj.ors, function() {
telnetObj.telnetState = 'getprompt';
});
}
else if (handle === 'password') {
if (telnetObj.telnetSocket.writable) {
telnetObj.telnetSocket.write(telnetObj.password + telnetObj.ors, function() {
telnetObj.telnetState = 'getprompt';
});
}
}
}

@@ -199,0 +192,0 @@

@@ -8,3 +8,3 @@ {

},
"version": "0.0.8",
"version": "0.1.0",
"main": "./lib/telnet-client.js",

@@ -16,6 +16,9 @@ "engine": "node >= 0.10.23",

"devDependencies": {
"coveralls": "^2.11.2",
"jscoverage": "^0.5.9",
"nodeunit": ">= 0.9.0"
},
"scripts": {
"test": "nodeunit test"
"test": "nodeunit test",
"coveralls": "jscoverage lib && NODETELNETCLIENT_COV=1 nodeunit --reporter=lcov test | coveralls"
},

@@ -22,0 +25,0 @@ "repository": {

@@ -0,1 +1,6 @@

[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/mkozjak/node-telnet-client/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/mkozjak/node-telnet-client.svg?branch=master)](https://travis-ci.org/mkozjak/node-telnet-client)
[![Coverage Status](https://coveralls.io/repos/mkozjak/node-telnet-client/badge.svg?branch=master)](https://coveralls.io/r/mkozjak/node-telnet-client?branch=master)
[![NPM](https://nodei.co/npm/telnet-client.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/telnet-client/)
# node-telnet-client

@@ -9,39 +14,45 @@

npm install telnet-client
npm install -g telnet-client
```
npm install telnet-client
npm install -g telnet-client
```
## Example usage
var telnet = require('telnet-client');
var connection = new telnet();
var params = {
host: '127.0.0.1',
port: 23,
shellPrompt: '/ # ',
timeout: 1500,
// removeEcho: 4
};
connection.on('ready', function(prompt) {
connection.exec(cmd, function(response) {
console.log(response);
});
});
connection.on('timeout', function() {
console.log('socket timeout!')
connection.end();
});
connection.on('close', function() {
console.log('connection closed');
});
connection.connect(params);
```js
var telnet = require('telnet-client');
var connection = new telnet();
var params = {
host: '127.0.0.1',
port: 23,
shellPrompt: '/ # ',
timeout: 1500,
// removeEcho: 4
};
connection.on('ready', function(prompt) {
connection.exec(cmd, function(response) {
console.log(response);
});
});
connection.on('timeout', function() {
console.log('socket timeout!')
connection.end();
});
connection.on('close', function() {
console.log('connection closed');
});
connection.connect(params);
```
## API
var telnet = require('telnet-client');
var connection = new telnet();
```js
var telnet = require('telnet-client');
var connection = new telnet();
```

@@ -53,13 +64,15 @@ ### connection.connect(options)

* host: Host the client should connect to. Defaults to 'localhost'.
* port: Port the client should connect to. Defaults to '23'.
* timeout: Sets the socket to timeout after the specified number of milliseconds
* `host`: Host the client should connect to. Defaults to '127.0.0.1'.
* `port`: Port the client should connect to. Defaults to '23'.
* `timeout`: Sets the socket to timeout after the specified number of milliseconds
of inactivity on the socket.
* shellPrompt: Shell prompt that the host is using. Defaults to regex '/(?:\/ )?#\s/'.
* loginPrompt: Username/login prompt that the host is using. Defaults to regex '/login[: ]*$/i'.
* username: Username used to login. Defaults to 'root'.
* irs: Input record separator. A separator used to distinguish between lines of the response. Defaults to '\r\n'.
* ors: Output record separator. A separator used to execute commands (break lines on input). Defaults to '\n'.
* echoLines: The number of lines used to cut off the response. Defaults to 1.
* pageSeparator: The pattern used to break the number of lines on output. Defaults to '---- More'.
* `shellPrompt`: Shell prompt that the host is using. Defaults to regex '/(?:\/ )?#\s/'.
* `loginPrompt`: Username/login prompt that the host is using. Defaults to regex '/login[: ]*$/i'.
* `passwordPrompt`: Username/login prompt that the host is using. Defaults to regex '/Password: /i'.
* `username`: Username used to login. Defaults to 'root'.
* `password`: Username used to login. Defaults to 'guest'.
* `irs`: Input record separator. A separator used to distinguish between lines of the response. Defaults to '\r\n'.
* `ors`: Output record separator. A separator used to execute commands (break lines on input). Defaults to '\n'.
* `echoLines`: The number of lines used to cut off the response. Defaults to 1.
* `pageSeparator`: The pattern used (and removed from final output) for breaking the number of lines on output. Defaults to '---- More'.

@@ -74,9 +87,9 @@ ### connection.exec(data, [options], [callback])

* shellPrompt: Shell prompt that the host is using. Defaults to regex '/(?:\/ )?#\s/'.
* loginPrompt: Username/login prompt that the host is using. Defaults to regex '/login[: ]*$/i'.
* timeout: Sets the socket to timeout after the specified number of milliseconds
* `shellPrompt`: Shell prompt that the host is using. Defaults to regex '/(?:\/ )?#\s/'.
* `loginPrompt`: Username/login prompt that the host is using. Defaults to regex '/login[: ]*$/i'.
* `timeout`: Sets the socket to timeout after the specified number of milliseconds
of inactivity on the socket.
* irs: Input record separator. A separator used to distinguish between lines of the response. Defaults to '\r\n'.
* ors: Output record separator. A separator used to execute commands (break lines on input). Defaults to '\n'.
* echoLines: The number of lines used to cut off the response. Defaults to 1.
* `irs`: Input record separator. A separator used to distinguish between lines of the response. Defaults to '\r\n'.
* `ors`: Output record separator. A separator used to execute commands (break lines on input). Defaults to '\n'.
* `echoLines`: The number of lines used to cut off the response. Defaults to 1.

@@ -83,0 +96,0 @@ ### connection.end()

@@ -1,5 +0,8 @@

var telnet = require('../lib/telnet-client');
var telnet = process.env.NODETELNETCLIENT_COV
? require('../lib-cov/telnet-client')
: require('../lib/telnet-client');
var nodeunit = require('nodeunit');
var socket;
var net = require('net');
var socket, server, callbackCount;

@@ -9,6 +12,16 @@ exports['socket'] = nodeunit.testCase({

socket = new telnet();
callback();
callbackCount = 0;
server = net.createServer(function(c) {
callbackCount++;
c.end();
})
server.listen(2323, function(err) {
callback();
});
},
tearDown: function(callback) {
server.close(function() {
callback();
});
},

@@ -18,8 +31,7 @@

socket.connect({
// TODO: napravi neki server koji ce glumiti box i pokreni ga u setUp
host: '10.126.129.195',
port: 23
host: '127.0.0.1',
port: 2323 //not using 23 is a service port could need sudo
});
socket.on('connect', function() {
test.ok(callbackCount == 1, "Client did connect");
test.done();

@@ -26,0 +38,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc