Refactor sequence code into SequenceManager

This commit is contained in:
Kleissner
2021-10-17 21:34:30 +02:00
parent 767181620e
commit 1b9151d6fd
5 changed files with 90 additions and 45 deletions

View File

@@ -195,7 +195,7 @@ func packetWorker(packets <-chan networkWire) {
case protocol.CommandResponse: // Response
if response, _ := msgDecodeResponse(raw); response != nil {
// Validate sequence number which prevents unsolicited responses.
if valid, rtt := ValidateSequence(raw, response.Actions&(1<<ActionSequenceLast) > 0); !valid {
if valid, rtt := networks.Sequences.ValidateSequence(raw, response.Actions&(1<<ActionSequenceLast) > 0); !valid {
//Filters.LogError("packetWorker", "message with invalid sequence %d command %d from %s\n", raw.Sequence, raw.Command, raw.connection.Address.String()) // Only log for debug purposes.
continue
} else if rtt > 0 {
@@ -237,7 +237,7 @@ func packetWorker(packets <-chan networkWire) {
case protocol.CommandPong: // Ping
// Validate sequence number which prevents unsolicited responses.
if valid, rtt := ValidateSequence(raw, true); !valid {
if valid, rtt := networks.Sequences.ValidateSequence(raw, true); !valid {
//Filters.LogError("packetWorker", "message with invalid sequence %d command %d from %s\n", raw.Sequence, raw.Command, raw.connection.Address.String()) // Only log for debug purposes.
continue
} else if rtt > 0 {