x/dialer/quic/metadata.go
2022-04-07 23:03:31 +08:00

39 lines
795 B
Go

package quic
import (
"time"
mdata "github.com/go-gost/core/metadata"
mdx "github.com/go-gost/x/metadata"
)
type metadata struct {
keepAlive bool
maxIdleTimeout time.Duration
handshakeTimeout time.Duration
cipherKey []byte
}
func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
const (
keepAlive = "keepAlive"
handshakeTimeout = "handshakeTimeout"
maxIdleTimeout = "maxIdleTimeout"
cipherKey = "cipherKey"
)
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
if key := mdx.GetString(md, cipherKey); key != "" {
d.md.cipherKey = []byte(key)
}
d.md.keepAlive = mdx.GetBool(md, keepAlive)
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
d.md.maxIdleTimeout = mdx.GetDuration(md, maxIdleTimeout)
return
}