Skip to content
Browse files

Initial Commit

  • Loading branch information...
0 parents commit f53a10f8db6ac3beb42a7f78a20c33727945dbf9 @davglass committed Sep 15, 2011
Showing with 138 additions and 0 deletions.
  1. +30 −0 LICENSE
  2. +52 −0 README.md
  3. +8 −0 examples/example.js
  4. +30 −0 lib/check.js
  5. +18 −0 package.json
30 LICENSE
@@ -0,0 +1,30 @@
+Software License Agreement (BSD License)
+
+Copyright (c) 2011, Dav Glass <davglass@gmail.com>.
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+* The name of Dav Glass may not be used to endorse or promote products
+ derived from this software without specific prior
+ written permission of Dav Glass.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
52 README.md
@@ -0,0 +1,52 @@
+Get Your Current IP
+-------------------
+
+A simple module to get your ip address from a remote source.
+It's useful if you are behind a NAT and need to display your
+current IP address.
+
+Usage
+-----
+
+ $ checkip
+ 123.123.123.123
+
+
+ var checkip = require('checkip');
+ checkip(function(ip) {
+ console.log('Your current remote ip: ', ip);
+ });
+
+License
+-------
+
+Software License Agreement (BSD License)
+
+Copyright (c) 2011, Dav Glass <davglass@gmail.com>.
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+* The name of Dav Glass may not be used to endorse or promote products
+ derived from this software without specific prior
+ written permission of Dav Glass.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
8 examples/example.js
@@ -0,0 +1,8 @@
+#!/usr/bin/env node
+
+var checkip = require(__dirname + '/../lib/check');
+
+checkip(function(ip) {
+ console.log('Current IP: ', ip);
+});
+
30 lib/check.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+var http = require('http'),
+ regEx = /Current IP Address: (\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)/,
+ url = 'http://checkip.dyndns.org/',
+ isRequired = (process.mainModule.filename !== __filename);
+
+
+var getIP = function(cb) {
+ http.get({
+ host: 'checkip.dyndns.org',
+ path: '/'
+ }, function(res) {
+ var html = '';
+ res.on('data', function(chunk) {
+ html += chunk;
+ });
+ res.on('end', function() {
+ var ip = html.match(regEx)[1];
+ cb(ip);
+ });
+ });
+};
+
+module.exports = getIP;
+
+if (!isRequired) {
+ getIP(console.log);
+}
+
18 package.json
@@ -0,0 +1,18 @@
+{
+ "name": "checkip",
+ "description": "Get's your current IP address (if behind a NAT).",
+ "version": "0.1.0",
+ "author": "Dav Glass <davglass@gmail.com>",
+ "keywords": [
+ "ipaddress",
+ "ip",
+ "nat"
+ ],
+ "bin": {
+ "checkip": "./lib/check.js"
+ },
+ "engines": {
+ "node": ">=0.4.0"
+ },
+ "preferGlobal": "true"
+}

0 comments on commit f53a10f

Please sign in to comment.
Something went wrong with that request. Please try again.