Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
portscanner
Advanced tools
The portscanner npm package is a utility for scanning and checking the status of ports on a given host. It can be used to find open ports, check if a specific port is open, and find the first open port within a range.
Check if a specific port is open
This feature allows you to check if a specific port on a given host is open or closed. The code sample demonstrates how to check the status of port 3000 on localhost.
const portscanner = require('portscanner');
portscanner.checkPortStatus(3000, '127.0.0.1', (error, status) => {
if (error) throw error;
console.log(`Port 3000 is ${status}`); // 'open' or 'closed'
});
Find the first open port in a range
This feature allows you to find the first open port within a specified range on a given host. The code sample demonstrates how to find the first open port between 3000 and 3010 on localhost.
const portscanner = require('portscanner');
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', (error, port) => {
if (error) throw error;
console.log(`First open port is ${port}`);
});
Find the first port in use in a range
This feature allows you to find the first port that is in use within a specified range on a given host. The code sample demonstrates how to find the first port in use between 3000 and 3010 on localhost.
const portscanner = require('portscanner');
portscanner.findAPortInUse(3000, 3010, '127.0.0.1', (error, port) => {
if (error) throw error;
console.log(`First port in use is ${port}`);
});
net-ping is a package that provides network utilities including ping and port scanning. While it offers more comprehensive network diagnostic tools, its port scanning capabilities are similar to those of portscanner. It can be used to check the status of ports and find open ports on a host.
The portscanner module is an asynchronous JavaScript port scanner for Node.js.
Portscanner can check a port, or range of ports, for 'open' or 'closed' statuses.
npm install portscanner
A brief example:
var portscanner = require('portscanner')
// Checks the status of a single port
portscanner.checkPortStatus(3000, '127.0.0.1', function(error, status) {
// Status is 'open' if currently in use or 'closed' if available
console.log(status)
})
// Find the first available port. Asynchronously checks, so first port
// determined as available is returned.
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', function(error, port) {
console.log('AVAILABLE PORT AT: ' + port)
})
// Find the first port in use or blocked. Asynchronously checks, so first port
// to respond is returned.
portscanner.findAPortInUse(3000, 3010, '127.0.0.1', function(error, port) {
console.log('PORT IN USE AT: ' + port)
})
The example directory contains a more detailed example.
There are currently no tests. If you have ideas, please open an issue.
Please create issues or pull requests for port scanning related features you'd like to see included.
1.0.0
2463e64a0a
] - 1.0.0 (Sean Massa)21aa98b632
] - update readme (Sean Massa)5fe4ab4a69
] - Merge pull request #21 from jdwilliams15/master (Sean Massa)725afef7b4
] - fix indent (jdwilliams15)053b56e455
] - fixed indentation (jdwilliams15)b1dd496633
] - Changed socket error handler to handle 'ECONNREFUSED'. In event of ECONNREFUSED the port is available (jdwilliams15)512cfdbf78
] - 0.2.3 (Sean Massa)5526b8b4eb
] - Merge pull request #19 from thomseddon/fix-end (Sean Massa)a854ec6bd6
] - Use socket.destroy() not socket.end() on successful connection (Thom Seddon)c747ffa9de
] - 0.2.2 (Sean Massa)4a1f8f811b
] - Merge pull request #16 from baalexander/fix-port-finding (Sean Massa)ff51ebe871
] - fix port reporting (Sean Massa)e9070e85ca
] - 0.2.1 (Sean Massa)809b7760ad
] - 0.2.0 (Sean Massa)87f35e5b87
] - Merge pull request #14 from baalexander/localhost-127.0.0.1 (Sean Massa)0b72b83cab
] - switch out localhost for 127.0.0.1 (Sean Massa)4407d6f701
] - Merge pull request #13 from skilesare/master (Sean Massa)3ed682ad7a
] - Update portscanner.js (skilesare)c1544a1bb3
] - Update portscanner.js (skilesare)d3b029c384
] - Adds @EndangeredMassa as a package maintainer. (Brandon Alexander)8f5559b1fe
] - Merge pull request #7 from EndangeredMassa/smassa/timeout (Brandon Alexander)16d0db3944
] - added options param to checkPortStatus; supports host and timeout (Sean Massa)b8acb18a08
] - exposed errors for checkPortStatus (Sean Massa)381769162d
] - Updates version to 0.1.3. (Brandon Alexander)38cb922d1c
] - Uses callback in listen() instead of a timeout. (Brandon Alexander)aefd8ccad1
] - Merge pull request #4 from DennisKehrig/master (Brandon Alexander)5b58f03421
] - Call socket.destroy() on timeout (Dennis Kehrig)45028c6e3e
] - Updates version to 0.1.2. (Brandon Alexander)a60a248a2a
] - Fixes multiple callbacks when checking port status. (Brandon Alexander)19a8c1df2c
] - Updates to v0.1.1. (Brandon Alexander)c81ae8d6e4
] - Checks range of ports one at a time. (Brandon Alexander)fe9726773d
] - Only returns status of a port after connection closed. (Brandon Alexander)af6c474f38
] - Ignores example and test directories in NPM. (Brandon Alexander)78be727cb4
] - Initial release to NPM. (Brandon Alexander)cc71a028cb
] - Renames port finding functions for clarity. (Brandon Alexander)bb0356a82e
] - Quits scanning ports when a matching port has been found. (Brandon Alexander)24224b8148
] - Destroys the socket on error instead of end. (Brandon Alexander)e2c4448293
] - Updates README since not yet ready for NPM. (Brandon Alexander)5cca315f8b
] - Packages up port scanner for NPM. (Brandon Alexander)8c1f11e76c
] - Adds JSDocs and updates example code. (Brandon Alexander)4b432ba950
] - Set max port range to 65535. (Brandon Alexander)3a78761e4f
] - Adds README and MIT license. (Brandon Alexander)e232efc85f
] - Checks a range of ports for first open or closed port. (Brandon Alexander)8568c23e7c
] - Initial commit checks status of a specified port. (Brandon Alexander)FAQs
Asynchronous port scanner for Node.js
The npm package portscanner receives a total of 521,587 weekly downloads. As such, portscanner popularity was classified as popular.
We found that portscanner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.