external: minor.

This commit is contained in:
Christopher Jeffrey 2017-07-08 13:37:03 -07:00
parent 15ba37099e
commit 278265536e
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -35,12 +35,11 @@ external.getIPv4 = async function getIPv4() {
return await external.getIPv42();
}
ip = res.body.trim();
try {
ip = res.body.trim();
ip = IP.toBuffer(ip);
if (!IP.isMapped(ip))
if (!IP.isIPv4(ip))
throw new Error('Could not find IPv4.');
ip = IP.toString(ip);
@ -76,7 +75,7 @@ external.getIPv42 = async function getIPv42() {
ip = match[1];
raw = IP.toBuffer(ip);
if (!IP.isMapped(raw))
if (!IP.isIPv4(raw))
throw new Error('Could not find IPv4.');
return IP.toString(raw);
@ -101,7 +100,7 @@ external.getIPv6 = async function getIPv6() {
ip = res.body.trim();
ip = IP.toBuffer(ip);
if (IP.isMapped(ip))
if (!IP.isIPv6(ip))
throw new Error('Could not find IPv6.');
return IP.toString(ip);