1 Star 0 Fork 0

朽木木/gost-x

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
metadata.go 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
hao_shen 提交于 2025-03-25 16:26 +08:00 . 2
package mws
import (
"net/http"
"time"
mdata "gitee.com/hao_shen/gost-core/metadata"
"gitee.com/hao_shen/gost-x/internal/util/mux"
mdutil "gitee.com/hao_shen/gost-x/metadata/util"
)
const (
defaultPath = "/ws"
defaultBacklog = 128
)
type metadata struct {
path string
backlog int
header http.Header
handshakeTimeout time.Duration
readHeaderTimeout time.Duration
readBufferSize int
writeBufferSize int
enableCompression bool
muxCfg *mux.Config
mptcp bool
}
func (l *mwsListener) parseMetadata(md mdata.Metadata) (err error) {
l.md.path = mdutil.GetString(md, "ws.path", "path")
if l.md.path == "" {
l.md.path = defaultPath
}
l.md.backlog = mdutil.GetInt(md, "ws.backlog", "backlog")
if l.md.backlog <= 0 {
l.md.backlog = defaultBacklog
}
l.md.handshakeTimeout = mdutil.GetDuration(md, "ws.handshakeTimeout", "handshakeTimeout")
l.md.readHeaderTimeout = mdutil.GetDuration(md, "ws.readHeaderTimeout", "readHeaderTimeout")
l.md.readBufferSize = mdutil.GetInt(md, "ws.readBufferSize", "readBufferSize")
l.md.writeBufferSize = mdutil.GetInt(md, "ws.writeBufferSize", "writeBufferSize")
l.md.enableCompression = mdutil.GetBool(md, "ws.enableCompression", "enableCompression")
l.md.muxCfg = &mux.Config{
Version: mdutil.GetInt(md, "mux.version"),
KeepAliveInterval: mdutil.GetDuration(md, "mux.keepaliveInterval"),
KeepAliveDisabled: mdutil.GetBool(md, "mux.keepaliveDisabled"),
KeepAliveTimeout: mdutil.GetDuration(md, "mux.keepaliveTimeout"),
MaxFrameSize: mdutil.GetInt(md, "mux.maxFrameSize"),
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
}
if mm := mdutil.GetStringMapString(md, "ws.header", "header"); len(mm) > 0 {
hd := http.Header{}
for k, v := range mm {
hd.Add(k, v)
}
l.md.header = hd
}
l.md.mptcp = mdutil.GetBool(md, "mptcp")
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hao_shen/gost-x.git
git@gitee.com:hao_shen/gost-x.git
hao_shen
gost-x
gost-x
v1.1.1

搜索帮助