dialer: add bind device
This commit is contained in:
@ -64,11 +64,14 @@ func (d *quicDialer) Dial(ctx context.Context, addr string, opts ...dialer.DialO
|
||||
opt(options)
|
||||
}
|
||||
|
||||
netd := options.NetDialer
|
||||
if netd == nil {
|
||||
netd = dialer.DefaultNetDialer
|
||||
host := d.md.host
|
||||
if host == "" {
|
||||
host = options.Host
|
||||
}
|
||||
conn, err = netd.Dial(ctx, "udp", "")
|
||||
if h, _, _ := net.SplitHostPort(host); h != "" {
|
||||
host = h
|
||||
}
|
||||
conn, err = options.NetDialer.Dial(ctx, "udp", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ type metadata struct {
|
||||
handshakeTimeout time.Duration
|
||||
|
||||
cipherKey []byte
|
||||
host string
|
||||
}
|
||||
|
||||
func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
@ -21,6 +22,7 @@ func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
maxIdleTimeout = "maxIdleTimeout"
|
||||
|
||||
cipherKey = "cipherKey"
|
||||
host = "host"
|
||||
)
|
||||
|
||||
d.md.handshakeTimeout = mdata.GetDuration(md, handshakeTimeout)
|
||||
@ -32,5 +34,7 @@ func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
d.md.keepAlive = mdata.GetBool(md, keepAlive)
|
||||
d.md.handshakeTimeout = mdata.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdata.GetDuration(md, maxIdleTimeout)
|
||||
|
||||
d.md.host = mdata.GetString(md, host)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user