mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-25 16:54:41 +00:00
[frontend] Generate web token at runtime (#3462)
Rather than having that hardcoded one like before. Also adds infrastructure which should make it easier to setup defaults at runtime (e.g. GPU stuff?) Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3462 Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: Lizzie <lizzie@eden-emu.dev>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
@@ -12,7 +12,8 @@ add_library(frontend_common STATIC
|
||||
firmware_manager.cpp
|
||||
data_manager.h data_manager.cpp
|
||||
play_time_manager.cpp
|
||||
play_time_manager.h)
|
||||
play_time_manager.h
|
||||
settings_generator.h settings_generator.cpp)
|
||||
|
||||
if (ENABLE_UPDATE_CHECKER)
|
||||
target_link_libraries(frontend_common PRIVATE httplib::httplib)
|
||||
@@ -29,4 +30,6 @@ if (ENABLE_UPDATE_CHECKER)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(frontend_common)
|
||||
target_link_libraries(frontend_common PUBLIC core SimpleIni::SimpleIni PRIVATE common Boost::headers)
|
||||
target_link_libraries(frontend_common
|
||||
PUBLIC core SimpleIni::SimpleIni frozen::frozen-headers
|
||||
PRIVATE common Boost::headers)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <random>
|
||||
#include <frozen/string.h>
|
||||
#include "common/settings.h"
|
||||
#include "settings_generator.h"
|
||||
|
||||
namespace FrontendCommon {
|
||||
|
||||
void GenerateSettings() {
|
||||
static std::random_device rd;
|
||||
|
||||
// Web Token //
|
||||
auto &token_setting = Settings::values.eden_token;
|
||||
if (token_setting.GetValue().empty()) {
|
||||
static constexpr const size_t token_length = 48;
|
||||
static constexpr const frozen::string token_set = "abcdefghijklmnopqrstuvwxyz";
|
||||
static std::uniform_int_distribution<int> token_dist(0, token_set.size() - 1);
|
||||
std::string result;
|
||||
|
||||
for (size_t i = 0; i < token_length; ++i) {
|
||||
size_t idx = token_dist(rd);
|
||||
result += token_set[idx];
|
||||
}
|
||||
|
||||
token_setting.SetValue(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace FrontendCommon {
|
||||
|
||||
/**
|
||||
* @brief GenerateSettings Generate platform-specific or randomized settings.
|
||||
* Run this function at initialization time for your frontend.
|
||||
*/
|
||||
void GenerateSettings();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user