mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-02-14 12:15:22 -05:00
udp for shadowsocks
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package alloc
|
||||
|
||||
import (
|
||||
"io"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -72,6 +73,19 @@ func (b *Buffer) Write(data []byte) (int, error) {
|
||||
return len(data), nil
|
||||
}
|
||||
|
||||
func (b *Buffer) Read(data []byte) (int, error) {
|
||||
if b.Len() == 0 {
|
||||
return 0, io.EOF
|
||||
}
|
||||
nBytes := copy(data, b.Value)
|
||||
if nBytes == b.Len() {
|
||||
b.Value = b.Value[:0]
|
||||
} else {
|
||||
b.Value = b.Value[nBytes:]
|
||||
}
|
||||
return nBytes, nil
|
||||
}
|
||||
|
||||
type bufferPool struct {
|
||||
chain chan []byte
|
||||
allocator *sync.Pool
|
||||
|
||||
Reference in New Issue
Block a user