diff --git a/cmd/yanic/main.go b/cmd/yanic/main.go index 5f1339a..214087f 100644 --- a/cmd/yanic/main.go +++ b/cmd/yanic/main.go @@ -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() } diff --git a/respond/collector.go b/respond/collector.go index 46c807e..88086d9 100644 --- a/respond/collector.go +++ b/respond/collector.go @@ -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, }) } diff --git a/respond/respond.go b/respond/respond.go index a7987b8..a6f1ad4 100644 --- a/respond/respond.go +++ b/respond/respond.go @@ -4,9 +4,10 @@ import ( "net" ) +// default multicast group used by announced +var MulticastGroup string = "ff02:0:0:0:0:0:2:1001" + const ( - // default multicast group used by announced - multiCastGroup = "ff02:0:0:0:0:0:2:1001" // default udp port used by announced port = 1001 diff --git a/runtime/config.go b/runtime/config.go index 66382a4..854edba 100644 --- a/runtime/config.go +++ b/runtime/config.go @@ -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 {