From 40080ae652796aee7dc978b3d7c0fb9658f5df7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Farka=C5=A1?= Date: Sat, 11 Jan 2025 21:00:23 +0100 Subject: [PATCH] ip fix --- server/helpers.js | 8 ++++---- web/js/main.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/helpers.js b/server/helpers.js index 4bbf442..73e9a18 100644 --- a/server/helpers.js +++ b/server/helpers.js @@ -1,4 +1,4 @@ -const https = require('https'); +const http = require('http'); const net = require('net'); const crypto = require('crypto'); const dataHandler = require('./datahandler'); @@ -57,7 +57,7 @@ function authenticateWithXdrd(client, salt, password) { } function handleConnect(clientIp, currentUsers, ws) { - https.get(`https://ipinfo.io/${clientIp}/json`, (response) => { + http.get(`https://ip-api.com/json/${clientIp}/`, (response) => { let data = ''; response.on('data', (chunk) => { @@ -70,7 +70,7 @@ function handleConnect(clientIp, currentUsers, ws) { const options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }; const connectionTime = new Date().toLocaleString([], options); - if (locationInfo.org?.includes("AS205016 HERN Labs AB")) { // anti opera VPN block + if (locationInfo.as?.includes("AS205016 HERN Labs AB")) { // anti opera VPN block return; } @@ -79,7 +79,7 @@ function handleConnect(clientIp, currentUsers, ws) { storage.connectedUsers.push(userData); consoleCmd.logInfo(`Web client \x1b[32mconnected\x1b[0m (${clientIp}) \x1b[90m[${currentUsers}]\x1b[0m`); } else { - const userLocation = `${locationInfo.city}, ${locationInfo.region}, ${locationInfo.country}`; + const userLocation = `${locationInfo.city}, ${locationInfo.regionName}, ${locationInfo.countryCode}`; const userData = { ip: clientIp, location: userLocation, time: connectionTime, instance: ws }; storage.connectedUsers.push(userData); consoleCmd.logInfo(`Web client \x1b[32mconnected\x1b[0m (${clientIp}) \x1b[90m[${currentUsers}]\x1b[0m Location: ${locationInfo.city}, ${locationInfo.region}, ${locationInfo.country}`); diff --git a/web/js/main.js b/web/js/main.js index 8c0cb08..3699e75 100644 --- a/web/js/main.js +++ b/web/js/main.js @@ -18,7 +18,7 @@ const europe_programmes = [ "Serious Classical", "Other Music", "Weather", "Finance", "Children's Programmes", "Social Affairs", "Religion", "Phone-in", "Travel", "Leisure", "Jazz Music", "Country Music", "National Music", - "Oldies Music", "Folk Music", "Documentary", "Alarm Test" + "Oldies Music", "Folk Music", "Documentary", "Alarm Test", "Alarm" ]; const usa_programmes = [