Пример #1
0
func (d *Discoverer) startLocalIPv6Multicasts(localMCAddr string) {
	intfs, err := net.Interfaces()
	if err != nil {
		if debug {
			l.Debugln("discover: interfaces:", err)
		}
		l.Infoln("Local discovery over IPv6 unavailable")
		return
	}

	v6Intfs := 0
	for _, intf := range intfs {
		// Interface flags seem to always be 0 on Windows
		if runtime.GOOS != "windows" && (intf.Flags&net.FlagUp == 0 || intf.Flags&net.FlagMulticast == 0) {
			continue
		}

		mb, err := beacon.NewMulticast(localMCAddr, intf.Name)
		if err != nil {
			if debug {
				l.Debugln("discover: Start local v6:", err)
			}
			continue
		}

		d.beacons = append(d.beacons, mb)
		go d.recvAnnouncements(mb)
		v6Intfs++
	}

	if v6Intfs == 0 {
		l.Infoln("Local discovery over IPv6 unavailable")
	}
}
Пример #2
0
func (d *Discoverer) startLocalIPv6Multicasts(localMCAddr string) {
	mb, err := beacon.NewMulticast(localMCAddr)
	if err != nil {
		if debug {
			l.Debugln("beacon.NewMulticast:", err)
		}
		l.Infoln("Local discovery over IPv6 unavailable")
		return
	}
	d.beacons = append(d.beacons, mb)
	go d.recvAnnouncements(mb)
}
Пример #3
0
func main() {
	flag.BoolVar(&all, "all", all, "Print all received announcements (not only first)")
	flag.BoolVar(&fake, "fake", fake, "Send fake announcements")
	flag.StringVar(&mc, "mc", mc, "IPv6 multicast address")
	flag.IntVar(&bc, "bc", bc, "IPv4 broadcast port number")
	flag.Parse()

	if fake {
		log.Println("My ID:", protocol.DeviceIDFromBytes(myID))
	}

	runbeacon(beacon.NewMulticast(mc), fake)
	runbeacon(beacon.NewBroadcast(bc), fake)

	select {}
}
Пример #4
0
func (c *localClient) startLocalIPv6Multicasts(localMCAddr string) {
	c.beacon = beacon.NewMulticast(localMCAddr)
	c.Add(c.beacon)
	go c.recvAnnouncements(c.beacon)
}