complete password protected servers

closes #2290
This commit is contained in:
Matthias Mailänder
2013-10-05 13:02:47 +02:00
parent a6cdcea414
commit b618fc7cc2
17 changed files with 229 additions and 81 deletions

View File

@@ -239,6 +239,14 @@ namespace OpenRA.Server
var handshake = HandshakeResponse.Deserialize(data);
if (!string.IsNullOrEmpty(Settings.Password) && handshake.Password != Settings.Password)
{
var message = string.IsNullOrEmpty(handshake.Password) ? "Server requires a password" : "Incorrect password";
SendOrderTo(newConn, "AuthenticationError", message);
DropClient(newConn);
return;
}
var client = new Session.Client()
{
Name = handshake.Client.Name,
@@ -270,7 +278,7 @@ namespace OpenRA.Server
Log.Write("server", "Rejected connection from {0}; mods do not match.",
newConn.socket.RemoteEndPoint);
SendOrderTo(newConn, "ServerError", "Your mods don't match the server");
SendOrderTo(newConn, "ServerError", "Server is running an incompatible mod");
DropClient(newConn);
return;
}
@@ -283,7 +291,7 @@ namespace OpenRA.Server
Log.Write("server", "Rejected connection from {0}; Not running the same version.",
newConn.socket.RemoteEndPoint);
SendOrderTo(newConn, "ServerError", "Not running the same version.");
SendOrderTo(newConn, "ServerError", "Server is running an incompatible version");
DropClient(newConn);
return;
}
@@ -293,7 +301,7 @@ namespace OpenRA.Server
if (bans.Contains(client.IpAddress))
{
Log.Write("server", "Rejected connection from {0}; Banned.", newConn.socket.RemoteEndPoint);
SendOrderTo(newConn, "ServerError", "You are {0} from the server.".F(Settings.Ban.Contains(client.IpAddress) ? "banned" : "temporarily banned"));
SendOrderTo(newConn, "ServerError", "You have been {0} from the server".F(Settings.Ban.Contains(client.IpAddress) ? "banned" : "temporarily banned"));
DropClient(newConn);
return;
}