add ttl option for quic

This commit is contained in:
ginuerzh
2022-08-21 21:47:07 +08:00
parent ca414f655d
commit dc36d50fb2
8 changed files with 38 additions and 18 deletions

View File

@ -59,7 +59,7 @@ func (l *icmpListener) Init(md md.Metadata) (err error) {
conn = admission.WrapPacketConn(l.options.Admission, conn)
config := &quic.Config{
KeepAlivePeriod: l.md.keepAlive,
KeepAlivePeriod: l.md.keepAlivePeriod,
HandshakeIdleTimeout: l.md.handshakeTimeout,
MaxIdleTimeout: l.md.maxIdleTimeout,
Versions: []quic.VersionNumber{

View File

@ -12,17 +12,17 @@ const (
)
type metadata struct {
keepAlive time.Duration
keepAlivePeriod time.Duration
handshakeTimeout time.Duration
maxIdleTimeout time.Duration
cipherKey []byte
backlog int
backlog int
}
func (l *icmpListener) parseMetadata(md mdata.Metadata) (err error) {
const (
keepAlive = "keepAlive"
keepAlivePeriod = "ttl"
handshakeTimeout = "handshakeTimeout"
maxIdleTimeout = "maxIdleTimeout"
@ -34,7 +34,12 @@ func (l *icmpListener) parseMetadata(md mdata.Metadata) (err error) {
l.md.backlog = defaultBacklog
}
l.md.keepAlive = mdx.GetDuration(md, keepAlive)
if mdx.GetBool(md, keepAlive) {
l.md.keepAlivePeriod = mdx.GetDuration(md, keepAlivePeriod)
if l.md.keepAlivePeriod <= 0 {
l.md.keepAlivePeriod = 10 * time.Second
}
}
l.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
l.md.maxIdleTimeout = mdx.GetDuration(md, maxIdleTimeout)