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