5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 01:20:29 +00:00

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 { if err != nil {
return err return err
} }
addr.Zone = sintf dialer, err := l.dialerFor(addr, sintf)
dialer, err := l.dialerFor(addr.String(), sintf)
if err != nil { if err != nil {
return err return err
} }
@ -121,13 +120,11 @@ func (l *linkTCP) getAddr() *net.TCPAddr {
return addr return addr
} }
func (l *linkTCP) dialerFor(saddr, sintf string) (*net.Dialer, error) { func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error) {
dst, err := net.ResolveTCPAddr("tcp", saddr)
if err != nil {
return nil, err
}
if dst.IP.IsLinkLocalUnicast() { if dst.IP.IsLinkLocalUnicast() {
if sintf != "" {
dst.Zone = sintf dst.Zone = sintf
}
if dst.Zone == "" { if dst.Zone == "" {
return nil, fmt.Errorf("link-local address requires a 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 { if err != nil {
return err return err
} }
addr.Zone = sintf dialer, err := l.tcp.dialerFor(addr, sintf)
dialer, err := l.tcp.dialerFor(addr.String(), sintf)
if err != nil { if err != nil {
return err return err
} }