1
1
using ConsoleTables ;
2
2
using Network . Enums ;
3
3
using Network . Packets ;
4
+ using Network . RSA ;
4
5
using System ;
5
6
using System . Diagnostics ;
6
7
using System . IO ;
@@ -190,7 +191,7 @@ private void LogPacket(byte[] packet, Packet packetObj, PacketDirection directio
190
191
if ( ! EnableLogging )
191
192
return ;
192
193
193
- ConsoleTable tableOutPut = BuildConsoleTable ( packet , packetObj , direction . ToString ( ) ) ;
194
+ ConsoleTable tableOutPut = BuildConsoleTable ( packet , packetObj , direction ) ;
194
195
195
196
LogToAllOutputs ( tableOutPut . ToStringAlternative ( ) ) ;
196
197
}
@@ -202,24 +203,28 @@ private void LogPacket(byte[] packet, Packet packetObj, PacketDirection directio
202
203
/// <param name="packetObj">The <see cref="Packet"/> object.</param>
203
204
/// <param name="direction"> The direction that the packet is traveling across the network.</param>
204
205
/// <returns>The built <see cref="ConsoleTable"/>.</returns>
205
- private ConsoleTable BuildConsoleTable ( byte [ ] packet , Packet packetObj , string direction )
206
+ private ConsoleTable BuildConsoleTable ( byte [ ] packet , Packet packetObj , PacketDirection direction )
206
207
{
208
+ string localEndPoint = monitoredConnection . IPLocalEndPoint ? . ToString ( ) ;
209
+ string remoteEndPoint = monitoredConnection . IPRemoteEndPoint ? . ToString ( ) ;
210
+
207
211
object type = monitoredConnection . GetType ( ) . Name ;
208
- object local = monitoredConnection . IPLocalEndPoint ? . ToString ( ) ;
212
+ object route = string . Format ( "{0} -> {1}" , direction == PacketDirection . Incoming ? remoteEndPoint : localEndPoint ,
213
+ direction == PacketDirection . Incoming ? localEndPoint : remoteEndPoint ) ;
209
214
object ascii = Encoding . ASCII . GetString ( packet , 0 , packet . Length ) . Replace ( "\0 " , "" ) . Replace ( "\n " , "" ) . Replace ( "\r " , "" ) ;
210
215
object packetName = packetObj . GetType ( ) . Name ;
211
216
212
217
ConsoleTable tableOutPut ;
213
218
214
219
if ( string . IsNullOrWhiteSpace ( ( string ) ascii ) )
215
220
{
216
- tableOutPut = new ConsoleTable ( "Direction" , "Type" , "Local " , "Packet" ) ;
217
- tableOutPut . AddRow ( direction , type , local , packetName ) ;
221
+ tableOutPut = new ConsoleTable ( "Direction" , "Type" , "Route " , "Packet" ) ;
222
+ tableOutPut . AddRow ( direction , type , route , packetName ) ;
218
223
}
219
224
else
220
225
{
221
- tableOutPut = new ConsoleTable ( "Direction" , "Type" , "Local " , "ASCII " , "Packet " ) ;
222
- tableOutPut . AddRow ( direction , type , local , ascii , packetName ) ;
226
+ tableOutPut = new ConsoleTable ( "Direction" , "Type" , "Route " , "Packet " , "ASCII " ) ;
227
+ tableOutPut . AddRow ( direction , type , route , packetName , ascii ) ;
223
228
}
224
229
225
230
return tableOutPut ;
0 commit comments