Fix InterfacePeers

This commit is contained in:
Neil Alexander 2022-10-21 19:49:15 +01:00
parent b8a2d9f125
commit 81839ad50d
2 changed files with 6 additions and 10 deletions

View File

@ -39,8 +39,7 @@ func (l *linkTCP) dial(url *url.URL, options linkOptions, sintf string) error {
if err != nil {
return err
}
addr.Zone = sintf
dialer, err := l.dialerFor(addr.String(), sintf)
dialer, err := l.dialerFor(addr, sintf)
if err != nil {
return err
}
@ -121,13 +120,11 @@ func (l *linkTCP) getAddr() *net.TCPAddr {
return addr
}
func (l *linkTCP) dialerFor(saddr, sintf string) (*net.Dialer, error) {
dst, err := net.ResolveTCPAddr("tcp", saddr)
if err != nil {
return nil, err
}
func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error) {
if dst.IP.IsLinkLocalUnicast() {
dst.Zone = sintf
if sintf != "" {
dst.Zone = sintf
}
if dst.Zone == "" {
return nil, fmt.Errorf("link-local address requires a zone")
}

View File

@ -55,8 +55,7 @@ func (l *linkTLS) dial(url *url.URL, options linkOptions, sintf, sni string) err
if err != nil {
return err
}
addr.Zone = sintf
dialer, err := l.tcp.dialerFor(addr.String(), sintf)
dialer, err := l.tcp.dialerFor(addr, sintf)
if err != nil {
return err
}