mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-17 17:48:40 +00:00
Update default.go
This commit is contained in:
parent
3ba7f5f6d3
commit
f3e1c28a20
1 changed files with 4 additions and 10 deletions
|
@ -2,7 +2,6 @@ package dispatcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -374,14 +373,7 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw
|
||||||
return nil, ctx.Err()
|
return nil, ctx.Err()
|
||||||
default:
|
default:
|
||||||
cachingStartingTimeStamp := time.Now()
|
cachingStartingTimeStamp := time.Now()
|
||||||
payloadLen := payload.Len()
|
|
||||||
cacheErr := cReader.Cache(payload, cacheDeadline)
|
cacheErr := cReader.Cache(payload, cacheDeadline)
|
||||||
if cacheErr != nil {
|
|
||||||
return nil, cacheErr
|
|
||||||
}
|
|
||||||
if payload.Len() == payloadLen {
|
|
||||||
return nil, io.EOF
|
|
||||||
}
|
|
||||||
cachingTimeElapsed := time.Since(cachingStartingTimeStamp)
|
cachingTimeElapsed := time.Since(cachingStartingTimeStamp)
|
||||||
cacheDeadline -= cachingTimeElapsed
|
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
|
case common.ErrNoClue: // No Clue: protocol not matches, and sniffer cannot determine whether there will be a match or not
|
||||||
totalAttempt++
|
totalAttempt++
|
||||||
case protocol.ErrProtoNeedMoreData: // Protocol Need More Data: protocol matches, but need more data to complete sniffing
|
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:
|
default:
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, io.EOF
|
totalAttempt++
|
||||||
}
|
}
|
||||||
if totalAttempt >= 2 || cacheDeadline <= 0 {
|
if totalAttempt >= 2 || cacheDeadline <= 0 {
|
||||||
return nil, errSniffingTimeout
|
return nil, errSniffingTimeout
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue