public readonly List<ByteSpan> QueuedApplicationDataMessage = new List<ByteSpan>();
+ public DateTime StartOfNegotiation;
+
public PeerData()
{
ByteSpan block = new byte[2 * Finished.Size];
this.NextEpoch.ServerVerification = new byte[Finished.Size];
this.ConnectionId = connectionId;
+
+ this.StartOfNegotiation = DateTime.UtcNow;
}
public void Dispose()
}
}
+ /// <inheritdoc />
+ public override void DisconnectOldConnections(TimeSpan maxAge, MessageWriter disconnectMessage)
+ {
+ DateTime now = DateTime.UtcNow;
+ foreach (KeyValuePair<IPEndPoint, PeerData> kvp in this.existingPeers)
+ {
+ PeerData peer = kvp.Value;
+ lock(peer)
+ {
+ if (peer.Epoch == 0 || peer.NextEpoch.State != HandshakeState.ExpectingHello)
+ {
+ TimeSpan negotiationAge = now - peer.StartOfNegotiation;
+ if (negotiationAge > maxAge)
+ {
+ base.MarkConnectionAsStale(peer.ConnectionId);
+ }
+ }
+ }
+ }
+
+ base.DisconnectOldConnections(maxAge, disconnectMessage);
+ }
+
/// <summary>
/// Allocate a new connection id
/// </summary>
}
}
- public void DisconnectOldConnections(TimeSpan maxAge, MessageWriter disconnectMessage)
+ public virtual void DisconnectOldConnections(TimeSpan maxAge, MessageWriter disconnectMessage)
{
var now = DateTime.UtcNow;
foreach (var conn in this.allConnections.Values)