Make the adhoc server list data driven

This commit is contained in:
Henrik Rydgård
2026-03-05 14:54:23 +01:00
parent 2a1cefb58b
commit 962d132e5f
8 changed files with 168 additions and 21 deletions
+1
View File
@@ -2851,6 +2851,7 @@ set(NativeAssets
assets/Inconsolata-Regular.ttf
assets/7z.png
assets/compat.ini
assets/adhoc-servers.json
assets/infra-dns.json
assets/gamecontrollerdb.txt
assets/langregion.ini
+1 -1
View File
@@ -409,7 +409,7 @@ bool PollInfraJsonDownload(std::string *jsonOutput) {
std::unique_ptr<uint8_t[]> jsonStr(g_VFS.ReadFile("infra-dns.json", &jsonSize));
if (!jsonStr) {
jsonOutput->clear();
return true; // A clear output but returning true means something vent very wrong.
return true; // A clear output but returning true means something went very wrong.
}
*jsonOutput = std::string((const char *)jsonStr.get(), jsonSize);
// In case there's an old request, get rid of it.
+51 -16
View File
@@ -24,12 +24,14 @@
#include <string>
#include "Common/Net/SocketCompat.h"
#include "Common/Data/Format/JSONReader.h"
#include "Common/Data/Text/I18n.h"
#include "Common/Serialize/Serializer.h"
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/Serialize/SerializeMap.h"
#include "Common/System/OSD.h"
#include "Common/System/System.h"
#include "Common/File/VFS/VFS.h"
#include "Common/Thread/ThreadUtil.h"
#include "Common/TimeUtil.h"
@@ -105,25 +107,48 @@ static const char *AdhocDataModeToString(AdhocDataMode mode) {
return "unknown";
}
const std::vector<AdhocServerListEntry> defaultProAdhocServerList = {
{"Socom Adhoc Server", "socom.cc", "https://discord.com/invite/XtVYDr7", "France", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Madness Gaming Network", "psp.mgn.pub", "https://discord.com/invite/kaPScVrPes", "Alaska USA", "For players looking to play any games, has a good amount of Monster Hunter players, also provides VPN to work around connection issues as well as P2P mode", AdhocDataMode::AemuPostoffice},
{"EA Nation Hub", "eahub.eu", "https://discord.com/invite/fwrQHHxrQQ", "France", "Mostly for Medal of Honor Heros 2 & Need For Speed Most Wanted players, but can be used for other games", AdhocDataMode::AemuPostoffice},
{"Psi-Hate", "psi-hate.com", "https://discord.com/invite/wxeGVkM", "Minnesota USA", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Relay Brasileiro", "jpa36a7.glddns.com", "https://discord.com/invite/gp45nhdjQJ", "São Paulo Brazil", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere SA", "relay-sa.arenaanywhere.site", "https://discord.gg/GdsXWmNHq5", "South Africa", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere EU", "relay.arenaanywhere.site", "https://discord.gg/GdsXWmNHq5", "Europe", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere Dubai", "relay-dubai.arenaanywhere.site", "https://discord.gg/GdsXWmNHq5", "Dubai", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Retroverze Relay Beta", "psp.retroverze.my.id", "https://retroverze.my.id/beta", "Unknown", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Games Nexus", "adhoc.gamesnexus.ovh", "https://adhoc.gamesnexus.ovh", "Milan Italy", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Sony PSP & PSVita Fans", "psp.gameplayer.club", "https://psp.gameplayer.club/", "Unknown", "For players looking to play any games", AdhocDataMode::P2P},
};
// TODO download the list from somewhere and probably cache it on disk
// should also make the url configurable and support file:/ local list besides https:// online lists
std::mutex g_proAdhocServerListMutex;
std::vector<AdhocServerListEntry> g_proAdhocServerList;
bool ParseServerListEntriesJSON(std::string_view json, std::vector<AdhocServerListEntry> *result) {
using namespace json;
// Use our JSONReader to parse json into a list of AdhocServerListEntry.
json::JsonReader reader(json.data(), json.length());
if (!reader.ok() || !reader.root()) {
ERROR_LOG(Log::IO, "Error parsing DNS JSON");
return false;
}
const JsonGet root = reader.root();
const JsonNode *servers = root.getArray("servers");
result->clear();
for (const JsonNode *iter : servers->value) {
JsonGet server = iter->value;
AdhocServerListEntry entry;
entry.name = server.getStringOr("name", "");
entry.discord = server.getStringOr("discord", "");
entry.host = server.getStringOr("host", "");
entry.web = server.getStringOr("web", "");
entry.location = server.getStringOr("location", "");
entry.description = server.getStringOr("description", "");
entry.mode = server.getStringOr("data_mode", "") == "AemuPostoffice" ? AdhocDataMode::AemuPostoffice : AdhocDataMode::P2P;
if (entry.host.empty()) {
// Skipping invalid entry.
continue;
}
result->push_back(entry);
}
return true;
}
void AdhocLoadServerList() {
{
std::lock_guard<std::mutex> guard(g_proAdhocServerListMutex);
@@ -139,7 +164,17 @@ void AdhocLoadServerList() {
// 1. Cached list in PSP/SYSTEM/CACHE
// 2. Online list from some url, and cache it in PSP/SYSTEM/CACHE for next time.
std::lock_guard<std::mutex> guard(g_proAdhocServerListMutex);
g_proAdhocServerList = defaultProAdhocServerList;
size_t jsonSize;
std::unique_ptr<uint8_t[]> jsonStr(g_VFS.ReadFile("adhoc-servers.json", &jsonSize));
if (!jsonStr) {
_dbg_assert_(false);
// Something went wrong. This shouldn't happen.
return;
}
ParseServerListEntriesJSON(std::string_view((char*)jsonStr.get(), jsonSize), &g_proAdhocServerList);
System_PostUIMessage(UIMessage::ADHOC_SERVER_LIST_CHANGED);
});
thread.detach();
@@ -153,7 +188,7 @@ std::vector<AdhocServerListEntry> AdhocGetServerList() {
static AdhocDataMode AdhocGetServerDataMode(std::string_view server) {
std::vector<AdhocServerListEntry> list = AdhocGetServerList();
for (const auto &item : list) {
if (equals(server, item.hostname)) {
if (equals(server, item.host)) {
INFO_LOG(Log::sceNet, "server %.*s is in known list, using data mode %s", STR_VIEW(server), AdhocDataModeToString(item.mode));
return item.mode;
}
+4 -3
View File
@@ -105,10 +105,11 @@ enum class AdhocDataMode {
struct AdhocServerListEntry {
std::string name;
std::string hostname;
std::string community_link;
std::string host;
std::string web;
std::string discord;
std::string location;
std::string note;
std::string description;
AdhocDataMode mode = AdhocDataMode::P2P;
};
+1 -1
View File
@@ -41,7 +41,7 @@ void AdhocServerScreen::CreatePopupContents(UI::ViewGroup *parent) {
std::vector<std::string> listIP;
for (const auto &item : listItems) {
listIP.push_back(item.hostname);
listIP.push_back(item.host);
}
// Add non-editable items
+4
View File
@@ -388,6 +388,10 @@
<DeploymentContent>true</DeploymentContent>
<Link>Content\%(Filename)%(Extension)</Link>
</None>
<None Include="..\Assets\adhoc-servers.json">
<DeploymentContent>true</DeploymentContent>
<Link>Content\%(Filename)%(Extension)</Link>
</None>
<None Include="..\Assets\knownfuncs.ini">
<DeploymentContent>true</DeploymentContent>
<Link>Content\%(Filename)%(Extension)</Link>
+3
View File
@@ -216,6 +216,9 @@
<None Include="..\Assets\infra-dns.json">
<Filter>Content</Filter>
</None>
<None Include="..\Assets\adhoc-servers.json">
<Filter>Content</Filter>
</None>
<None Include="..\Assets\redump.csv">
<Filter>Content</Filter>
</None>
+103
View File
@@ -0,0 +1,103 @@
{
"servers": [
{
"name": "Socom Adhoc Server",
"host": "socom.cc",
"discord": "https://discord.com/invite/XtVYDr7",
"web": "",
"location": "France",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "Madness Gaming Network",
"host": "psp.mgn.pub",
"discord": "https://discord.com/invite/kaPScVrPes",
"web": "",
"location": "Alaska USA",
"description": "For players looking to play any games, has a good amount of Monster Hunter players, also provides VPN to work around connection issues as well as P2P mode",
"data_mode": "AemuPostoffice"
},
{
"name": "EA Nation Hub",
"host": "eahub.eu",
"discord": "https://discord.com/invite/fwrQHHxrQQ",
"web": "",
"location": "France",
"description": "Mostly for Medal of Honor Heros 2 & Need For Speed Most Wanted players, but can be used for other games",
"data_mode": "AemuPostoffice"
},
{
"name": "Psi-Hate",
"host": "psi-hate.com",
"discord": "https://discord.com/invite/wxeGVkM",
"web": "",
"location": "Minnesota USA",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "Relay Brasileiro",
"host": "jpa36a7.glddns.com",
"discord": "https://discord.com/invite/gp45nhdjQJ",
"web": "",
"location": "São Paulo Brazil",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "ArenaAnywhere SA",
"host": "relay-sa.arenaanywhere.site",
"discord": "https://discord.gg/GdsXWmNHq5",
"web": "",
"location": "South Africa",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "ArenaAnywhere EU",
"host": "relay.arenaanywhere.site",
"discord": "https://discord.gg/GdsXWmNHq5",
"web": "",
"location": "Europe",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "ArenaAnywhere Dubai",
"host": "relay-dubai.arenaanywhere.site",
"discord": "https://discord.gg/GdsXWmNHq5",
"web": "",
"location": "Dubai",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "Retroverze Relay Beta",
"host": "psp.retroverze.my.id",
"discord": "",
"web": "https://retroverze.my.id/beta",
"location": "Unknown",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "Games Nexus",
"host": "adhoc.gamesnexus.ovh",
"discord": "",
"web": "https://adhoc.gamesnexus.ovh",
"location": "Milan Italy",
"description": "For players looking to play any games",
"data_mode": "AemuPostoffice"
},
{
"name": "Sony PSP & PSVita Fans",
"host": "psp.gameplayer.club",
"discord": "",
"web": "https://psp.gameplayer.club/",
"location": "Unknown",
"description": "For players looking to play any games",
"data_mode": "P2P"
}
]
}