mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 07:43:01 +01:00
Feature: Add allowed_hosts to plugin section of config
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
- Feature: [#13495] [Plugin] Add properties for park value, guests and company value.
|
- Feature: [#13495] [Plugin] Add properties for park value, guests and company value.
|
||||||
- Feature: [#13509] [Plugin] Add ability to format strings using OpenRCT2 string framework.
|
- Feature: [#13509] [Plugin] Add ability to format strings using OpenRCT2 string framework.
|
||||||
- Feature: [#13512] [Plugin] Add item separators to list view.
|
- Feature: [#13512] [Plugin] Add item separators to list view.
|
||||||
|
- Feature: Add allowed_hosts to plugin section of config
|
||||||
- Change: [#13346] Change FootpathScenery to FootpathAddition in all occurrences.
|
- Change: [#13346] Change FootpathScenery to FootpathAddition in all occurrences.
|
||||||
- Fix: [#12895] Mechanics are called to repair rides that have already been fixed.
|
- Fix: [#12895] Mechanics are called to repair rides that have already been fixed.
|
||||||
- Fix: [#13257] Rides that are exactly the minimum objective length are not counted.
|
- Fix: [#13257] Rides that are exactly the minimum objective length are not counted.
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ namespace Config
|
|||||||
{
|
{
|
||||||
auto model = &gConfigPlugin;
|
auto model = &gConfigPlugin;
|
||||||
model->enable_hot_reloading = reader->GetBoolean("enable_hot_reloading", false);
|
model->enable_hot_reloading = reader->GetBoolean("enable_hot_reloading", false);
|
||||||
|
model->allowed_hosts = reader->GetString("allowed_hosts", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,6 +546,7 @@ namespace Config
|
|||||||
auto model = &gConfigPlugin;
|
auto model = &gConfigPlugin;
|
||||||
writer->WriteSection("plugin");
|
writer->WriteSection("plugin");
|
||||||
writer->WriteBoolean("enable_hot_reloading", model->enable_hot_reloading);
|
writer->WriteBoolean("enable_hot_reloading", model->enable_hot_reloading);
|
||||||
|
writer->WriteString("allowed_hosts", model->allowed_hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool SetDefaults()
|
static bool SetDefaults()
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ struct FontConfiguration
|
|||||||
struct PluginConfiguration
|
struct PluginConfiguration
|
||||||
{
|
{
|
||||||
bool enable_hot_reloading;
|
bool enable_hot_reloading;
|
||||||
|
std::string allowed_hosts;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SORT
|
enum SORT
|
||||||
|
|||||||
@@ -83,6 +83,22 @@ namespace OpenRCT2::Scripting
|
|||||||
return s == "localhost" || s == "127.0.0.1" || s == "::";
|
return s == "localhost" || s == "127.0.0.1" || s == "::";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsOnWhiteList(std::string_view host)
|
||||||
|
{
|
||||||
|
constexpr char delimiter = ',';
|
||||||
|
size_t start_pos = 0;
|
||||||
|
size_t end_pos = 0;
|
||||||
|
while ((end_pos = gConfigPlugin.allowed_hosts.find(delimiter, start_pos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
if (host == gConfigPlugin.allowed_hosts.substr(start_pos, end_pos - start_pos))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
start_pos = end_pos + 1;
|
||||||
|
}
|
||||||
|
return host == gConfigPlugin.allowed_hosts.substr(start_pos, gConfigPlugin.allowed_hosts.length() - start_pos);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScSocketBase(const std::shared_ptr<Plugin>& plugin)
|
ScSocketBase(const std::shared_ptr<Plugin>& plugin)
|
||||||
: _plugin(plugin)
|
: _plugin(plugin)
|
||||||
@@ -166,7 +182,7 @@ namespace OpenRCT2::Scripting
|
|||||||
{
|
{
|
||||||
duk_error(ctx, DUK_ERR_ERROR, "Socket is already connecting.");
|
duk_error(ctx, DUK_ERR_ERROR, "Socket is already connecting.");
|
||||||
}
|
}
|
||||||
else if (!IsLocalhostAddress(host))
|
else if (!IsLocalhostAddress(host) && !IsOnWhiteList(host))
|
||||||
{
|
{
|
||||||
duk_error(ctx, DUK_ERR_ERROR, "For security reasons, only connecting to localhost is allowed.");
|
duk_error(ctx, DUK_ERR_ERROR, "For security reasons, only connecting to localhost is allowed.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user