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.3 to 0.0.4

32

lib/telnet-client.js

@@ -21,8 +21,13 @@ // Node.js Telnet client

var self = this;
var host = opts.host || '127.0.0.1';
var host = (typeof opts.host !== 'undefined' ? opts.host : '127.0.0.1');
var port = (typeof opts.port !== 'undefined' ? opts.port : 23);
this.timeout = (typeof opts.timeout !== 'undefined' ? opts.timeout : 500);
this.shellPrompt = opts.shellPrompt || /(?:\/ )?#\s/;
this.loginPrompt = opts.loginPrompt || /login[: ]*$/i;
this.shellPrompt = (typeof opts.shellPrompt !== 'undefined'
? opts.shellPrompt : /(?:\/ )?#\s/);
this.loginPrompt = (typeof opts.loginPrompt !== 'undefined'
? opts.loginPrompt : /login[: ]*$/i);
this.passwordPrompt = (typeof opts.passwordPrompt !== 'undefined'
? opts.passwordPrompt : /Password: /i);
this.username = (typeof opts.username !== 'undefined' ? opts.username : 'root');
this.password = (typeof opts.password !== 'undefined' ? opts.password : 'guest');
this.irs = (typeof opts.irs !== 'undefined' ? opts.irs : '\r\n');

@@ -123,4 +128,8 @@ this.ors = (typeof opts.ors !== 'undefined' ? opts.ors : '\n');

telnetObj.telnetState = 'login';
login(telnetObj);
login(telnetObj, 'username');
}
else if (stringData.search(telnetObj.passwordPrompt) !== -1) {
telnetObj.telnetState = 'login';
login(telnetObj, 'password');
}
else return;

@@ -147,6 +156,13 @@ }

function login(telnetObj) {
telnetObj.telnetSocket.write(telnetObj.username + '\n', function() {
telnetObj.telnetState = 'getprompt';
});
function login(telnetObj, handle) {
if (handle === 'username') {
telnetObj.telnetSocket.write(telnetObj.username + '\n', function() {
telnetObj.telnetState = 'getprompt';
});
}
else if (handle === 'password') {
telnetObj.telnetSocket.write(telnetObj.password + '\n', function() {
telnetObj.telnetState = 'getprompt';
});
}
}

@@ -153,0 +169,0 @@

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

},
"version": "0.0.3",
"version": "0.0.4",
"main": "./lib/telnet-client.js",

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

@@ -67,2 +67,3 @@ # node-telnet-client

The optional callback parameter will be executed when the data is finally written out - this may not be immediately.
Command result will be passed as the first argument to the callback.

@@ -80,2 +81,3 @@ ### connection.end()

Emitted when a socket connection is successfully established and the client is successfully connected to the specified remote host.
A value of prompt is passed as the first argument to the callback.

@@ -82,0 +84,0 @@ ### Event: 'writedone'

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