Identified all of the private IP addresses

Converted indexOf matchings to a single regular expression and added support for 172.16 - 31.x.x.
This commit is contained in:
phistuck 2015-01-27 10:04:49 +02:00
parent 07daef3320
commit 5051823805

View file

@ -79,8 +79,8 @@
var li = document.createElement("li"); var li = document.createElement("li");
li.textContent = ip; li.textContent = ip;
//local IPs (TODO: 172.16.0.0/12) //local IPs
if(ip.indexOf("10.") === 0 || ip.indexOf("192.168.") === 0) if (ip.match(/^(192\.168\.|10\.|172\.(1[6-9]|2\d|3[01]))/))
document.getElementsByTagName("ul")[0].appendChild(li); document.getElementsByTagName("ul")[0].appendChild(li);
//assume the rest are public IPs //assume the rest are public IPs