https://github.com/ubcent/node-subnet-discover
subnet-discover is a nodejs class that allows you to discover of specific devices in your local network
https://github.com/ubcent/node-subnet-discover
Last synced: about 1 year ago
JSON representation
subnet-discover is a nodejs class that allows you to discover of specific devices in your local network
- Host: GitHub
- URL: https://github.com/ubcent/node-subnet-discover
- Owner: ubcent
- License: mit
- Created: 2017-09-26T13:48:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-10T13:33:30.000Z (over 7 years ago)
- Last Synced: 2024-04-26T06:02:12.865Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# subnet-discover
*subnet-discover* is a `nodejs` class that allows you to discover of specific devices in your local network. It's just an extension of a [ping-subnet](https://www.npmjs.com/package/ping-subnet) package. It has the same API with a small addition. At this moment it supports the only printers.
# Installation
```sh
npm install subnet-discover
```
# 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 SubnetDiscoverer = require('subnet-discover');
const ranges = [
'192.168.0.123',
'192.168.0.1-192.168.0.100'
];
const subnetDiscoverer = new SubnetDiscoverer(ranges);
subnetDiscoverer.on('host:printer', (ip, deviceName) => {
console.log('printer', ip, deviceName);
});
subnetDiscoverer.discover();
```
### If the custom ranges is not specified it would be assigned using current network settings
```javascript
const SubnetDiscoverer = require('subnet-discover');
const subnetDiscoverer = new SubnetDiscoverer();
subnetDiscoverer.on('host:printer', (ip, deviceName) => {
console.log('printer', ip, deviceName);
});
subnetDiscoverer.discover();
```
# Events list
| Name | Args | Description |
|------------|----------|-------------|
|`host:alive`| IP-address of a live host | Fired when the ping of any host is succesful |
|`ping:end` | empty | Fired when the ping of all IPs in ranges is completed |
|`host:printer`| IP-address and the model of the printer | Fired when printer is detected |