[TASk] put multicast address in config file
This commit is contained in:
		
							parent
							
								
									b4e6cd5864
								
							
						
					
					
						commit
						0a207d0170
					
				@ -49,6 +49,9 @@ func main() {
 | 
			
		||||
	if config.Respondd.InterfaceSendMulticast == "" {
 | 
			
		||||
		config.Respondd.InterfaceSendMulticast = config.Respondd.InterfaceListen
 | 
			
		||||
	}
 | 
			
		||||
	if config.Respondd.MulticastDestination != "" {
 | 
			
		||||
		respond.MulticastGroup = config.Respondd.MulticastDestination
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	connections, err = allDB.Connect(config.Database.Connection)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -88,7 +91,7 @@ func main() {
 | 
			
		||||
			time.Sleep(delay)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		collector = respond.NewCollector(connections, nodes, config.Respondd.InterfaceListen, config.Respondd.InterfaceSendMulticast, config.Respondd.InterfaceSendUnicast, config.Respondd.Port)
 | 
			
		||||
		collector = respond.NewCollector(connections, nodes, config.Respondd.InterfaceListen, config.Respondd.InterfaceSendMulticast, config.Respondd.InterfaceSendUnicast, config.Respondd.ListenPort)
 | 
			
		||||
		collector.Start(config.Respondd.CollectInterval.Duration)
 | 
			
		||||
		defer collector.Close()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -120,7 +120,7 @@ func (coll *Collector) sendOnce() {
 | 
			
		||||
func (coll *Collector) sendMulticast() {
 | 
			
		||||
	log.Println("sending multicast")
 | 
			
		||||
	coll.SendPacket(net.UDPAddr{
 | 
			
		||||
		IP:   net.ParseIP(multiCastGroup),
 | 
			
		||||
		IP:   net.ParseIP(MulticastGroup),
 | 
			
		||||
		Zone: coll.ifaceSendMulticast,
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,9 +4,10 @@ import (
 | 
			
		||||
	"net"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
// default multicast group used by announced
 | 
			
		||||
	multiCastGroup = "ff02:0:0:0:0:0:2:1001"
 | 
			
		||||
var MulticastGroup string = "ff02:0:0:0:0:0:2:1001"
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
 | 
			
		||||
	// default udp port used by announced
 | 
			
		||||
	port = 1001
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,8 @@ type Config struct {
 | 
			
		||||
		InterfaceListen        string   `toml:"interface"`
 | 
			
		||||
		InterfaceSendMulticast string   `toml:"interface_send_multicast"`
 | 
			
		||||
		InterfaceSendUnicast   string   `toml:"interface_send_unicast"`
 | 
			
		||||
		Port                   int      `toml:"port"`
 | 
			
		||||
		ListenPort             int      `toml:"port"`
 | 
			
		||||
		MulticastDestination   string   `toml:"destination"`
 | 
			
		||||
		CollectInterval        Duration `toml:"collect_interval"`
 | 
			
		||||
	}
 | 
			
		||||
	Webserver struct {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user