use fixed buffer size

This commit is contained in:
ginuerzh
2025-02-18 17:38:27 +08:00
parent d610e2dc01
commit e0915affda
14 changed files with 67 additions and 126 deletions
+4 -7
View File
@@ -8,26 +8,23 @@ import (
mdutil "github.com/go-gost/x/metadata/util"
)
const (
MaxMessageSize = math.MaxUint16
)
type metadata struct {
key string
readTimeout time.Duration
bufferSize int
}
func (h *ssuHandler) parseMetadata(md mdata.Metadata) (err error) {
const (
key = "key"
readTimeout = "readTimeout"
bufferSize = "bufferSize"
)
h.md.key = mdutil.GetString(md, key)
h.md.readTimeout = mdutil.GetDuration(md, readTimeout)
if bs := mdutil.GetInt(md, bufferSize); bs > 0 {
h.md.bufferSize = int(math.Min(math.Max(float64(bs), 512), 64*1024))
} else {
h.md.bufferSize = 4096
}
return
}