public-address
Resolve public IP address and hostname
Last updated 9 years ago by andris .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install public-address 
SYNC missed versions from official npm registry.

public-address

Resolve the public IP address and hostname of your current machine.

This module makes a HTTP request to https://www.ipify.org/ IP resolving service.

Installation

npm install public-address

Usage

var publicAddress = require("public-address");
publicAddress([options,] callback);

Where

  • options - an optional options object. Everything in this object is passed to the HTTP request object (eg. agent, localAddress etc.)
  • callback - function to run once the resolving succeeded or failed. Has error object and response data as arguments

The data argument for callback has the following properties

  • address - public IP address
  • hostname - (if available) hostname of the IP address

Example

Resolve public IP:

publicAddress(function(err, data){
    console.log(err || data);
});

Example response:

{
    "address": "193.152.61.139",
    "hostname": "gprs-inet-61-139.example.com"
}

License

MIT

Current Tags

  • 0.1.2                                ...           latest (9 years ago)

3 Versions

  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |