gluetun
gluetun copied to clipboard
fix(cyberghost): update cyberghost servers list
Cyberghost servers list is not up to date. For example, impossible to connect to hosts in Vietnam.
But it seems the Cyberghost API used is not available anymore. For now, I just updated the list with a small script doing a dig
on the hostnames, and putting every A
records inside it.
You can check it:
const fs = require('fs');
const dns = require('dns');
const path = require('path');
// Read the JSON file
const filePath = path.join(__dirname, 'cg.json');
const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
// Function to perform DNS lookup and update IPs
const updateIPs = async (hostname) => {
return new Promise((resolve, reject) => {
dns.resolve(hostname, 'A', (err, addresses) => {
if (err) {
console.error(`Failed to resolve ${hostname}:`, err);
return resolve([]); // Resolve with an empty array on error
}
resolve(addresses);
});
});
};
// Function to process each server entry
const processServers = async () => {
for (let server of data.cyberghost.servers) {
console.log(`Processing ${server.hostname} for ${server.country}...`);
const updatedIPs = await updateIPs(server.hostname);
if (updatedIPs.length > 0) {
server.ips = updatedIPs;
console.log(`Updated IPs for ${server.hostname}:`, updatedIPs);
} else {
console.log(`No IPs found for ${server.hostname}.`);
}
}
// Write the updated JSON back to the file
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
console.log(`Updated JSON saved to ${filePath}`);
};
// Start the process
processServers().catch(error => {
console.error('Error processing servers:', error);
});