Skip to content

Instantly share code, notes, and snippets.

@commonquail
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save commonquail/268e6e66e2e0fbe0e742 to your computer and use it in GitHub Desktop.
Save commonquail/268e6e66e2e0fbe0e742 to your computer and use it in GitHub Desktop.
Notes for filtering IPVanish servers

Server list at https://www.ipvanish.com/api/servers.geojson

No CORS. Copy the JavaScript functions below into the console and confirm. Copy all the (JSON) output in the browser window into the console, into a variable named e.g. everything. Copy the final line, then play arround with the all array.

var sortCountriesByCode = function(a, b) {
return a.countryCode.localeCompare(b.countryCode);
};
var unpackProperties = function(properties) {
return {
countryCode: properties.countryCode,
country: properties.country,
city: properties.city,
capacity: properties.capacity,
continent: properties.continent,
continentCode: properties.continentCode,
hostname: properties.hostname,
ip: properties.ip,
online: properties.online,
title: properties.title,
};
};
var unpackEntry = function(acc, item) {
acc.push(unpackProperties(item.properties));
return acc;
};
var everything = JSON.parse(document.body.textContent);
var all = everything.reduce(unpackEntry, []).sort(sortCountriesByCode);
var byCountryCode = function(code) {
return function(item) {
return item.countryCode === code;
};
}
var inSweden = byCountryCode('SE');
all.filter(inSweden);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment