chore: use spans instead
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 28s
Build, Package and Push Images / sbom-scan (push) Successful in 36s
Build, Package and Push Images / sonarqube (push) Successful in 1m19s
Build, Package and Push Images / container-build (push) Successful in 2m0s
Build, Package and Push Images / container-sbom-scan (push) Successful in 35s
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 28s
Build, Package and Push Images / sbom-scan (push) Successful in 36s
Build, Package and Push Images / sonarqube (push) Successful in 1m19s
Build, Package and Push Images / container-build (push) Successful in 2m0s
Build, Package and Push Images / container-sbom-scan (push) Successful in 35s
This commit is contained in:
parent
43a5c994df
commit
5b8880f392
2 changed files with 5 additions and 6 deletions
|
@ -71,11 +71,10 @@ public class AuthSession : TcpSession
|
|||
protected override void OnReceived(byte[] buffer, long offset, long size)
|
||||
{
|
||||
_logger.LogDebug("Length: {Size} & offset: {Offset}", size, offset);
|
||||
Span<byte> decryptedBuffer = new byte[size];
|
||||
Span<byte> decryptedBuffer = stackalloc byte[(int)size];
|
||||
|
||||
// xor every value after the first 8 bytes
|
||||
var dataBuffer = Decrypt(new ArraySegment<byte>(buffer, 8, (int)size - 8).ToArray());
|
||||
|
||||
var dataBuffer = Decrypt(buffer.AsSpan(8, (int)size - 8));
|
||||
_logger.LogDebug("Length {Length}", BitConverter.ToUInt16(buffer, 0));
|
||||
|
||||
var opCode = BitConverter.ToUInt16(buffer.ToArray(), 2);
|
||||
|
@ -99,7 +98,7 @@ public class AuthSession : TcpSession
|
|||
base.OnReceived(decryptedBuffer.ToArray(), offset, decryptedBuffer.Length);
|
||||
}
|
||||
|
||||
private static byte[] Decrypt(byte[] buffer)
|
||||
private static Span<byte> Decrypt(Span<byte> buffer)
|
||||
{
|
||||
for (var i = 0; i < buffer.Length; ++i)
|
||||
{
|
||||
|
|
|
@ -8,10 +8,10 @@ namespace Server.Packets;
|
|||
[MessageUrn("packets")]
|
||||
public class RawPacket
|
||||
{
|
||||
public RawPacket(OperationCode operationCode, byte[] messageBody, uint aliveTime, byte unknownValue2,
|
||||
public RawPacket(OperationCode operationCode, Span<byte> messageBody, uint aliveTime, byte unknownValue2,
|
||||
byte unknownValue, Guid sessionId, AuthSession session)
|
||||
{
|
||||
MessageBody = messageBody;
|
||||
MessageBody = messageBody.ToArray();
|
||||
UnknownValue2 = unknownValue2;
|
||||
UnknownValue = unknownValue;
|
||||
SessionId = sessionId;
|
||||
|
|
Loading…
Reference in a new issue