Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

3 lat temu
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # portscanner
  2. [![npm](https://img.shields.io/npm/v/portscanner.svg)](https://www.npmjs.com/package/portscanner)
  3. [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
  4. The portscanner module is
  5. an asynchronous JavaScript port scanner for Node.js.
  6. Portscanner can check a port,
  7. or range of ports,
  8. for 'open' or 'closed' statuses.
  9. [Looking for maintainer](https://github.com/baalexander/node-portscanner/issues/25)!
  10. ## Install
  11. ```bash
  12. npm install portscanner
  13. ```
  14. ## Usage
  15. A brief example:
  16. ```javascript
  17. var portscanner = require('portscanner')
  18. // Checks the status of a single port
  19. portscanner.checkPortStatus(3000, '127.0.0.1', function(error, status) {
  20. // Status is 'open' if currently in use or 'closed' if available
  21. console.log(status)
  22. })
  23. // Find the first available port. Asynchronously checks, so first port
  24. // determined as available is returned.
  25. portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', function(error, port) {
  26. console.log('AVAILABLE PORT AT: ' + port)
  27. })
  28. // Find the first port in use or blocked. Asynchronously checks, so first port
  29. // to respond is returned.
  30. portscanner.findAPortInUse(3000, 3010, '127.0.0.1', function(error, port) {
  31. console.log('PORT IN USE AT: ' + port)
  32. })
  33. // You can also pass array of ports to check
  34. portscanner.findAPortInUse([3000, 3005, 3006], '127.0.0.1', function(error, port) {
  35. console.log('PORT IN USE AT: ' + port)
  36. })
  37. // And skip host param. Default is '127.0.0.1'
  38. portscanner.findAPortNotInUse(3000, 4000, function(error, port) {
  39. console.log('PORT IN USE AT: ' + port)
  40. })
  41. // And use promises
  42. portscanner.findAPortNotInUse(3000, 4000).then(function(port) {
  43. console.log('PORT IN USE AT: ' + port)
  44. })
  45. ```
  46. The example directory contains a more detailed example.
  47. ## Test
  48. ```sh
  49. npm test
  50. ```
  51. ## Future
  52. Please create issues or pull requests
  53. for port scanning related features
  54. you'd like to see included.
  55. ## License (MIT)
  56. [MIT](LICENSE)