mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-12-23 04:05:39 +00:00
Merge pull request #371 from neilalexander/multilink-fixes
Fix bugs from multilink branch (#360)
This commit is contained in:
commit
f38963c71b
@ -166,6 +166,7 @@ func (m *multicast) announce() {
|
||||
// Get the listener details and construct the multicast beacon
|
||||
lladdr := listener.listener.Addr().String()
|
||||
if a, err := net.ResolveTCPAddr("tcp6", lladdr); err == nil {
|
||||
a.Zone = ""
|
||||
destAddr.Zone = iface.Name
|
||||
msg := []byte(a.String())
|
||||
m.sock.WriteTo(msg, nil, destAddr)
|
||||
@ -208,8 +209,9 @@ func (m *multicast) listen() {
|
||||
if addr.IP.String() != from.IP.String() {
|
||||
continue
|
||||
}
|
||||
addr.Zone = from.Zone
|
||||
saddr := addr.String()
|
||||
m.core.link.call("tcp://"+saddr, addr.Zone)
|
||||
addr.Zone = ""
|
||||
if err := m.core.link.call("tcp://"+addr.String(), from.Zone); err != nil {
|
||||
m.core.log.Debugln("Call from multicast failed:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +259,16 @@ func (t *tcp) call(saddr string, options interface{}, sintf string) {
|
||||
}
|
||||
t.handler(conn, false, dialerdst.String())
|
||||
} else {
|
||||
dst, err := net.ResolveTCPAddr("tcp", saddr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if dst.IP.IsLinkLocalUnicast() {
|
||||
dst.Zone = sintf
|
||||
if dst.Zone == "" {
|
||||
return
|
||||
}
|
||||
}
|
||||
dialer := net.Dialer{
|
||||
Control: t.tcpContext,
|
||||
}
|
||||
@ -272,10 +282,6 @@ func (t *tcp) call(saddr string, options interface{}, sintf string) {
|
||||
}
|
||||
addrs, err := ief.Addrs()
|
||||
if err == nil {
|
||||
dst, err := net.ResolveTCPAddr("tcp", saddr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for addrindex, addr := range addrs {
|
||||
src, _, err := net.ParseCIDR(addr.String())
|
||||
if err != nil {
|
||||
@ -309,9 +315,9 @@ func (t *tcp) call(saddr string, options interface{}, sintf string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
conn, err = dialer.Dial("tcp", saddr)
|
||||
conn, err = dialer.Dial("tcp", dst.String())
|
||||
if err != nil {
|
||||
t.link.core.log.Debugln("Failed to dial TCP:", err)
|
||||
return
|
||||
}
|
||||
t.handler(conn, false, nil)
|
||||
|
Loading…
Reference in New Issue
Block a user