From d5c434b6afc27275dee020a490693d97d6f0a4e9 Mon Sep 17 00:00:00 2001 From: ahmed Date: Fri, 3 Apr 2026 12:58:39 +0300 Subject: [PATCH] Auth --- Esiur/Net/SendList.cs | 4 +++- Esiur/Protocol/EpConnection.cs | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Esiur/Net/SendList.cs b/Esiur/Net/SendList.cs index 550f5be..39fbbe3 100644 --- a/Esiur/Net/SendList.cs +++ b/Esiur/Net/SendList.cs @@ -19,7 +19,9 @@ public class SendList : BinaryList public override AsyncReply Done() { - connection.Send(this.ToArray()); + var s = this.ToArray(); + //Console.WriteLine($"Sending {s.Length} -> {DC.ToHex(s)}"); + connection.Send(s); return reply; } } diff --git a/Esiur/Protocol/EpConnection.cs b/Esiur/Protocol/EpConnection.cs index c4c0cc3..389ebd4 100644 --- a/Esiur/Protocol/EpConnection.cs +++ b/Esiur/Protocol/EpConnection.cs @@ -644,6 +644,8 @@ public partial class EpConnection : NetworkConnection, IStore { offset += (uint)rt; + //Console.WriteLine($"AuthPacket: RT: {rt} {authPacket.ToString()}"); + if (authPacket.Command == EpAuthPacketCommand.Initialize && isInitiator) throw new Exception("Bad authentication packet received. Connection is initiator but received an initialization packet."); @@ -672,6 +674,7 @@ public partial class EpConnection : NetworkConnection, IStore } //@TODO allow all for testing + AuthenticatonCompleted("guest"); SendParams() .AddUInt8((byte)EpAuthPacketAcknowledgement.SessionEstablished) .Done(); @@ -762,7 +765,8 @@ public partial class EpConnection : NetworkConnection, IStore } void AuthenticatonCompleted(string identity) - { + { + if (this.Instance == null) { Server.Instance.Warehouse.Put( @@ -770,8 +774,8 @@ public partial class EpConnection : NetworkConnection, IStore .Then(x => { session.AuthorizedIdentity = identity; - authenticated = true; + Status = EpConnectionStatus.Connected; openReply?.Trigger(true); openReply = null; @@ -1500,7 +1504,6 @@ public partial class EpConnection : NetworkConnection, IStore var chunkId = (new Random()).Next(1000, 1000000); - this.Socket.Hold(); try