mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-19 06:39:48 +03:00
Add sniff timeoit
This commit is contained in:
@ -31,10 +31,18 @@ type cachedReader struct {
|
||||
sync.Mutex
|
||||
reader *pipe.Reader
|
||||
cache buf.MultiBuffer
|
||||
|
||||
ReadBufferTimeout time.Duration
|
||||
}
|
||||
|
||||
func (r *cachedReader) Cache(b *buf.Buffer) {
|
||||
mb, _ := r.reader.ReadMultiBufferTimeout(time.Millisecond * 100)
|
||||
var timeout time.Duration
|
||||
if r.ReadBufferTimeout == 0 {
|
||||
timeout = time.Millisecond * 100
|
||||
} else {
|
||||
timeout = r.ReadBufferTimeout
|
||||
}
|
||||
mb, _ := r.reader.ReadMultiBufferTimeout(timeout)
|
||||
r.Lock()
|
||||
if !mb.IsEmpty() {
|
||||
r.cache, _ = buf.MergeMulti(r.cache, mb)
|
||||
@ -360,6 +368,8 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw
|
||||
|
||||
sniffer := NewSniffer(ctx)
|
||||
|
||||
cReader.ReadBufferTimeout = sniffer.Timeout
|
||||
|
||||
metaresult, metadataErr := sniffer.SniffMetadata(ctx)
|
||||
|
||||
if metadataOnly {
|
||||
|
Reference in New Issue
Block a user