Skip to content

Instantly share code, notes, and snippets.

@b4dtR1p
Created May 28, 2015 21:35
Show Gist options
  • Save b4dtR1p/a122b91b5cc3b0b5003a to your computer and use it in GitHub Desktop.
Save b4dtR1p/a122b91b5cc3b0b5003a to your computer and use it in GitHub Desktop.
#!/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