SysInfo.EXTERNAL_ERROR is undefined

This commit is contained in:
Girish Ramakrishnan
2019-01-24 14:58:04 -08:00
parent 93e0acc8e9
commit db6404a7c6
4 changed files with 14 additions and 13 deletions
+2 -2
View File
@@ -17,14 +17,14 @@ function getPublicIp(callback) {
superagent.get('http://169.254.169.254/metadata/v1.json').timeout(30 * 1000).end(function (error, result) {
if (error || result.statusCode !== 200) {
console.error('Error getting metadata', error);
return callback(new SysInfoError(SysInfoError.INTERNAL_ERROR, 'Could not detect public IP from metadata'));
return callback(new SysInfoError(SysInfoError.EXTERNAL_ERROR, 'Could not detect public IP from metadata'));
}
// Note that we do not use a floating IP for 3 reasons:
// The PTR record is not set to floating IP, the outbound interface is not changeable to floating IP
// and there are reports that port 25 on floating IP is blocked.
var ip = safe.query(result.body, 'interfaces.public[0].ipv4.ip_address');
if (!ip) return callback(new SysInfoError(SysInfoError.INTERNAL_ERROR, 'Could not detect public IP from interface'));
if (!ip) return callback(new SysInfoError(SysInfoError.EXTERNAL_ERROR, 'Could not detect public IP from interface'));
callback(null, ip);
});