Give server operators more control over client validation.
This commit is contained in:
@@ -476,11 +476,25 @@ namespace OpenRA.Server
|
|||||||
|
|
||||||
delayedActions.Add(() =>
|
delayedActions.Add(() =>
|
||||||
{
|
{
|
||||||
if (Dedicated && Settings.RequireAuthIDs.Any() &&
|
var notAuthenticated = Dedicated && profile == null && (Settings.RequireAuthentication || Settings.ProfileIDWhitelist.Any());
|
||||||
(profile == null || !Settings.RequireAuthIDs.Contains(profile.ProfileID)))
|
var blacklisted = Dedicated && profile != null && Settings.ProfileIDBlacklist.Contains(profile.ProfileID);
|
||||||
|
var notWhitelisted = Dedicated && Settings.ProfileIDWhitelist.Any() &&
|
||||||
|
(profile == null || !Settings.ProfileIDWhitelist.Contains(profile.ProfileID));
|
||||||
|
|
||||||
|
if (notAuthenticated)
|
||||||
{
|
{
|
||||||
Log.Write("server", "Rejected connection from {0}; Not in server whitelist.", newConn.Socket.RemoteEndPoint);
|
Log.Write("server", "Rejected connection from {0}; Not authenticated.", newConn.Socket.RemoteEndPoint);
|
||||||
SendOrderTo(newConn, "ServerError", "You are not authenticated for this server");
|
SendOrderTo(newConn, "ServerError", "Server requires players to have an OpenRA forum account");
|
||||||
|
DropClient(newConn);
|
||||||
|
}
|
||||||
|
else if (blacklisted || notWhitelisted)
|
||||||
|
{
|
||||||
|
if (blacklisted)
|
||||||
|
Log.Write("server", "Rejected connection from {0}; In server blacklist.", newConn.Socket.RemoteEndPoint);
|
||||||
|
else
|
||||||
|
Log.Write("server", "Rejected connection from {0}; Not in server whitelist.", newConn.Socket.RemoteEndPoint);
|
||||||
|
|
||||||
|
SendOrderTo(newConn, "ServerError", "You do not have permission to join this server");
|
||||||
DropClient(newConn);
|
DropClient(newConn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -494,10 +508,10 @@ namespace OpenRA.Server
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Dedicated && Settings.RequireAuthIDs.Any())
|
if (Dedicated && (Settings.RequireAuthentication || Settings.ProfileIDWhitelist.Any()))
|
||||||
{
|
{
|
||||||
Log.Write("server", "Rejected connection from {0}; Not authenticated and whitelist is set.", newConn.Socket.RemoteEndPoint);
|
Log.Write("server", "Rejected connection from {0}; Not authenticated.", newConn.Socket.RemoteEndPoint);
|
||||||
SendOrderTo(newConn, "ServerError", "You are not authenticated for this server");
|
SendOrderTo(newConn, "ServerError", "Server requires players to have an OpenRA forum account");
|
||||||
DropClient(newConn);
|
DropClient(newConn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -59,8 +59,14 @@ namespace OpenRA
|
|||||||
[Desc("Takes a comma separated list of IP addresses that are not allowed to join.")]
|
[Desc("Takes a comma separated list of IP addresses that are not allowed to join.")]
|
||||||
public string[] Ban = { };
|
public string[] Ban = { };
|
||||||
|
|
||||||
[Desc("If non-empty, only allow authenticated players with these user IDs to join.")]
|
[Desc("For dedicated servers only, allow anonymous clients to join.")]
|
||||||
public int[] RequireAuthIDs = { };
|
public bool RequireAuthentication = false;
|
||||||
|
|
||||||
|
[Desc("For dedicated servers only, if non-empty, only allow authenticated players with these profile IDs to join.")]
|
||||||
|
public int[] ProfileIDWhitelist = { };
|
||||||
|
|
||||||
|
[Desc("For dedicated servers only, if non-empty, always reject players with these user IDs from joining.")]
|
||||||
|
public int[] ProfileIDBlacklist = { };
|
||||||
|
|
||||||
[Desc("For dedicated servers only, controls whether a game can be started with just one human player in the lobby.")]
|
[Desc("For dedicated servers only, controls whether a game can be started with just one human player in the lobby.")]
|
||||||
public bool EnableSingleplayer = false;
|
public bool EnableSingleplayer = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user