mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-12-23 08:45:39 +00:00
Allow multiple connections to the same link-local address
Note that this may mean that currently we end up with two links to each multicast-discovered peer, one incoming and one outgoing
This commit is contained in:
parent
c505097be0
commit
8ecc402d7c
@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -641,16 +640,6 @@ func (l *links) handler(linkType linkType, options linkOptions, conn net.Conn, s
|
||||
|
||||
func urlForLinkInfo(u url.URL) url.URL {
|
||||
u.RawQuery = ""
|
||||
if host, _, err := net.SplitHostPort(u.Host); err == nil {
|
||||
if addr, err := netip.ParseAddr(host); err == nil {
|
||||
// For peers that look like multicast peers (i.e.
|
||||
// link-local addresses), we will ignore the port number,
|
||||
// otherwise we might open multiple connections to them.
|
||||
if addr.IsLinkLocalUnicast() {
|
||||
u.Host = fmt.Sprintf("[%s]", addr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user