@@ -697,7 +697,7 @@ public void Connect()
697
697
/// </remarks>
698
698
public void Disconnect ( )
699
699
{
700
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] {1} Disconnecting session" , ToHex ( SessionId ) , DateTime . Now . Ticks ) ) ;
700
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Disconnecting session. " , ToHex ( SessionId ) ) ) ;
701
701
702
702
// send SSH_MSG_DISCONNECT message, clear socket read buffer and dispose it
703
703
Disconnect ( DisconnectReason . ByApplication , "Connection terminated by the client." ) ;
@@ -843,7 +843,7 @@ internal void SendMessage(Message message)
843
843
WaitOnHandle ( _keyExchangeCompletedWaitHandle ) ;
844
844
}
845
845
846
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] SendMessage to server '{1}': '{2}'." , ToHex ( SessionId ) , message . GetType ( ) . Name , message ) ) ;
846
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Sending message '{1}' to server : '{2}'." , ToHex ( SessionId ) , message . GetType ( ) . Name , message ) ) ;
847
847
848
848
var paddingMultiplier = _clientCipher == null ? ( byte ) 8 : Math . Max ( ( byte ) 8 , _serverCipher . MinimumSize ) ;
849
849
var packetData = message . GetPacket ( paddingMultiplier , _clientCompression ) ;
@@ -947,12 +947,12 @@ private bool TrySendMessage(Message message)
947
947
}
948
948
catch ( SshException ex )
949
949
{
950
- DiagnosticAbstraction . Log ( string . Format ( "Failure sending message server '{0}': '{1}' => {2}" , message . GetType ( ) . Name , message , ex ) ) ;
950
+ DiagnosticAbstraction . Log ( string . Format ( "Failure sending message '{0}' to server : '{1}' => {2}" , message . GetType ( ) . Name , message , ex ) ) ;
951
951
return false ;
952
952
}
953
953
catch ( SocketException ex )
954
954
{
955
- DiagnosticAbstraction . Log ( string . Format ( "Failure sending message server '{0}': '{1}' => {2}" , message . GetType ( ) . Name , message , ex ) ) ;
955
+ DiagnosticAbstraction . Log ( string . Format ( "Failure sending message '{0}' to server : '{1}' => {2}" , message . GetType ( ) . Name , message , ex ) ) ;
956
956
return false ;
957
957
}
958
958
}
@@ -998,16 +998,9 @@ private Message ReceiveMessage()
998
998
return null ;
999
999
}
1000
1000
1001
- #if DEBUG_GERT
1002
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] FirstBlock [{1}]: {2}" , ToHex ( SessionId ) , blockSize , ToHex ( firstBlock ) ) ) ;
1003
- #endif // DEBUG_GERT
1004
-
1005
1001
if ( _serverCipher != null )
1006
1002
{
1007
1003
firstBlock = _serverCipher . Decrypt ( firstBlock ) ;
1008
- #if DEBUG_GERT
1009
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] FirstBlock decrypted [{1}]: {2}" , ToHex ( SessionId ) , firstBlock . Length , ToHex ( firstBlock ) ) ) ;
1010
- #endif // DEBUG_GERT
1011
1004
}
1012
1005
1013
1006
packetLength = ( uint ) ( firstBlock [ 0 ] << 24 | firstBlock [ 1 ] << 16 | firstBlock [ 2 ] << 8 | firstBlock [ 3 ] ) ;
@@ -1053,16 +1046,8 @@ private Message ReceiveMessage()
1053
1046
var numberOfBytesToDecrypt = data . Length - ( blockSize + inboundPacketSequenceLength + serverMacLength ) ;
1054
1047
if ( numberOfBytesToDecrypt > 0 )
1055
1048
{
1056
- #if DEBUG_GERT
1057
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] NextBlocks [{1}]: {2}" , ToHex ( SessionId ) , bytesToRead , ToHex ( nextBlocks ) ) ) ;
1058
- #endif // DEBUG_GERT
1059
-
1060
1049
var decryptedData = _serverCipher . Decrypt ( data , blockSize + inboundPacketSequenceLength , numberOfBytesToDecrypt ) ;
1061
1050
Buffer . BlockCopy ( decryptedData , 0 , data , blockSize + inboundPacketSequenceLength , decryptedData . Length ) ;
1062
-
1063
- #if DEBUG_GERT
1064
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] NextBlocks decrypted [{1}]: {2}" , ToHex ( SessionId ) , decryptedData . Length , ToHex ( decryptedData ) ) ) ;
1065
- #endif // DEBUG_GERT
1066
1051
}
1067
1052
}
1068
1053
@@ -1092,10 +1077,6 @@ private Message ReceiveMessage()
1092
1077
messagePayloadLength = data . Length ;
1093
1078
}
1094
1079
1095
- #if DEBUG_GERT
1096
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] Message info (Sequence:{1},MessagePayloadLength:{2})" , ToHex ( SessionId ) , _inboundPacketSequence , messagePayloadLength ) ) ;
1097
- #endif // DEBUG_GERT
1098
-
1099
1080
_inboundPacketSequence ++ ;
1100
1081
1101
1082
return LoadMessage ( data , messagePayloadOffset , messagePayloadLength ) ;
@@ -1120,7 +1101,7 @@ private void TrySendDisconnect(DisconnectReason reasonCode, string message)
1120
1101
/// <param name="message"><see cref="DisconnectMessage"/> message.</param>
1121
1102
internal void OnDisconnectReceived ( DisconnectMessage message )
1122
1103
{
1123
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] {1} Disconnect received: {2 } {3} " , ToHex ( SessionId ) , DateTime . Now . Ticks , message . ReasonCode , message . Description ) ) ;
1104
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Disconnect received: {1 } {2}. " , ToHex ( SessionId ) , message . ReasonCode , message . Description ) ) ;
1124
1105
1125
1106
// transition to disconnecting state to avoid throwing exceptions while cleaning up, and to
1126
1107
// ensure any exceptions that are raised do not overwrite the SshConnectionException that we
@@ -1578,14 +1559,9 @@ private Message LoadMessage(byte[] data, int offset, int count)
1578
1559
var messageType = data [ offset ] ;
1579
1560
1580
1561
var message = _sshMessageFactory . Create ( messageType ) ;
1581
-
1582
- #if DEBUG_GERT
1583
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] Loading message with offset '{1}': {2}" , ToHex ( SessionId ) , offset , ToHex ( data , 0 ) ) ) ;
1584
- #endif // DEBUG_GERT
1585
-
1586
1562
message . Load ( data , offset + 1 , count - 1 ) ;
1587
1563
1588
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] ReceiveMessage from server: '{1}': '{2}'." , ToHex ( SessionId ) , message . GetType ( ) . Name , message ) ) ;
1564
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Received message '{1}' from server : '{2}'." , ToHex ( SessionId ) , message . GetType ( ) . Name , message ) ) ;
1589
1565
1590
1566
return message ;
1591
1567
}
@@ -1627,7 +1603,7 @@ private void SocketConnect(string host, int port)
1627
1603
var ipAddress = DnsAbstraction . GetHostAddresses ( host ) [ 0 ] ;
1628
1604
var ep = new IPEndPoint ( ipAddress , port ) ;
1629
1605
1630
- DiagnosticAbstraction . Log ( string . Format ( "Initiating connect to '{0}:{1}'." , host , port ) ) ;
1606
+ DiagnosticAbstraction . Log ( string . Format ( "Initiating connection to '{0}:{1}'." , host , port ) ) ;
1631
1607
1632
1608
_socket = SocketAbstraction . Connect ( ep , ConnectionInfo . Timeout ) ;
1633
1609
@@ -2209,7 +2185,7 @@ private void RaiseError(Exception exp)
2209
2185
{
2210
2186
var connectionException = exp as SshConnectionException ;
2211
2187
2212
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] {1} Raised exception: {2 }" , ToHex ( SessionId ) , DateTime . Now . Ticks , exp ) ) ;
2188
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Raised exception: {1 }" , ToHex ( SessionId ) , exp ) ) ;
2213
2189
2214
2190
if ( _isDisconnecting )
2215
2191
{
@@ -2234,7 +2210,7 @@ private void RaiseError(Exception exp)
2234
2210
2235
2211
if ( connectionException != null )
2236
2212
{
2237
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] {1} Disconnecting after exception: {2 }" , ToHex ( SessionId ) , DateTime . Now . Ticks , exp ) ) ;
2213
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Disconnecting after exception: {1 }" , ToHex ( SessionId ) , exp ) ) ;
2238
2214
Disconnect ( connectionException . DisconnectReason , exp . ToString ( ) ) ;
2239
2215
}
2240
2216
}
@@ -2290,7 +2266,7 @@ protected virtual void Dispose(bool disposing)
2290
2266
2291
2267
if ( disposing )
2292
2268
{
2293
- DiagnosticAbstraction . Log ( string . Format ( "[{0}] Disposing session" , ToHex ( SessionId ) ) ) ;
2269
+ DiagnosticAbstraction . Log ( string . Format ( "[{0}] Disposing session. " , ToHex ( SessionId ) ) ) ;
2294
2270
2295
2271
Disconnect ( ) ;
2296
2272
0 commit comments