node.js - Why do this port-scanner not give accurate results everytime? -


below code port-scanner have written in node. problem gives correct result 1 time skip few open ports on other instances of running. open ports should list include 22, 80 , 443. can me running few times please?

const async = require('async')  const net = require('net')  const timeout = 3000  const host = '192.30.253.113'  const openports = []  const concurrency = 100  const portstoscan = 2000    const q = async.queue(function(port, callback) {    const client = net.createconnection({      port: port,      host: host    }, () => {      openports.push(port)      client.destroy()    })      client.on('error', () => {      client.destroy()    })      client.settimeout(timeout, () => {      client.destroy()    })      client.on('close', () => {      callback()    })  }, concurrency)    (let port = 0; port <= portstoscan; port++) {    q.push(port)  }    q.drain = () => {    console.log(openports)  }

it depends on timeout set... 3s not lot (ping > 1000ms tonight, it's bad day, maybe that's why it's not working here). it's difficult figure out "perfect" parameters.

note: there's no port 0, can start loop @ 1.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -