mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 13:00:47 +00:00
possibly make multicast automatic peer detection work on windows
This commit is contained in:
parent
e52b099d05
commit
83e0579ca8
14
yggdrasil.go
14
yggdrasil.go
@ -132,12 +132,17 @@ func (n *node) listen() {
|
|||||||
}
|
}
|
||||||
//if rcm == nil { continue } // wat
|
//if rcm == nil { continue } // wat
|
||||||
//fmt.Println("DEBUG:", "packet from:", fromAddr.String())
|
//fmt.Println("DEBUG:", "packet from:", fromAddr.String())
|
||||||
|
if rcm != nil {
|
||||||
|
// Windows can't set the flag needed to return a non-nil value here
|
||||||
|
// So only make these checks if we get something useful back
|
||||||
|
// TODO? Skip them always, I'm not sure if they're really needed...
|
||||||
if !rcm.Dst.IsLinkLocalMulticast() {
|
if !rcm.Dst.IsLinkLocalMulticast() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !rcm.Dst.Equal(groupAddr.IP) {
|
if !rcm.Dst.Equal(groupAddr.IP) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
anAddr := string(bs[:nBytes])
|
anAddr := string(bs[:nBytes])
|
||||||
addr, err := net.ResolveUDPAddr("udp6", anAddr)
|
addr, err := net.ResolveUDPAddr("udp6", anAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -163,11 +168,7 @@ func (n *node) announce() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
udpaddr := n.core.DEBUG_getGlobalUDPAddr()
|
var anAddr net.UDPAddr
|
||||||
anAddr, err := net.ResolveUDPAddr("udp6", udpaddr.String())
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
destAddr, err := net.ResolveUDPAddr("udp6", multicastAddr)
|
destAddr, err := net.ResolveUDPAddr("udp6", multicastAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -266,7 +267,8 @@ func main() {
|
|||||||
//defer conn.Close() // Let it close on its own when the application exits
|
//defer conn.Close() // Let it close on its own when the application exits
|
||||||
n.sock = ipv6.NewPacketConn(conn)
|
n.sock = ipv6.NewPacketConn(conn)
|
||||||
if err = n.sock.SetControlMessage(ipv6.FlagDst, true); err != nil {
|
if err = n.sock.SetControlMessage(ipv6.FlagDst, true); err != nil {
|
||||||
panic(err)
|
// Windows can't set this flag, so we need to handle it in other ways
|
||||||
|
//panic(err)
|
||||||
}
|
}
|
||||||
go n.listen()
|
go n.listen()
|
||||||
go n.announce()
|
go n.announce()
|
||||||
|
Loading…
Reference in New Issue
Block a user