diff --git a/lib/src/Net/IIP/DistributedConnection.dart b/lib/src/Net/IIP/DistributedConnection.dart index 8c203ee..3440657 100644 --- a/lib/src/Net/IIP/DistributedConnection.dart +++ b/lib/src/Net/IIP/DistributedConnection.dart @@ -1158,6 +1158,7 @@ class DistributedConnection extends NetworkConnection with IStore { else if (_authPacket.event == IIPAuthPacketEvent.IndicationEstablished) { session.id = _authPacket.sessionId; + session.authorizedAccount = _authPacket.accountId!.getString(0, _authPacket.accountId!.length); _ready = true; _status = ConnectionStatus.Connected; @@ -1166,7 +1167,7 @@ class DistributedConnection extends NetworkConnection with IStore { if (this.instance == null) { - Warehouse.put(this.hashCode.toString().replaceAll("/", "_"), this, null, server).then((x) + Warehouse.put(session.authorizedAccount!.replaceAll("/", "_"), this, null, server).then((x) { _openReply?.trigger(true); @@ -1626,10 +1627,14 @@ class DistributedConnection extends NetworkConnection with IStore { session.id = n; + var accountId = DC.stringToBytes(session.authorizedAccount!); + _sendParams() ..addUint8(IIPAuthPacketEvent.IndicationEstablished) ..addUint8(n.length) ..addDC(n) + ..addUint8(accountId.length) + ..addDC(accountId) ..done(); if (this.instance == null) diff --git a/lib/src/Net/Packets/IIPAuthPacket.dart b/lib/src/Net/Packets/IIPAuthPacket.dart index 49cdbed..48ecd4c 100644 --- a/lib/src/Net/Packets/IIPAuthPacket.dart +++ b/lib/src/Net/Packets/IIPAuthPacket.dart @@ -49,7 +49,8 @@ class IIPAuthPacket { DC? challenge; DC? asymetricEncryptionKey; DC? sessionId; - + DC? accountId; + TransmissionType? dataType; int reference = 0; @@ -298,7 +299,7 @@ class IIPAuthPacket { } else if (event == IIPAuthPacketEvent.IndicationEstablished) { - if (_notEnough(offset, ends, 1)) + if (_notEnough(offset, ends, 2)) return -_dataLengthNeeded; var sessionLength = data[offset++]; @@ -310,6 +311,20 @@ class IIPAuthPacket { 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 || event == IIPAuthPacketEvent.IAuthHashed || event == IIPAuthPacketEvent.IAuthEncrypted) {