add ttl option for quic
This commit is contained in:
parent
ca414f655d
commit
dc36d50fb2
@ -105,7 +105,7 @@ func (d *icmpDialer) Dial(ctx context.Context, addr string, opts ...dialer.DialO
|
||||
|
||||
func (d *icmpDialer) initSession(ctx context.Context, addr net.Addr, conn net.PacketConn) (*quicSession, error) {
|
||||
quicConfig := &quic.Config{
|
||||
KeepAlivePeriod: d.md.keepAlive,
|
||||
KeepAlivePeriod: d.md.keepAlivePeriod,
|
||||
HandshakeIdleTimeout: d.md.handshakeTimeout,
|
||||
MaxIdleTimeout: d.md.maxIdleTimeout,
|
||||
Versions: []quic.VersionNumber{
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
keepAlive time.Duration
|
||||
keepAlivePeriod time.Duration
|
||||
maxIdleTimeout time.Duration
|
||||
handshakeTimeout time.Duration
|
||||
}
|
||||
@ -16,13 +16,17 @@ type metadata struct {
|
||||
func (d *icmpDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
keepAlive = "keepAlive"
|
||||
keepAlivePeriod = "ttl"
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
maxIdleTimeout = "maxIdleTimeout"
|
||||
)
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
|
||||
d.md.keepAlive = mdx.GetDuration(md, keepAlive)
|
||||
if mdx.GetBool(md, keepAlive) {
|
||||
d.md.keepAlivePeriod = mdx.GetDuration(md, keepAlivePeriod)
|
||||
if d.md.keepAlivePeriod <= 0 {
|
||||
d.md.keepAlivePeriod = 10 * time.Second
|
||||
}
|
||||
}
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdx.GetDuration(md, maxIdleTimeout)
|
||||
|
||||
|
@ -103,7 +103,7 @@ func (d *quicDialer) Dial(ctx context.Context, addr string, opts ...dialer.DialO
|
||||
|
||||
func (d *quicDialer) initSession(ctx context.Context, addr net.Addr, conn net.PacketConn) (*quicSession, error) {
|
||||
quicConfig := &quic.Config{
|
||||
KeepAlivePeriod: d.md.keepAlive,
|
||||
KeepAlivePeriod: d.md.keepAlivePeriod,
|
||||
HandshakeIdleTimeout: d.md.handshakeTimeout,
|
||||
MaxIdleTimeout: d.md.maxIdleTimeout,
|
||||
Versions: []quic.VersionNumber{
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
keepAlive time.Duration
|
||||
keepAlivePeriod time.Duration
|
||||
maxIdleTimeout time.Duration
|
||||
handshakeTimeout time.Duration
|
||||
|
||||
@ -18,19 +18,23 @@ type metadata struct {
|
||||
func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
keepAlive = "keepAlive"
|
||||
keepAlivePeriod = "ttl"
|
||||
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.GetDuration(md, keepAlive)
|
||||
if mdx.GetBool(md, keepAlive) {
|
||||
d.md.keepAlivePeriod = mdx.GetDuration(md, keepAlivePeriod)
|
||||
if d.md.keepAlivePeriod <= 0 {
|
||||
d.md.keepAlivePeriod = 10 * time.Second
|
||||
}
|
||||
}
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdx.GetDuration(md, maxIdleTimeout)
|
||||
|
||||
|
@ -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{
|
||||
|
@ -12,17 +12,17 @@ const (
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
keepAlive time.Duration
|
||||
keepAlivePeriod time.Duration
|
||||
handshakeTimeout time.Duration
|
||||
maxIdleTimeout time.Duration
|
||||
|
||||
cipherKey []byte
|
||||
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)
|
||||
|
||||
|
@ -68,7 +68,7 @@ func (l *quicListener) Init(md md.Metadata) (err error) {
|
||||
}
|
||||
|
||||
config := &quic.Config{
|
||||
KeepAlivePeriod: l.md.keepAlive,
|
||||
KeepAlivePeriod: l.md.keepAlivePeriod,
|
||||
HandshakeIdleTimeout: l.md.handshakeTimeout,
|
||||
MaxIdleTimeout: l.md.maxIdleTimeout,
|
||||
Versions: []quic.VersionNumber{
|
||||
|
@ -12,7 +12,8 @@ const (
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
keepAlive time.Duration
|
||||
// keepAlive bool
|
||||
keepAlivePeriod time.Duration
|
||||
handshakeTimeout time.Duration
|
||||
maxIdleTimeout time.Duration
|
||||
|
||||
@ -23,6 +24,7 @@ type metadata struct {
|
||||
func (l *quicListener) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
keepAlive = "keepAlive"
|
||||
keepAlivePeriod = "ttl"
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
maxIdleTimeout = "maxIdleTimeout"
|
||||
|
||||
@ -39,7 +41,12 @@ func (l *quicListener) parseMetadata(md mdata.Metadata) (err error) {
|
||||
l.md.cipherKey = []byte(key)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user