Comparing version 1.1.0 to 1.1.1
@@ -14,3 +14,4 @@ 'use strict'; | ||
'http://tnx.nl/ip', | ||
'http://myip.dnsomatic.com/' | ||
'http://myip.dnsomatic.com/', | ||
'http://ipecho.net/plain' | ||
]; | ||
@@ -22,2 +23,3 @@ | ||
GetIP.done = false; | ||
GetIP.requests = []; | ||
GetIP.isOnItsLastResponse = function() { return GetIP.completedRequests === services.length }; | ||
@@ -27,16 +29,23 @@ GetIP.completedRequests = 0; | ||
services.forEach( function( service ){ | ||
request( service, function( err, response, address ){ | ||
GetIP.completedRequests++; | ||
GetIP.requests.push( | ||
request( service, function( err, response, address ){ | ||
GetIP.completedRequests++; | ||
if ( address ) address = address.trim(); | ||
if ( address ) address = address.trim(); | ||
if ( GetIP.done === false && thisIsAnIP( address )){ | ||
GetIP.done = true; | ||
callback( null, address, response.request.uri.href ) | ||
} | ||
if ( GetIP.done === false && thisIsAnIP( address )){ | ||
GetIP.done = true; | ||
if ( GetIP.done === false && GetIP.isOnItsLastResponse() ){ | ||
callback( new Error( 'All attempts to retrieve your IP address were exhausted' ), null, null ) | ||
} | ||
}); | ||
GetIP.requests.forEach( function( request ){ | ||
request.abort() | ||
}); | ||
callback( null, address, response.request.uri.href ) | ||
} | ||
if ( GetIP.done === false && GetIP.isOnItsLastResponse() ){ | ||
callback( new Error( 'All attempts to retrieve your IP address were exhausted' ), null, null ) | ||
} | ||
}) | ||
) | ||
}) | ||
@@ -43,0 +52,0 @@ } |
{ | ||
"name": "moira", | ||
"description": "Most Outstanding IP Reporting Assistant", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"homepage": "https://github.com/mjhasbach/MOIRA", | ||
@@ -9,2 +9,10 @@ "main": "lib/moira.js", | ||
"dependencies": { | ||
"request": ">= 2.34.0" | ||
}, | ||
"scripts": { | ||
"test": "node test/test" | ||
}, | ||
"keywords": [ | ||
@@ -35,6 +43,2 @@ "external", | ||
"dependencies": { | ||
"request": ">= 2.34.0" | ||
}, | ||
"bugs": { | ||
@@ -41,0 +45,0 @@ "url": "https://github.com/mjhasbach/MOIRA/issues" |
@@ -6,3 +6,3 @@ # MOIRA | ||
You may install MOIRA via ```npm``` as follows: | ||
You may install MOIRA via NPM as follows: | ||
@@ -13,9 +13,9 @@ npm install moira | ||
### Usage | ||
### Command | ||
#### moira.getIP( callback( ```err```, ```ip```, ```service``` )) | ||
Retrieve your external IP address asynchronously by requesting it from several different IP-fetching services simultaneously. ```moira.getIP()``` reports the quickest result after verifying that it is a valid IP address. ```err``` is null if an IP address was found. ```ip``` is an IPv4 address. ```service``` is the URL of the IP-reporting service that returned ```ip``` (e.g. http://whatismyip.akamai.com/). | ||
Retrieve your external IP address asynchronously by requesting it from several different IP-fetching services simultaneously. ```moira.getIP()``` reports the quickest result after verifying that it is a valid IP address and terminating all other requests. ```err``` is null if an IP address was found. ```ip``` is an IPv4 address. ```service``` is the URL of the IP-reporting service that returned ```ip``` (e.g. http://whatismyip.akamai.com/). | ||
Example (see test/test.js): | ||
Example: | ||
@@ -31,4 +31,8 @@ var moira = require( 'moira' ); | ||
### Test | ||
npm test | ||
### Improving MOIRA | ||
If you would like to contribute code or simply add an IP reporting service, feel free to submit a pull request. Please report issues [here](https://github.com/mjhasbach/MOIRA/issues). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5439
49
35