Fix private IP address for IPv6

This commit is contained in:
Jonathan Wong 2015-11-15 10:16:06 -08:00
parent 98411f0715
commit 18b328a387

View file

@ -232,7 +232,9 @@ function getPlatformImagePath(platformName) {
function isPrivateIP(ip_address) { function isPrivateIP(ip_address) {
if (ip_address.indexOf(".") > -1) { if (ip_address.indexOf(".") > -1) {
var parts = ip_address.split('.'); // get IPv4 mapped address (xxx.xxx.xxx.xxx) from IPv6 addresss (::ffff:xxx.xxx.xxx.xxx)
var parts = ip_address.split(":");
var parts = parts[parts.length - 1].split('.');
if (parts[0] === '10' || if (parts[0] === '10' ||
(parts[0] === '172' && (parseInt(parts[1], 10) >= 16 && parseInt(parts[1], 10) <= 31)) || (parts[0] === '172' && (parseInt(parts[1], 10) >= 16 && parseInt(parts[1], 10) <= 31)) ||
(parts[0] === '192' && parts[1] === '168')) { (parts[0] === '192' && parts[1] === '168')) {