mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-11 22:31:04 +00:00
udp for shadowsocks
This commit is contained in:
1 parent
1f9bd5f692
commit
dde3f60e30
2 files changed
+97
-22
No files matched your search
@@ -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