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.6 to 0.0.7

35

lib/telnet-client.js

@@ -25,7 +25,7 @@ // Node.js Telnet client

this.shellPrompt = (typeof opts.shellPrompt !== 'undefined'
? opts.shellPrompt : /(?:\/ )?#\s/);
? opts.shellPrompt : /(?:\/ )?#\s/);
this.loginPrompt = (typeof opts.loginPrompt !== 'undefined'
? opts.loginPrompt : /login[: ]*$/i);
? opts.loginPrompt : /login[: ]*$/i);
this.passwordPrompt = (typeof opts.passwordPrompt !== 'undefined'
? opts.passwordPrompt : /Password: /i);
? opts.passwordPrompt : /Password: /i);
this.username = (typeof opts.username !== 'undefined' ? opts.username : 'root');

@@ -36,2 +36,4 @@ this.password = (typeof opts.password !== 'undefined' ? opts.password : 'guest');

this.echoLines = (typeof opts.echoLines !== 'undefined' ? opts.echoLines : 1);
this.pageSeparator = (typeof opts.pageSeparator !== 'undefined'
? opts.pageSeparator : '---- More');
this.response = '';

@@ -76,6 +78,16 @@ this.telnetState;

Telnet.prototype.exec = function(cmd, callback) {
Telnet.prototype.exec = function(cmd, opts, callback) {
var self = this;
cmd += this.ors;
if (opts && opts instanceof Function) callback = opts;
else if (opts && opts instanceof Object) {
self.shellPrompt = opts.shellPrompt || self.shellPrompt;
self.loginPrompt = opts.loginPrompt || self.loginPrompt;
self.timeout = opts.timeout || self.timeout;
self.irs = opts.irs || self.irs;
self.ors = opts.ors || self.ors;
self.echoLines = opts.echoLines || self.echoLines;
}
if (this.telnetSocket.writable) {

@@ -86,3 +98,3 @@ this.telnetSocket.write(cmd, function() {

self.on('responseready', function() {
self.once('responseready', function() {
if (callback && self.cmdOutput !== 'undefined') {

@@ -148,6 +160,17 @@ callback(self.cmdOutput.join('\n'));

if (promptIndex === -1 && stringData.length !== 0) return;
if (promptIndex === -1 && stringData.length !== 0) {
if (stringData.search(telnetObj.pageSeparator) !== -1) {
telnetObj.telnetSocket.write(Buffer('20', 'hex'));
}
return;
}
telnetObj.cmdOutput = telnetObj.stringData.split(telnetObj.irs);
for (var i = 0; i < telnetObj.cmdOutput.length; i++) {
if (telnetObj.cmdOutput[i].search(telnetObj.pageSeparator) !== -1)
telnetObj.cmdOutput.splice(i, 1);
}
if (telnetObj.echoLines === 1) telnetObj.cmdOutput.shift();

@@ -154,0 +177,0 @@ else if (telnetObj.echoLines > 1) telnetObj.cmdOutput.splice(0, telnetObj.echoLines);

2

package.json

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

},
"version": "0.0.6",
"version": "0.0.7",
"main": "./lib/telnet-client.js",

@@ -11,0 +11,0 @@ "engine": "node >= 0.10.23",

@@ -62,4 +62,5 @@ # node-telnet-client

* 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'.
### connection.exec(data, [callback])
### connection.exec(data, [options], [callback])

@@ -70,2 +71,12 @@ Sends data on the socket (should be a compatible remote host's command if sane information is wanted).

Options:
* 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.
### connection.end()

@@ -72,0 +83,0 @@

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