Clients aren't allowed to use the same name as the server, changed radio msg color back to yellow
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Barotrauma.Networking
|
|||||||
new Color(204, 74, 78), //error
|
new Color(204, 74, 78), //error
|
||||||
new Color(63, 72, 204), //dead
|
new Color(63, 72, 204), //dead
|
||||||
new Color(157, 225, 160), //server
|
new Color(157, 225, 160), //server
|
||||||
new Color(148, 230, 7), //radio
|
new Color(238, 208, 0), //radio
|
||||||
new Color(228, 199, 27) //private
|
new Color(228, 199, 27) //private
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -103,9 +103,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
//disconnect and ban after too many failed attempts
|
//disconnect and ban after too many failed attempts
|
||||||
banList.BanPlayer("Unnamed", unauthClient.Connection.RemoteEndPoint.Address.ToString());
|
banList.BanPlayer("Unnamed", unauthClient.Connection.RemoteEndPoint.Address.ToString());
|
||||||
unauthClient.Connection.Disconnect("Too many failed login attempts. You have been automatically banned from the server.");
|
DisconnectUnauthClient(inc, unauthClient, "Too many failed login attempts. You have been automatically banned from the server.");
|
||||||
unauthenticatedClients.Remove(unauthClient);
|
|
||||||
unauthClient = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -127,48 +125,47 @@ namespace Barotrauma.Networking
|
|||||||
string clName = Client.SanitizeName(inc.ReadString());
|
string clName = Client.SanitizeName(inc.ReadString());
|
||||||
if (string.IsNullOrWhiteSpace(clName))
|
if (string.IsNullOrWhiteSpace(clName))
|
||||||
{
|
{
|
||||||
unauthClient.Connection.Disconnect("You need a name.");
|
DisconnectUnauthClient(inc, unauthClient, "You need a name.");
|
||||||
unauthenticatedClients.Remove(unauthClient);
|
|
||||||
unauthClient = null;
|
Log(inc.SenderConnection.RemoteEndPoint.Address.ToString() + " couldn't join the server (no name given)", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clVersion != GameMain.Version.ToString())
|
if (clVersion != GameMain.Version.ToString())
|
||||||
{
|
{
|
||||||
inc.SenderConnection.Disconnect("Version " + GameMain.Version + " required to connect to the server (Your version: " + clVersion + ")");
|
DisconnectUnauthClient(inc, unauthClient, "Version " + GameMain.Version + " required to connect to the server (Your version: " + clVersion + ")");
|
||||||
unauthenticatedClients.Remove(unauthClient);
|
Log(clName + " couldn't join the server (wrong game version)", Color.Red);
|
||||||
unauthClient = null;
|
|
||||||
DebugConsole.NewMessage(clName + " couldn't join the server (wrong game version)", Color.Red);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (clPackageName != GameMain.SelectedPackage.Name)
|
if (clPackageName != GameMain.SelectedPackage.Name)
|
||||||
{
|
{
|
||||||
inc.SenderConnection.Disconnect("Your content package (" + clPackageName + ") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")");
|
DisconnectUnauthClient(inc, unauthClient, "Your content package (" + clPackageName + ") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")");
|
||||||
unauthenticatedClients.Remove(unauthClient);
|
Log(clName + " couldn't join the server (wrong content package name)", Color.Red);
|
||||||
unauthClient = null;
|
|
||||||
DebugConsole.NewMessage(clName + " couldn't join the server (wrong content package name)", Color.Red);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (clPackageHash != GameMain.SelectedPackage.MD5hash.Hash)
|
if (clPackageHash != GameMain.SelectedPackage.MD5hash.Hash)
|
||||||
{
|
{
|
||||||
unauthClient.Connection.Disconnect("Your content package (MD5: " + clPackageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")");
|
DisconnectUnauthClient(inc, unauthClient, "Your content package (MD5: " + clPackageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")");
|
||||||
unauthenticatedClients.Remove(unauthClient);
|
Log(clName + " couldn't join the server (wrong content package hash)", Color.Red);
|
||||||
unauthClient = null;
|
|
||||||
DebugConsole.NewMessage(clName + " couldn't join the server (wrong content package hash)", Color.Red);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!whitelist.IsWhiteListed(clName, inc.SenderConnection.RemoteEndPoint.Address.ToString()))
|
if (!whitelist.IsWhiteListed(clName, inc.SenderConnection.RemoteEndPoint.Address.ToString()))
|
||||||
{
|
{
|
||||||
inc.SenderConnection.Disconnect("You're not in this server's whitelist.");
|
DisconnectUnauthClient(inc, unauthClient, "You're not in this server's whitelist.");
|
||||||
DebugConsole.NewMessage(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (not in whitelist)", Color.Red);
|
Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (not in whitelist)", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Client.IsValidName(clName))
|
if (!Client.IsValidName(clName))
|
||||||
{
|
{
|
||||||
unauthClient.Connection.Disconnect("Your name contains illegal symbols.");
|
DisconnectUnauthClient(inc, unauthClient, "Your name contains illegal symbols.");
|
||||||
unauthenticatedClients.Remove(unauthClient);
|
Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (invalid name)", Color.Red);
|
||||||
unauthClient = null;
|
return;
|
||||||
|
}
|
||||||
|
if (clName.ToLower() == Name.ToLower())
|
||||||
|
{
|
||||||
|
DisconnectUnauthClient(inc, unauthClient, "That name is taken.");
|
||||||
|
Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (name taken by the server)", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Client nameTaken = ConnectedClients.Find(c => c.name.ToLower() == clName.ToLower());
|
Client nameTaken = ConnectedClients.Find(c => c.name.ToLower() == clName.ToLower());
|
||||||
@@ -187,9 +184,8 @@ namespace Barotrauma.Networking
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//can't authorize this client
|
//can't authorize this client
|
||||||
unauthClient.Connection.Disconnect("That name is taken.");
|
DisconnectUnauthClient(inc, unauthClient, "That name is taken.");
|
||||||
unauthenticatedClients.Remove(unauthClient);
|
Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (name already taken)", Color.Red);
|
||||||
unauthClient = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,5 +212,15 @@ namespace Barotrauma.Networking
|
|||||||
newClient.SetPermissions(ClientPermissions.None);
|
newClient.SetPermissions(ClientPermissions.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DisconnectUnauthClient(NetIncomingMessage inc, UnauthenticatedClient unauthClient, string reason)
|
||||||
|
{
|
||||||
|
inc.SenderConnection.Disconnect(reason);
|
||||||
|
|
||||||
|
if (unauthClient != null)
|
||||||
|
{
|
||||||
|
unauthenticatedClients.Remove(unauthClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user