1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-16 09:26:21 -05:00

fix snifer

This commit is contained in:
Darien Raymond 2017-04-25 01:56:08 +02:00
parent 00dd7d5cd2
commit 94405dd467
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 13 additions and 1 deletions

View File

@ -110,7 +110,7 @@ func snifer(ctx context.Context, sniferList []proxyman.KnownProtocols, outbound
if mb.IsEmpty() {
continue
}
nBytes, _ := mb.Read(payload)
nBytes := mb.Copy(payload)
for _, protocol := range sniferList {
var f func([]byte) (string, error)
switch protocol {

View File

@ -31,6 +31,18 @@ func (mb *MultiBuffer) AppendMulti(buf MultiBuffer) {
*mb = append(*mb, buf...)
}
func (mb MultiBuffer) Copy(b []byte) int {
total := 0
for _, bb := range mb {
nBytes := copy(b[total:], bb.Bytes())
total += nBytes
if nBytes < bb.Len() {
break
}
}
return total
}
func (mb *MultiBuffer) Read(b []byte) (int, error) {
endIndex := len(*mb)
totalBytes := 0