getting POTA spots and updated the getBuffer() function to add a user-agent and referer.

merge-requests/160/head
Matthew Chambers 2022-02-05 11:36:52 -06:00
rodzic cc7742af3d
commit ccc3a29f42
2 zmienionych plików z 28 dodań i 4 usunięć

Wyświetl plik

@ -12781,7 +12781,8 @@ function getBuffer(file_url, callback, flag, mode, port, cache = null)
host: url.parse(file_url).host, // eslint-disable-line node/no-deprecated-api
port: port,
followAllRedirects: true,
path: url.parse(file_url).path // eslint-disable-line node/no-deprecated-api
path: url.parse(file_url).path, // eslint-disable-line node/no-deprecated-api
headers: { "User-Agent": gtVersionString, Referer: "https://gridtracker.org" }
};
http.get(options, function (res)

Wyświetl plik

@ -2,8 +2,8 @@
// All rights reserved.
// See LICENSE for more information.
var g_potaPlace = Object;
var g_potaSpot = Object;
var g_potaPlaces = null;
var g_potaSpots = null;
function g_getPotaPlaces()
{
@ -11,9 +11,32 @@ function g_getPotaPlaces()
// we need to see if ever run and update 1x a week
}
function g_ingestPotaSpots()
{
try
{
g_potaSpots = JSON.parse(buffer);
}
catch (e)
{
// can't write, somethings broke
}
}
function g_getPotaSpots()
{
// if Pota Spotting enabled, get spots
if (g_mapSettings.offlineMode == false)
{
getBuffer(
"https://api.pota.app/spot/activator",
g_ingestPotaSpots,
null,
"http",
80
);
setTimeout(g_getPotaSpots, 300000);
}
}
function g_sendPotaSpot()