fix: Adds packet logging (#836)

### Enabling Packet Logging
`[packetlogging on` and target the user.
Supports command modifiers such as:
`[online packetlogging on where accesslevel = player`

Logs are saved in `path/<ip address>/packets.log`. It is a simple append-format log with no date splitting.
This commit is contained in:
Kamron Batman 2021-10-31 10:22:22 -07:00 committed by GitHub
parent 85d699fcd7
commit 2890f5c3ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 186 additions and 193 deletions

View file

@ -59,6 +59,27 @@ namespace Server.Text
return result;
}
public static unsafe int ToSpacedHexString(this ReadOnlySpan<byte> bytes, Span<char> result)
{
var charsWritten = 0;
fixed (char* resultP = result)
{
for (int i = 0; i < bytes.Length; i++)
{
var resultP2 = (uint*)(resultP + charsWritten);
*resultP2 = m_Lookup32Chars[bytes[i]];
charsWritten += 2;
if (i < bytes.Length - 1)
{
*(resultP + charsWritten++) = ' ';
}
}
}
return charsWritten;
}
public static string ToDelimitedHexString(this byte[] bytes) => ((ReadOnlySpan<byte>)bytes).ToDelimitedHexString();
public static unsafe string ToDelimitedHexString(this ReadOnlySpan<byte> bytes)