update ftcp
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
package ftcp
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultTTL = 60 * time.Second
|
||||
defaultReadBufferSize = 1024
|
||||
defaultReadQueueSize = 128
|
||||
defaultConnQueueSize = 128
|
||||
)
|
||||
|
||||
const (
|
||||
addr = "addr"
|
||||
defaultBacklog = 128
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -18,5 +18,35 @@ type metadata struct {
|
||||
|
||||
readBufferSize int
|
||||
readQueueSize int
|
||||
connQueueSize int
|
||||
backlog int
|
||||
}
|
||||
|
||||
func (l *ftcpListener) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
ttl = "ttl"
|
||||
readBufferSize = "readBufferSize"
|
||||
readQueueSize = "readQueueSize"
|
||||
backlog = "backlog"
|
||||
)
|
||||
|
||||
l.md.ttl = mdata.GetDuration(md, ttl)
|
||||
if l.md.ttl <= 0 {
|
||||
l.md.ttl = defaultTTL
|
||||
}
|
||||
l.md.readBufferSize = mdata.GetInt(md, readBufferSize)
|
||||
if l.md.readBufferSize <= 0 {
|
||||
l.md.readBufferSize = defaultReadBufferSize
|
||||
}
|
||||
|
||||
l.md.readQueueSize = mdata.GetInt(md, readQueueSize)
|
||||
if l.md.readQueueSize <= 0 {
|
||||
l.md.readQueueSize = defaultReadQueueSize
|
||||
}
|
||||
|
||||
l.md.backlog = mdata.GetInt(md, backlog)
|
||||
if l.md.backlog <= 0 {
|
||||
l.md.backlog = defaultBacklog
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user