mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
修订代码
This commit is contained in:
@@ -7,7 +7,7 @@ const (
|
||||
Log_debug = iota
|
||||
Log_info
|
||||
Log_warning
|
||||
Log_error
|
||||
Log_error //error一般用于输出一些 连接错误或者客户端协议错误之类的, 但不致命
|
||||
Log_fatal
|
||||
//Log_off //不支持不打印致命输出。既然致命我们一定要尸检然后查看病因啊
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -24,9 +25,13 @@ const StandardBytesLength int = 1500
|
||||
// https://en.wikipedia.org/wiki/Maximum_transmission_unit
|
||||
|
||||
//本作设定的最大buf大小,64k
|
||||
const MaxBufLen = 64 * 1024
|
||||
var MaxBufLen = DefaultMaxBufLen
|
||||
|
||||
const DefaultMaxBufLen = 64 * 1024
|
||||
|
||||
func init() {
|
||||
flag.IntVar(&MaxBufLen, "bl", DefaultMaxBufLen, "buf len")
|
||||
|
||||
standardBytesPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make([]byte, StandardBytesLength)
|
||||
@@ -46,6 +51,15 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
//给了参数调节buf大小后,需要更新pool
|
||||
func AdjustBufSize() {
|
||||
standardPacketPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make([]byte, MaxBufLen)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
//从Pool中获取一个 *bytes.Buffer
|
||||
func GetBuf() *bytes.Buffer {
|
||||
return bufPool.Get().(*bytes.Buffer)
|
||||
|
||||
Reference in New Issue
Block a user