From f3e1c28a20d469246b9a5883bd4cc0fe10f90980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 15 May 2025 12:29:06 +0800 Subject: [PATCH] Update default.go --- app/dispatcher/default.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index b329292c..deffb3d1 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -2,7 +2,6 @@ package dispatcher import ( "context" - "io" "regexp" "strings" "sync" @@ -374,14 +373,7 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw return nil, ctx.Err() default: cachingStartingTimeStamp := time.Now() - payloadLen := payload.Len() cacheErr := cReader.Cache(payload, cacheDeadline) - if cacheErr != nil { - return nil, cacheErr - } - if payload.Len() == payloadLen { - return nil, io.EOF - } cachingTimeElapsed := time.Since(cachingStartingTimeStamp) cacheDeadline -= cachingTimeElapsed @@ -391,12 +383,14 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw case common.ErrNoClue: // No Clue: protocol not matches, and sniffer cannot determine whether there will be a match or not totalAttempt++ case protocol.ErrProtoNeedMoreData: // Protocol Need More Data: protocol matches, but need more data to complete sniffing - break + if cacheErr != nil { // Cache error (e.g. timeout) counts for failed attempt + totalAttempt++ + } default: return result, err } } else { - return nil, io.EOF + totalAttempt++ } if totalAttempt >= 2 || cacheDeadline <= 0 { return nil, errSniffingTimeout