Skip to content

Commit

Permalink
Made server sharding support white-list only.
Browse files Browse the repository at this point in the history
  • Loading branch information
TLeonardUK committed Mar 19, 2024
1 parent 88a842c commit 855770a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Source/MasterServer/src/routes/api/v1/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ var GCensors = [

];

// List of public hostnames that are allowed to mark their servers as supporting sharding.
var ShardingAllowList = [
"172.105.11.166"
];

var GOldestSupportedVersion = 2;

function IsFiltered(Name)
Expand Down Expand Up @@ -75,6 +80,20 @@ function IsServerCensored(ServerInfo)
IsCensored(ServerInfo['Hostname']);
}

function IsServerAllowedToShard(ServerInfo)
{
var NameLower = ServerInfo['Hostname'].toLowerCase();
for (var i = 0; i < ShardingAllowList.length; i++)
{
if (NameLower == ShardingAllowList[i])
{
return true;
}
}

return false;
}

function RemoveServer(Id)
{
for (var i = 0; i < GActiveServers.length; i++)
Expand Down Expand Up @@ -110,7 +129,13 @@ function AddServer(Id, IpAddress, hostname, private_hostname, description, name,
"UpdatedTime": Date.now(),
"Version": version,
"Censored": false
};
};

if (!IsServerAllowedToShard(ServerObj) && allow_sharding)
{
console.log(`Dropped server, marked to allow sharding but not whitelsited: id=${Id} ip=${IpAddress} port=${port} type=${game_type} name=${name}`);
return;
}

if (IsServerFilter(ServerObj))
{
Expand Down

0 comments on commit 855770a

Please sign in to comment.