Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ MaxConnections: 20
MaxGamePeers: 0
TickTimeBudget: 2000

#Optional Override for Region List
#RegionList:
# - Asia
# - Europe


# Settings database
# Requires LUXON_SERVER_ENABLE_SETTINGS_DATABASE
Expand Down
7 changes: 7 additions & 0 deletions include/luxon/server/server_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct HttpServerConfig {
///
struct ServerManagerConfig {
std::vector<ServerConfig> servers;
std::vector<std::string> region_list;
bool enable_ipv6 = true;
bool no_banner = false;
unsigned max_connections = 0;
Expand Down Expand Up @@ -175,9 +176,15 @@ class ServerManager {
Hookpoints hookpoints;
#endif

// For use by the handler_nameserver
const std::vector<std::string>& get_region_list() const { return region_list_; }

private:
SockSelector sock_selector_;

// For use by the handler_nameserver
std::vector<std::string> region_list_;

std::shared_ptr<logger> log_;
std::vector<ServerConfig> configs_;
std::unordered_map<uint16_t, enet::EnetServer> servers_;
Expand Down
7 changes: 6 additions & 1 deletion src/handler_nameserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ Awaitable<> NameServerHandler::HandleOperationRequest(ser::OperationRequestMessa
case OpCodes::RpcAndMisc::GetRegions: {
ZoneScopedN("HandleOperationRequest_GetRegions");

// Build dummy response with all regions
// Build dummy response with all regions unless overidden by config
std::vector<std::string> regions = {"asia", "au", "cae", "cn", "eu", "hk", "in", "jp", "za", "sa", "kr", "tr", "uae", "us", "usw", "ussc"};
const std::vector<std::string>& regions_from_yml = server_manager_.get_region_list();

if( regions_from_yml.empty() == false ) {
regions = regions_from_yml;
}

std::vector<std::string> addresses(regions.size());
for (size_t i = 0; i < regions.size(); ++i)
Expand Down
22 changes: 22 additions & 0 deletions src/server_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,25 @@ ServerManagerConfig ServerManager::parse_config(const std::string& config_conten

if (key == "Servers") {
ParseServersSection(config, section);
} else if (key == "RegionList") {
if (section.IsScalar()) {
config.region_list.push_back(section.As<std::string>());
} else if( section.IsSequence() ) {
for (Yaml::Iterator it = section.Begin(); it != section.End(); it.operator++(1)) {
Yaml::Node& region_node = (*it).second;
if (region_node.IsScalar()) {
config.region_list.push_back(region_node.As<std::string>());
} else {
create_logger("ConfigParser")
->warn("The 'RegionList' must be a valid scalar or valid sequence in yml. It is not, so the default value will be used.");
config.region_list.clear();
break;
}
}
} else {
create_logger("ConfigParser")
->warn("The 'RegionList' must be a valid scalar or valid sequence in yml. It is not, so the default value will be used.");
}
} else if (key == "External") {
create_logger("ConfigParser")
->warn("The 'External' configuration block is deprecated and will be ignored. Please migrate to using 'proxies' within the 'Servers' block.");
Expand Down Expand Up @@ -443,6 +462,9 @@ ServerManager::ServerManager(ServerManagerConfig config
config.no_banner = true;
#endif

// Fill in the region list for the handler_nameserver
region_list_ = (std::move(config.region_list));

if (!config.no_banner) {
static bool banner_printed = false;
if (!banner_printed) {
Expand Down