Socket
Socket
Sign inDemoInstall

ip-monitor

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-monitor

A node.js library to monitor your external ip


Version published
Weekly downloads
5
decreased by-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

ip-monitor

Build Status dependencies Status npm version

A node.js library to monitor your external ip for changes

Installation

npm install ip-monitor

Usage

basic

const IpMonitor = require('ip-monitor');
const ipMonitor = new IpMonitor();

ipMonitor.on('change', (prevIp, newIp) => {
    console.log(`IP changed from ${prevIp} to ${newIp}`);
});

ipMonitor.on('error', (error) => {
    console.error(error);
});

ipMonitor.start();


with custom configuration

const IpMonitor = require('ip-monitor');
const ipMonitor = new IpMonitor({
    pollingInterval: 36000,
    verbose: true,
    externalIp: {
        timeout: 1000,
        getIP: 'parallel',
        services: ['http://ifconfig.co/x-real-ip', 'http://icanhazip.com/'],
        replace: true,
        verbose: true
    }
});

ipMonitor.on('change', (prevIp, newIp) => {
    console.log(`IP changed from ${prevIp} to ${newIp}`);
});

ipMonitor.on('error', (error) => {
    console.error(error);
});

ipMonitor.start();

Configuration

new IpMonitor([config]) accepts a configuration object with the following optional properties:

  • pollingInterval: <Integer>: how often to poll for ip changes, default 1 day
  • externalIp: <Object>: configuration passed directly to external-ip

Methods

  • .start(): start watching
  • .stop(): stop watching
  • .poll(): poll for ip manually

Events

  • change: fired when the external ip has changed. it will also fire the first time .start() or .poll() are invoked.
  • error: typical error handling here

Test

Change your working directory to the project's root, npm install to get the development dependencies and then npm test

Keywords

FAQs

Package last updated on 04 May 2020

Did you know?

Socket

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.

Install

Related posts

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