https://github.com/ubcent/ping-subnet
A tiny util for discovering alive hosts in local network
https://github.com/ubcent/ping-subnet
Last synced: about 1 year ago
JSON representation
A tiny util for discovering alive hosts in local network
- Host: GitHub
- URL: https://github.com/ubcent/ping-subnet
- Owner: ubcent
- License: mit
- Created: 2017-09-25T12:52:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-06T09:04:34.000Z (almost 8 years ago)
- Last Synced: 2025-03-18T12:47:33.695Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ping-subnet
A tiny util for discovering alive hosts in local network. It is fully compatible with the native `nodejs` [EventEmmiter](https://nodejs.org/api/events.html)
# Installation
```sh
npm install ping-subnet
```
# Usage
### You can specify the custom ranges parameter.
Ranges parameter is represented by array of strings. There are two possible forms: just a single IP or the range.
```javascript
const SubnetsPinger = require('ping-subnet');
const ranges = [
'192.168.0.123',
'192.168.0.1-192.168.0.100'
];
const subnetPinger = new SubnetsPinger(ranges);
subnetPinger.on('host:alive', ip => {
console.log('alive', ip);
});
subnetPinger.once('ping:end', () => {
console.log('ping completed');
});
subnetPinger.ping();
```
### If the custom ranges is not specified it would be assigned using current network settings
```javascript
const SubnetsPinger = require('ping-subnet');
const subnetPinger = new SubnetsPinger();
subnetPinger.on('host:alive', ip => {
console.log('alive', ip);
});
subnetPinger.once('ping:end', () => {
console.log('ping completed');
});
subnetPinger.ping();
```