Skip to content

Commit 0c919b2

Browse files
committed
[core] Add extra logging around incoming/outgoing connections
1 parent 2a2243c commit 0c919b2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/MonoTorrent.Client/MonoTorrent.Client/Managers/ConnectionManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ internal async void ProcessNewOutgoingConnection (TorrentManager manager, PeerId
199199
try {
200200
// Create a handshake message to send to the peer
201201
var handshake = new HandshakeMessage (id.ExpectedInfoHash.Truncate (), LocalPeerId, Constants.ProtocolStringV100);
202+
logger.InfoFormatted (id.Connection, "[outgoing] Sending handshake message with peer id '{0}'", LocalPeerId);
203+
202204
var preferredEncryption = EncryptionTypes.GetPreferredEncryption (id.Peer.AllowedEncryption, Settings.AllowedEncryption);
203205
if (preferredEncryption.Count == 0)
204206
throw new NotSupportedException ("The peer and the engine do not agree on any encryption methods");
@@ -226,6 +228,7 @@ internal async void ProcessNewOutgoingConnection (TorrentManager manager, PeerId
226228
try {
227229
// Receive their handshake
228230
HandshakeMessage handshake = await PeerIO.ReceiveHandshakeAsync (id.Connection, id.Decryptor);
231+
logger.InfoFormatted (id.Connection, "[outgoing] Received handshake message with peer id '{0}'", handshake.PeerId);
229232
manager.Mode.HandleMessage (id, handshake, default);
230233
} catch {
231234
// If we choose plaintext and it resulted in the connection being closed, remove it from the list.

src/MonoTorrent.Client/MonoTorrent.Client/Managers/ListenManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ async ReusableTask<bool> HandleHandshake (PeerInfo peerInfo, IPeerConnection con
145145

146146
var peer = new Peer (peerInfo, man.InfoHashes.Expand (message.InfoHash));
147147
peer.UpdatePeerId (message.PeerId);
148+
149+
logger.InfoFormatted (connection, "[incoming] Received handshake with peer_id '{0}'", message.PeerId);
150+
148151
var id = new PeerId (peer, connection, new BitField (man.Bitfield.Length).SetAll (false)) {
149152
Decryptor = decryptor,
150153
Encryptor = encryptor

0 commit comments

Comments
 (0)