get p2pServers without using eval

merge-requests/521/merge^2
Moe 2024-10-10 15:11:32 -07:00
parent 290541b976
commit 4f1df193a0
1 changed files with 9 additions and 5 deletions

View File

@ -69,15 +69,19 @@ module.exports = function(s,config,lang,app){
}
}
}
// get latest
fetch('https://cdn.shinobi.video/configs/p2pServers.js')
.then(res => res.text())
.then((text) => {
try{
eval(`config.p2pServerList = ` + text)
}catch(err){
s.debugLog(err)
try {
const parsedData = new Function(`return ${text}`)();
config.p2pServerList = parsedData;
} catch (err) {
s.debugLog(`Failed to parse server list: ${err.message}`);
}
})
.catch((error) => {
s.debugLog(`Fetch error: ${error.message}`);
});
}
if(!config.p2pHostSelected)config.p2pHostSelected = config.useBetterP2P ? 'paris-1-v2' : 'paris-1'