Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eiriksm/node-local-ip
Get local ip address in node.
https://github.com/eiriksm/node-local-ip
Last synced: 2 months ago
JSON representation
Get local ip address in node.
- Host: GitHub
- URL: https://github.com/eiriksm/node-local-ip
- Owner: eiriksm
- Created: 2014-02-10T17:17:52.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-04-09T16:19:35.000Z (over 6 years ago)
- Last Synced: 2024-10-12T01:46:11.882Z (3 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-local-ip
=============
[![Build Status](https://travis-ci.org/eiriksm/node-local-ip.svg)](https://travis-ci.org/eiriksm/node-local-ip)
[![Code Climate](http://img.shields.io/codeclimate/github/eiriksm/node-local-ip.svg)](https://codeclimate.com/github/eiriksm/node-local-ip)Get local ip address in node.
# Installation
` npm install local-ip`# Why?
Well, for different kinds of reasons you might want to know what your local
ip address is so you can broadcast it to different services.# API
## localip(interface, [callback])
__interface__ should be a network interface, such as wlan0.
__callback__ is optional, and will be invoked with the signature `callback(err, res)` if specified. If no callback is specified, the value will be returned directly, or an Error will be thrown in case of an error.# Example
```js
var localip = require('local-ip');
var iface = 'wlan0';localip(iface, function(err, res) {
if (err) {
throw new Error('I have no idea what my local ip is.');
}
console.log('My local ip address on ' + iface + ' is ' + res);
});
```You can also use it in sync mode:
```js
var iface = 'wlan0';
var localip = require('local-ip')(iface);
console.log('My local ip address on ' + iface + ' is ' + localip);
```# License
MIT