@@ -892,9 +892,12 @@ private Message ReceiveMessage()
892
892
// Read first block - which starts with the packet length
893
893
var firstBlock = Read ( blockSize ) ;
894
894
895
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] FirstBlock [{1}]: {2}" , ToHex ( SessionId ) , blockSize , ToHex ( firstBlock ) ) ) ;
896
+
895
897
if ( _serverCipher != null )
896
898
{
897
899
firstBlock = _serverCipher . Decrypt ( firstBlock ) ;
900
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] FirstBlock decrypted [{1}]: {2}" , ToHex ( SessionId ) , firstBlock . Length , ToHex ( firstBlock ) ) ) ;
898
901
}
899
902
900
903
var packetLength = ( uint ) ( firstBlock [ 0 ] << 24 | firstBlock [ 1 ] << 16 | firstBlock [ 2 ] << 8 | firstBlock [ 3 ] ) ;
@@ -924,25 +927,29 @@ private Message ReceiveMessage()
924
927
{
925
928
var nextBlocks = Read ( bytesToRead ) ;
926
929
930
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] NextBlocks [{1}]: {2}" , ToHex ( SessionId ) , bytesToRead , ToHex ( nextBlocks ) ) ) ;
931
+
927
932
if ( serverHash != null )
928
933
{
929
934
Buffer . BlockCopy ( nextBlocks , nextBlocks . Length - serverHash . Length , serverHash , 0 , serverHash . Length ) ;
930
935
nextBlocks = nextBlocks . Take ( nextBlocks . Length - serverHash . Length ) ;
936
+
937
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] ServerHash [{1}]: {2}" , ToHex ( SessionId ) , serverHash . Length , ToHex ( serverHash ) ) ) ;
931
938
}
932
939
933
940
if ( nextBlocks . Length > 0 )
934
941
{
935
942
if ( _serverCipher != null )
936
943
{
937
944
nextBlocks = _serverCipher . Decrypt ( nextBlocks ) ;
945
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] NextBlocks decrypted [{1}]: {2}" , ToHex ( SessionId ) , nextBlocks . Length , ToHex ( nextBlocks ) ) ) ;
938
946
}
939
947
940
948
nextBlocks . CopyTo ( data , blockSize + inboundPacketSequenceLength ) ;
941
949
}
942
950
}
943
951
944
952
var paddingLength = data [ inboundPacketSequenceLength + packetLengthFieldLength ] ;
945
-
946
953
var messagePayloadLength = ( int ) ( packetLength - paddingLength - paddingLengthFieldLength ) ;
947
954
var messagePayloadOffset = inboundPacketSequenceLength + packetLengthFieldLength + paddingLengthFieldLength ;
948
955
@@ -965,6 +972,8 @@ private Message ReceiveMessage()
965
972
messagePayloadOffset = 0 ;
966
973
}
967
974
975
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Message info (Sequence:{1},MessagePayloadLength:{2})" , ToHex ( SessionId ) , _inboundPacketSequence , messagePayloadLength ) ) ;
976
+
968
977
_inboundPacketSequence ++ ;
969
978
970
979
return LoadMessage ( data , messagePayloadOffset ) ;
@@ -1681,7 +1690,7 @@ private static string ToHex(byte[] bytes, int offset)
1681
1690
return builder . ToString ( ) ;
1682
1691
}
1683
1692
1684
- private static string ToHex ( byte [ ] bytes )
1693
+ internal static string ToHex ( byte [ ] bytes )
1685
1694
{
1686
1695
if ( bytes == null )
1687
1696
return null ;
0 commit comments