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.10.2 to 0.10.3

42

app.js

@@ -1,39 +0,13 @@

var t = require('./lib/index')
var c = new t()
var telnet = require('./lib')
var params = {
var connection = new telnet()
connection.connect({
host: '127.0.0.1',
port: 8080,
port: 1337,
negotiationMandatory: false
}
c.on('failedlogin', function() {
console.log('login failed')
})
/*
c.on("connect", function() {
console.log('sending data')
c.send('something', {
ors: '\r\n',
waitfor: '\n'
}, function(error, data) {
console.log('received a response', data)
}).then(function() {
connection.send('hi').then(function(res) {
console.log(res)
})
})
*/
c.connect(params).then(function() {
setInterval(function() {
console.log('sending')
c.send('something', {
ors: '\r\n',
waitfor: '\n'
}, function(error, data) {
console.log('received a response:', error, data)
})
}, 20)
})

36

lib/index.js

@@ -67,12 +67,5 @@ // Node.js Telnet client

self.telnetSocket.on('data', function(data) {
if (self.telnetState === 'standby') {
self.rawResponse += data
if (self.telnetState === 'standby')
return self.emit('data', data)
if (self.waitfor !== undefined) {
if (self.rawResponse.indexOf(self.waitfor) === -1) return
return self.emit('data', self.rawResponse)
}
}
parseData(data, self, function(event, parsed) {

@@ -146,23 +139,28 @@ if (event === 'ready') {

if (opts && opts instanceof Object) {
self.ors = opts.ors || self.ors
this.ors = opts.ors || self.ors
self.sendTimeout = opts.timeout || self.sendTimeout
self.waitfor = opts.waitfor
data += this.ors
}
data += self.ors
if (self.telnetSocket.writable) {
self.telnetSocket.write(data, function() {
self.rawResponse = ''
var response = ''
self.telnetState = 'standby'
self.once('data', function(data) {
resolve(data.toString())
self.on('data', function(data) {
response += data.toString()
if (opts && opts.waitfor !== undefined) {
if (response.indexOf(opts.waitfor) === -1) return
resolve(response)
}
})
if (opts.waitfor === undefined) {
if (opts && opts.waitfor === undefined) {
setTimeout(function() {
if (self.rawResponse === '') return reject(new Error('response not received'))
if (response === '') return reject(new Error('response not received'))
resolve(self.rawResponse)
resolve(response)
}, self.sendTimeout)

@@ -169,0 +167,0 @@ }

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

},
"version": "0.10.2",
"version": "0.10.3",
"main": "./lib/index.js",

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

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