Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

icmp

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icmp - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

example/message.js

2

example/ping.js

@@ -22,3 +22,3 @@ const icmp = require('icmp');

.then(obj => {
console.log(obj.open);
console.log(obj.open, obj.elapsed);
})

@@ -25,0 +25,0 @@ .catch(err => { });

@@ -25,6 +25,5 @@ const icmp = require('icmp');

.then(obj => {
console.log('ddd')
// process.stdout.write(`${obj.host} ${obj.open}\r${obj.open ? '\n' : ''}`);
process.stdout.write(`${obj.host} ${obj.open}`);
});
process.stdout.write(`${obj.host} ${obj.open}\r${obj.open ? '\n' : ''}`);
})
.catch(err => { });
}

@@ -31,0 +30,0 @@

@@ -17,3 +17,3 @@ const raw = require('raw-socket');

}
send(data = "") {

@@ -74,3 +74,3 @@ return new Promise((resolve, reject) => {

static send(host, data) {
static send(host, data = "") {
const obj = new this(host);

@@ -89,8 +89,3 @@

static ping(host) {
const obj = new this(host);
return new Promise((resolve, reject) => obj.ping()
.then(() => resolve(obj))
.catch(err => reject(err))
);
return this.send(host);
}

@@ -97,0 +92,0 @@

{
"name": "icmp",
"version": "1.1.0",
"version": "1.1.1",
"description": "Internet Control Message Protocol in Node",

@@ -5,0 +5,0 @@ "main": "index.js",

# Internet Control Message Protocol in Node
Internet Control Message Protocol implementation in Node (it has Promises).
## How to install
# How to install
Install with npm:
> `npm install --save icmp`
## How to use
# How to use
You can view examples in `example` directory.
### Little example for lazy peoples
### Little example for lazy peoples who don't want to open `exemple` directory
Here's how to find if a network card is receiving or not (basic ping) -->

@@ -21,26 +21,47 @@ ```js

## ICMP class:
### Properties
> ## ICMP.host: string
> The requested HOST (can be an IP)
> ## ICMP.ip: string
> The requested IP
> ## ICMP.open: boolean
> The ICMP response
> ## ICMP.type: string
> The response message type, can be:
> ```js
> ['REPLY', 'NA', 'NA', 'DESTINATION_UNREACHABLE', 'SOURCE_QUENCH', 'REDIRECT']
> ```
> ## ICMP.code: string
> The response code, can be:
> ```js
> ['NET', 'HOST', 'PROTOCOL', 'PORT', 'FRAGMENTATION', 'ROUTE_FAILED', 'NET_UNKNOWN', 'HOST_UNKNOWN', 'HOST_ISOLATED', 'NET_PROHIBITED', 'HOST_PROHIBITED', 'NET_UNREACHABLE', 'HOST_UNREACHABLE', 'COMM_PROHIBITED', 'HOST_PRECEDENCE', 'PRECEDENCE_CUTOFF', 'NETWORK', 'HOST', 'SERVICE_NETWORK', 'HOST_NETWORK']
> ```
# Usage:
## Properties
### ICMP.host: string
The requested HOST (can be an IP)
### Methods
> ## ICMP.ping(host: string): Promise<ICMP>
> Send a ping to an host and get a Promise resolving an ICMP instance
### ICMP.ip: string
The requested IP, when host parameter is given to the constructor, the DNS will be resolved to get this IP adress
### ICMP.open: boolean
This property will be `true` or `false`, depending on the ping response
### ICMP.type: string
ICMP response type, will be one from this array:
```js
['REPLY', 'NA', 'NA', 'DESTINATION_UNREACHABLE', 'SOURCE_QUENCH', 'REDIRECT']
```
### ICMP.code: string
ICMP response code, will be one from this array:
```js
['NET', 'HOST', 'PROTOCOL', 'PORT', 'FRAGMENTATION', 'ROUTE_FAILED', 'NET_UNKNOWN', 'HOST_UNKNOWN', 'HOST_ISOLATED', 'NET_PROHIBITED', 'HOST_PROHIBITED', 'NET_UNREACHABLE', 'HOST_UNREACHABLE', 'COMM_PROHIBITED', 'HOST_PRECEDENCE', 'PRECEDENCE_CUTOFF', 'NETWORK', 'HOST', 'SERVICE_NETWORK', 'HOST_NETWORK']
```
## Methods
### (static) ICMP.ping(host: string): Promise<ICMP>
Send a ping to a specific host. Returns a Promise resolving an ICMP instance and rejecting an Error.
### ICMP.ping(): Promise<ICMP>
Send a ping to the defined ICMP instance's host. Returns a Promise, resolving nothing and rejecting an Error.
### (static) ICMP.send(host: string, data: string)
Send data to a specific host through ICMP. Returns a Promise resolving an ICMP instance and rejecting an Error.
```js
icmp.send('10.43.65.9', "Hey, I'm sending a message!")
.then(obj => {
console.log(obj.open ? 'Done' : 'Failed')
})
.catch(err => console.log(err));
```
### ICMP.send(data: string)
Send data to the defined ICMP instance's host. Returns a Promise resolving nothing and rejecting an Error.
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc