新增dnst隧道

This commit is contained in:
wenyifan
2026-07-04 13:01:21 +08:00
parent bf85966600
commit 74fef8838e
9 changed files with 906 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
package dns
import (
"time"
mdata "github.com/go-gost/core/metadata"
mdutil "github.com/go-gost/x/metadata/util"
)
type metadata struct {
keepAlivePeriod time.Duration
maxIdleTimeout time.Duration
handshakeTimeout time.Duration
maxStreams int
enableDatagram bool
domain string
udpSize int
}
func (d *dnsDialer) parseMetadata(md mdata.Metadata) (err error) {
const (
keepAlive = "keepAlive"
keepAlivePeriod = "ttl"
handshakeTimeout = "handshakeTimeout"
maxIdleTimeout = "maxIdleTimeout"
maxStreams = "maxStreams"
domain = "domain"
udpSize = "udpSize"
)
if md == nil || !md.IsExists(keepAlive) || mdutil.GetBool(md, keepAlive) {
d.md.keepAlivePeriod = mdutil.GetDuration(md, keepAlivePeriod)
if d.md.keepAlivePeriod <= 0 {
d.md.keepAlivePeriod = 10 * time.Second
}
}
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
d.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
d.md.maxStreams = mdutil.GetInt(md, maxStreams)
d.md.enableDatagram = mdutil.GetBool(md, "quic.enableDatagram", "enableDatagram")
d.md.domain = mdutil.GetString(md, domain, "dns.domain")
d.md.udpSize = mdutil.GetInt(md, udpSize, "dns.udpSize")
return
}