mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 11:32:59 +00:00
AuthAccount
This commit is contained in:
parent
3a89a108db
commit
c17191a7bf
@ -889,15 +889,17 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
else if (authPacket.Event == IIPAuthPacketEvent.IndicationEstablished)
|
else if (authPacket.Event == IIPAuthPacketEvent.IndicationEstablished)
|
||||||
{
|
{
|
||||||
session.Id = authPacket.SessionId;
|
session.Id = authPacket.SessionId;
|
||||||
|
session.AuthorizedAccount = authPacket.AccountId.GetString(0, (uint)authPacket.AccountId.Length);
|
||||||
|
|
||||||
ready = true;
|
ready = true;
|
||||||
Status = ConnectionStatus.Connected;
|
Status = ConnectionStatus.Connected;
|
||||||
|
|
||||||
|
|
||||||
// put it in the warehouse
|
// put it in the warehouse
|
||||||
|
|
||||||
if (this.Instance == null)
|
if (this.Instance == null)
|
||||||
{
|
{
|
||||||
Warehouse.Put(this.GetHashCode().ToString().Replace("/", "_"), this, null, Server).Then(x =>
|
Warehouse.Put(session.AuthorizedAccount.Replace("/", "_"), this, null, Server).Then(x =>
|
||||||
{
|
{
|
||||||
openReply?.Trigger(true);
|
openReply?.Trigger(true);
|
||||||
OnReady?.Invoke(this);
|
OnReady?.Invoke(this);
|
||||||
@ -1222,7 +1224,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Error
|
throw new NotImplementedException("Authentication method unsupported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.Then((pw) =>
|
reply.Then((pw) =>
|
||||||
@ -1355,11 +1357,14 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
var r = new Random();
|
var r = new Random();
|
||||||
session.Id = new byte[32];
|
session.Id = new byte[32];
|
||||||
r.NextBytes(session.Id);
|
r.NextBytes(session.Id);
|
||||||
|
var accountId = session.AuthorizedAccount.ToBytes();
|
||||||
|
|
||||||
SendParams()
|
SendParams()
|
||||||
.AddUInt8((byte)IIPAuthPacketEvent.IndicationEstablished)
|
.AddUInt8((byte)IIPAuthPacketEvent.IndicationEstablished)
|
||||||
.AddUInt8((byte)session.Id.Length)
|
.AddUInt8((byte)session.Id.Length)
|
||||||
.AddUInt8Array(session.Id)
|
.AddUInt8Array(session.Id)
|
||||||
|
.AddUInt8((byte)accountId.Length)
|
||||||
|
.AddUInt8Array(accountId)
|
||||||
.Done();
|
.Done();
|
||||||
|
|
||||||
if (this.Instance == null)
|
if (this.Instance == null)
|
||||||
@ -1574,7 +1579,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
{
|
{
|
||||||
session.LocalHeaders[IIPAuthPacketHeader.TokenIndex] = tokenIndex;
|
session.LocalHeaders[IIPAuthPacketHeader.TokenIndex] = tokenIndex;
|
||||||
}
|
}
|
||||||
else
|
else if (method == AuthenticationMethod.Certificate)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("Unsupported authentication method.");
|
throw new NotImplementedException("Unsupported authentication method.");
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,12 @@ public class IIPAuthPacket : Packet
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] AccountId
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
public TransmissionType? DataType
|
public TransmissionType? DataType
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@ -408,7 +414,7 @@ public class IIPAuthPacket : Packet
|
|||||||
}
|
}
|
||||||
else if (Event == IIPAuthPacketEvent.IndicationEstablished)
|
else if (Event == IIPAuthPacketEvent.IndicationEstablished)
|
||||||
{
|
{
|
||||||
if (NotEnough(offset, ends, 1))
|
if (NotEnough(offset, ends, 2))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
var sessionLength = data[offset++];
|
var sessionLength = data[offset++];
|
||||||
@ -419,6 +425,18 @@ public class IIPAuthPacket : Packet
|
|||||||
SessionId = data.Clip(offset, sessionLength);
|
SessionId = data.Clip(offset, sessionLength);
|
||||||
|
|
||||||
offset += sessionLength;
|
offset += sessionLength;
|
||||||
|
|
||||||
|
if (NotEnough(offset, ends, 1))
|
||||||
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
|
var accountLength = data[offset++];
|
||||||
|
|
||||||
|
if (NotEnough(offset, ends, accountLength))
|
||||||
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
|
AccountId = data.Clip(offset, accountLength);
|
||||||
|
|
||||||
|
offset += accountLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Event == IIPAuthPacketEvent.IAuthPlain
|
else if (Event == IIPAuthPacketEvent.IAuthPlain
|
||||||
|
Loading…
x
Reference in New Issue
Block a user