Created
May 28, 2015 21:35
-
-
Save b4dtR1p/a122b91b5cc3b0b5003a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
exports.IP = require('http').request({ | |
hostname: 'fugal.net', | |
path: '/ip.cgi', | |
agent: false | |
}, function(res) { | |
if(res.statusCode != 200) { | |
throw new Error('Error: ' + res.statusCode); | |
} | |
res.setEncoding('utf-8'); | |
var ip = ''; | |
res.on('data', function(chunk) {ip += chunk; }); | |
res.on('end', function() { | |
//console.log(ip); | |
return ip; // ipAddress contains the external IP address | |
}); | |
}).on('error', function(err) { | |
throw err; | |
}).end(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment