mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-24 05:29:01 +02:00
[common/settings] Allow to add custom blocked domains & change hardcoded list
Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
6f9d025ad2
commit
ed5976afda
6 changed files with 146 additions and 13 deletions
|
|
@ -262,6 +262,13 @@ void AndroidConfig::SavePathValues() {
|
||||||
}
|
}
|
||||||
EndArray();
|
EndArray();
|
||||||
|
|
||||||
|
BeginArray(std::string("blocked_domains"));
|
||||||
|
for (size_t i = 0; i < Settings::values.blocked_domains.size(); ++i) {
|
||||||
|
SetArrayIndex(i);
|
||||||
|
WriteStringSetting(std::string("domain"), Settings::values.blocked_domains[i]);
|
||||||
|
}
|
||||||
|
EndArray();
|
||||||
|
|
||||||
// Save custom NAND directory
|
// Save custom NAND directory
|
||||||
const auto nand_path = Common::FS::GetEdenPathString(Common::FS::EdenPath::NANDDir);
|
const auto nand_path = Common::FS::GetEdenPathString(Common::FS::EdenPath::NANDDir);
|
||||||
WriteStringSetting(std::string("nand_directory"), nand_path,
|
WriteStringSetting(std::string("nand_directory"), nand_path,
|
||||||
|
|
|
||||||
|
|
@ -803,9 +803,16 @@ struct Values {
|
||||||
Setting<bool> first_launch{linkage, true, "first_launch", Category::Miscellaneous};
|
Setting<bool> first_launch{linkage, true, "first_launch", Category::Miscellaneous};
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
Setting<std::string> network_interface{linkage, std::string(), "network_interface",
|
Setting<std::string> network_interface{linkage, std::string(), "network_interface", Category::Network};
|
||||||
Category::Network};
|
|
||||||
SwitchableSetting<bool> airplane_mode{linkage, false, "airplane_mode", Category::Network};
|
SwitchableSetting<bool> airplane_mode{linkage, false, "airplane_mode", Category::Network};
|
||||||
|
std::vector<std::string> blocked_domains = {
|
||||||
|
"srv.nintendo.net",
|
||||||
|
"battle.net",
|
||||||
|
"microsoft.com",
|
||||||
|
"mojang.com",
|
||||||
|
"xboxlive.com",
|
||||||
|
"minecraftservices.com"
|
||||||
|
};
|
||||||
|
|
||||||
// WebService
|
// WebService
|
||||||
Setting<std::string> web_api_url{linkage, "api.ynet-fun.xyz", "web_api_url",
|
Setting<std::string> web_api_url{linkage, "api.ynet-fun.xyz", "web_api_url",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common/settings.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
|
@ -53,17 +54,11 @@ enum class NetDbError : s32 {
|
||||||
NoData = 4,
|
NoData = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const constexpr std::array blockedDomains = {"srv.nintendo.net",
|
|
||||||
"battle.net",
|
|
||||||
"microsoft.com",
|
|
||||||
"mojang.com",
|
|
||||||
"xboxlive.com",
|
|
||||||
"minecraftservices.com"};
|
|
||||||
|
|
||||||
static bool IsBlockedHost(const std::string& host) {
|
static bool IsBlockedHost(const std::string& host) {
|
||||||
return std::any_of(
|
auto const& v = Settings::values.blocked_domains;
|
||||||
blockedDomains.begin(), blockedDomains.end(),
|
return std::any_of(v.begin(), v.end(), [&host](const std::string& domain) {
|
||||||
[&host](const std::string& domain) { return host.find(domain) != std::string::npos; });
|
return host.find(domain) != std::string::npos;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static NetDbError GetAddrInfoErrorToNetDbError(GetAddrInfoError result) {
|
static NetDbError GetAddrInfoErrorToNetDbError(GetAddrInfoError result) {
|
||||||
|
|
@ -163,7 +158,17 @@ static std::pair<u32, GetAddrInfoError> GetHostByNameRequestImpl(HLERequestConte
|
||||||
parameters.use_nsd_resolve, parameters.cancel_handle, parameters.process_id);
|
parameters.use_nsd_resolve, parameters.cancel_handle, parameters.process_id);
|
||||||
|
|
||||||
const auto host_buffer = ctx.ReadBuffer(0);
|
const auto host_buffer = ctx.ReadBuffer(0);
|
||||||
const std::string host = Common::StringFromBuffer(host_buffer);
|
|
||||||
|
std::string host = Common::StringFromBuffer(host_buffer);
|
||||||
|
if (parameters.use_nsd_resolve) {
|
||||||
|
// TODO: how its actually done?
|
||||||
|
if (auto const pos = host.find('%'); pos != std::string::npos) {
|
||||||
|
host[pos] = 'l';
|
||||||
|
host.insert(pos, "p1");
|
||||||
|
}
|
||||||
|
LOG_WARNING(Service, "nsd resolve={}", host);
|
||||||
|
}
|
||||||
|
|
||||||
// For now, ignore options, which are in input buffer 1 for GetHostByNameRequestWithOptions.
|
// For now, ignore options, which are in input buffer 1 for GetHostByNameRequestWithOptions.
|
||||||
|
|
||||||
// Prevent resolution of Nintendo servers
|
// Prevent resolution of Nintendo servers
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,16 @@ void QtConfig::ReadPathValues() {
|
||||||
}
|
}
|
||||||
EndArray();
|
EndArray();
|
||||||
|
|
||||||
|
Settings::values.blocked_domains.clear();
|
||||||
|
const int blocked_domains_size = BeginArray(std::string("blocked_domains"));
|
||||||
|
for (int i = 0; i < blocked_domains_size; ++i) {
|
||||||
|
SetArrayIndex(i);
|
||||||
|
if (auto s = ReadStringSetting(std::string("domain")); !s.empty()) {
|
||||||
|
Settings::values.blocked_domains.push_back(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EndArray();
|
||||||
|
|
||||||
ReadCategory(Settings::Category::Paths);
|
ReadCategory(Settings::Category::Paths);
|
||||||
|
|
||||||
EndGroup();
|
EndGroup();
|
||||||
|
|
@ -463,6 +473,13 @@ void QtConfig::SavePathValues() {
|
||||||
}
|
}
|
||||||
EndArray();
|
EndArray();
|
||||||
|
|
||||||
|
BeginArray(std::string("blocked_domains"));
|
||||||
|
for (int i = 0; i < static_cast<int>(Settings::values.blocked_domains.size()); ++i) {
|
||||||
|
SetArrayIndex(i);
|
||||||
|
WriteStringSetting(std::string("domain"), Settings::values.blocked_domains[i]);
|
||||||
|
}
|
||||||
|
EndArray();
|
||||||
|
|
||||||
EndGroup();
|
EndGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "core/internal_network/network_interface.h"
|
#include "core/internal_network/network_interface.h"
|
||||||
#include "ui_configure_network.h"
|
#include "ui_configure_network.h"
|
||||||
#include "yuzu/configuration/configure_network.h"
|
#include "yuzu/configuration/configure_network.h"
|
||||||
|
#include "yuzu/util/limitable_input_dialog.h"
|
||||||
|
|
||||||
ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent)
|
ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent)
|
||||||
: QWidget(parent), ui(std::make_unique<Ui::ConfigureNetwork>()), system{system_} {
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureNetwork>()), system{system_} {
|
||||||
|
|
@ -20,6 +21,26 @@ ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent)
|
||||||
ui->network_interface->addItem(QString::fromStdString(iface.name));
|
ui->network_interface->addItem(QString::fromStdString(iface.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->blocked_domains_list->clear();
|
||||||
|
for (const auto& s : Settings::values.blocked_domains) {
|
||||||
|
ui->blocked_domains_list->addItem(QString::fromStdString(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(ui->add_blocked_domains_button, &QPushButton::pressed, this, [this, parent] {
|
||||||
|
if (const QString s = LimitableInputDialog::GetText(parent, tr("Add blocked domain"), tr("Input DNS match rule"), 0, 64); !s.isEmpty()) {
|
||||||
|
ui->blocked_domains_list->addItem(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(ui->remove_blocked_domains_button, &QPushButton::pressed, this, [this] {
|
||||||
|
auto selected = ui->blocked_domains_list->selectedItems();
|
||||||
|
if (!selected.isEmpty()) {
|
||||||
|
qDeleteAll(ui->blocked_domains_list->selectedItems());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(ui->blocked_domains_list, &QListWidget::itemSelectionChanged, this, [this] {
|
||||||
|
ui->remove_blocked_domains_button->setEnabled(!ui->blocked_domains_list->selectedItems().isEmpty());
|
||||||
|
});
|
||||||
|
|
||||||
this->SetConfiguration();
|
this->SetConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,8 +49,24 @@ ConfigureNetwork::~ConfigureNetwork() = default;
|
||||||
void ConfigureNetwork::ApplyConfiguration() {
|
void ConfigureNetwork::ApplyConfiguration() {
|
||||||
Settings::values.network_interface = ui->network_interface->currentText().toStdString();
|
Settings::values.network_interface = ui->network_interface->currentText().toStdString();
|
||||||
Settings::values.airplane_mode = ui->airplane_mode->isChecked();
|
Settings::values.airplane_mode = ui->airplane_mode->isChecked();
|
||||||
|
|
||||||
|
std::vector<std::string> new_dirs;
|
||||||
|
new_dirs.reserve(ui->blocked_domains_list->count());
|
||||||
|
for (int i = 0; i < ui->blocked_domains_list->count(); ++i) {
|
||||||
|
new_dirs.push_back(ui->blocked_domains_list->item(i)->text().toStdString());
|
||||||
|
}
|
||||||
|
if (new_dirs != Settings::values.blocked_domains) {
|
||||||
|
Settings::values.blocked_domains = std::move(new_dirs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void ConfigureGeneral::UpdateExternalContentList() {
|
||||||
|
// ui->blocked_domains_list->clear();
|
||||||
|
// for (const auto& dir : Settings::values.blocked_domains) {
|
||||||
|
// ui->blocked_domains_list->addItem(QString::fromStdString(dir));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
void ConfigureNetwork::changeEvent(QEvent* event) {
|
void ConfigureNetwork::changeEvent(QEvent* event) {
|
||||||
if (event->type() == QEvent::LanguageChange) {
|
if (event->type() == QEvent::LanguageChange) {
|
||||||
RetranslateUI();
|
RetranslateUI();
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,66 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_blocked_domains">
|
||||||
|
<property name="title">
|
||||||
|
<string>Blocked Domains Content</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_blocked_domains">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_blocked_domains_desc">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add domains to filter out on DNS resolutions</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="blocked_domains_list">
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_blocked_domains_buttons">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="add_blocked_domains_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add Domain</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="remove_blocked_domains_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove Selected</string>
|
||||||
|
</property>
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_blocked_domains">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue