Release 1.10.5.0 - Autumn Update 2025
This commit is contained in:
@@ -820,16 +820,22 @@ namespace Barotrauma
|
||||
{
|
||||
int prevPos = inc.BitPosition;
|
||||
|
||||
const int MaxBytesToLog = 500;
|
||||
|
||||
StringBuilder hexData = new();
|
||||
inc.BitPosition = 0;
|
||||
while (inc.BitPosition < inc.LengthBits)
|
||||
while (inc.BitPosition < inc.LengthBits &&
|
||||
inc.BytePosition < MaxBytesToLog)
|
||||
{
|
||||
byte b = inc.ReadByte();
|
||||
hexData.Append($"{b:X2} ");
|
||||
}
|
||||
// trim the last space if there is one
|
||||
if (hexData.Length > 0) { hexData.Length--; }
|
||||
|
||||
if (inc.BytePosition >= MaxBytesToLog)
|
||||
{
|
||||
hexData.Append($" (data truncated, {inc.LengthBytes} bytes in the full message)");
|
||||
}
|
||||
inc.BitPosition = prevPos;
|
||||
|
||||
//only log the error once per sender, so this can't be abused by spamming the server with malformed data to fill up the console with errors
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Barotrauma.Networking
|
||||
return msg;
|
||||
}
|
||||
#endif
|
||||
public static void WriteNetSerializableStruct(this IWriteMessage msg, INetSerializableStruct serializableStruct)
|
||||
public static void WriteNetSerializableStruct<T>(this IWriteMessage msg, T serializableStruct) where T : INetSerializableStruct
|
||||
{
|
||||
serializableStruct.Write(msg);
|
||||
}
|
||||
|
||||
+17
-6
@@ -94,6 +94,12 @@ namespace Barotrauma.Networking
|
||||
public Option<int> RetriesLeft;
|
||||
}
|
||||
|
||||
[NetworkSerialize]
|
||||
internal readonly record struct DoSProtectionPacket(string EndpointStr, bool ShouldBan) : INetSerializableStruct
|
||||
{
|
||||
public Option<P2PEndpoint> Endpoint => P2PEndpoint.Parse(EndpointStr);
|
||||
}
|
||||
|
||||
[NetworkSerialize]
|
||||
internal readonly struct PeerDisconnectPacket : INetSerializableStruct
|
||||
{
|
||||
@@ -109,19 +115,24 @@ namespace Barotrauma.Networking
|
||||
AdditionalInformation = additionalInformation;
|
||||
}
|
||||
|
||||
public LocalizedString ChatMessage(Client c)
|
||||
public LocalizedString ChatMessage(string? name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
name = TextManager.Get("ServerMessage.UnknownClient").Value;
|
||||
}
|
||||
|
||||
LocalizedString message = DisconnectReason switch
|
||||
{
|
||||
DisconnectReason.Disconnected => TextManager.GetWithVariable("ServerMessage.ClientLeftServer",
|
||||
"[client]", c.Name),
|
||||
DisconnectReason.Banned => TextManager.GetWithVariable("servermessage.bannedfromserver", "[client]", c.Name),
|
||||
DisconnectReason.Kicked => TextManager.GetWithVariable("servermessage.kickedfromserver", "[client]", c.Name),
|
||||
"[client]", name),
|
||||
DisconnectReason.Banned => TextManager.GetWithVariable("servermessage.bannedfromserver", "[client]", name),
|
||||
DisconnectReason.Kicked => TextManager.GetWithVariable("servermessage.kickedfromserver", "[client]", name),
|
||||
_ => TextManager.GetWithVariables("ChatMsg.DisconnectedWithReason",
|
||||
("[client]", c.Name),
|
||||
("[client]", name),
|
||||
("[reason]", TextManager.Get($"ChatMsg.DisconnectReason.{DisconnectReason}")))
|
||||
};
|
||||
if (!string.IsNullOrEmpty(AdditionalInformation) &&
|
||||
if (!string.IsNullOrEmpty(AdditionalInformation) &&
|
||||
DisconnectReason is DisconnectReason.Banned or DisconnectReason.Kicked)
|
||||
{
|
||||
message += " "+ TextManager.Get("banreason") + " " + TextManager.GetServerMessage(AdditionalInformation);
|
||||
|
||||
@@ -89,8 +89,6 @@ namespace Barotrauma.Networking
|
||||
private readonly Queue<LogMessage> lines;
|
||||
private readonly Queue<LogMessage> unsavedLines;
|
||||
|
||||
private readonly bool[] msgTypeHidden = new bool[Enum.GetValues(typeof(MessageType)).Length];
|
||||
|
||||
public int LinesPerFile
|
||||
{
|
||||
get { return linesPerFile; }
|
||||
|
||||
Reference in New Issue
Block a user