mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
984 B
30 lines
984 B
4 years ago
|
'use strict';
|
||
|
|
||
|
const countries = require('i18n-iso-countries')
|
||
|
, countryNamesMap = countries.getNames('en')
|
||
4 years ago
|
, extraCountryCodes = ['EU', 'XX', 'T1']
|
||
|
, anonymizerCountryCodes = ['TOR', 'LOKI']
|
||
|
, anonymizerCountryCodesSet = new Set(anonymizerCountryCodes)
|
||
|
, countryCodes = Object.keys(countryNamesMap)
|
||
|
.concat(extraCountryCodes, anonymizerCountryCodes);
|
||
4 years ago
|
|
||
4 years ago
|
//this dumb library conveniently includes 2 names for some countries...
|
||
|
Object.entries(countryNamesMap)
|
||
4 years ago
|
.filter(e => Array.isArray(e[1])) //for any country with an array of names,
|
||
|
.forEach(c => countryNamesMap[c[0]] = c[1][0]) //use the first name
|
||
4 years ago
|
|
||
4 years ago
|
countryNamesMap['EU'] = 'Europe';
|
||
4 years ago
|
countryNamesMap['XX'] = 'Unknown';
|
||
|
countryNamesMap['T1'] = 'Tor Exit Node';
|
||
4 years ago
|
countryNamesMap['TOR'] = 'Tor Hidden Service';
|
||
|
countryNamesMap['LOKI'] = 'Lokinet SNApp';
|
||
4 years ago
|
|
||
4 years ago
|
module.exports = {
|
||
|
countryNamesMap,
|
||
|
countryCodes,
|
||
4 years ago
|
countryCodesSet: new Set(countryCodes),
|
||
4 years ago
|
isAnonymizer: (code) => {
|
||
|
return anonymizerCountryCodesSet.has(code);
|
||
|
},
|
||
4 years ago
|
}
|