From 4e7e2bad46a960577cba146aac4f828ce9720223 Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Sun, 11 Mar 2018 20:21:35 +0100 Subject: [PATCH] [TASK] do not send multicast request (#121) --- config_example.toml | 3 +++ docs/docs_configuration.md | 12 ++++++++++++ respond/collector.go | 7 +++++-- respond/config.go | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/config_example.toml b/config_example.toml index e80203b..a5a3b53 100644 --- a/config_example.toml +++ b/config_example.toml @@ -25,6 +25,9 @@ ifname = "br-ffhb" # ip address which is used for sending # (optional - without definition used a address of ifname) ip_address = "fd2f:5119:f2d::5" +# disable sending multicast respondd request +# (for receiving only respondd packages e.g. database respondd) +#send_no_request = false # multicast address to destination of respondd # (optional - without definition used batman default ff02::2:1001) multicast_address = "ff05::2:1001" diff --git a/docs/docs_configuration.md b/docs/docs_configuration.md index 1fcfecf..470a5ae 100644 --- a/docs/docs_configuration.md +++ b/docs/docs_configuration.md @@ -21,6 +21,7 @@ collect_interval = "1m" [[respondd.interfaces]] ifname = "br-ffhb" #ip_address = "fe80::..." +#send_no_request = false #multicast_address = "ff02::2:1001" #port = 10001 ``` @@ -100,6 +101,7 @@ It is possible to have multiple interfaces, just add this group again with new p [[respondd.interfaces]] ifname = "br-ffhb" #ip_address = "fe80::..." +#send_no_request = false #multicast_address = "ff02::2:1001" #port = 10001 ``` @@ -124,6 +126,16 @@ ip_address = "fe80::..." ``` {% endmethod %} +### send_no_request +{% method %} +Disable sending multicast respondd request. +For receiving only respondd packages e.g. database respondd. +{% sample lang="toml" %} +```toml +send_no_request = true +``` +{% endmethod %} + ### multicast_address {% method %} Multicast address to destination of respondd. diff --git a/respond/collector.go b/respond/collector.go index 1727bab..6908980 100644 --- a/respond/collector.go +++ b/respond/collector.go @@ -18,7 +18,6 @@ import ( // Collector for a specificle respond messages type Collector struct { connections []multicastConn // UDP sockets - port int queue chan *Response // received responses db database.Connection @@ -30,6 +29,7 @@ type Collector struct { type multicastConn struct { Conn *net.UDPConn + SendRequest bool MulticastAddress net.IP } @@ -89,6 +89,7 @@ func (coll *Collector) listenUDP(iface InterfaceConfig) { coll.connections = append(coll.connections, multicastConn{ Conn: conn, + SendRequest: !iface.SendNoRequest, MulticastAddress: net.ParseIP(multicastAddress), }) @@ -163,7 +164,9 @@ func (coll *Collector) sendOnce() { func (coll *Collector) sendMulticast() { log.Println("sending multicasts") for _, conn := range coll.connections { - coll.sendPacket(conn.Conn, conn.MulticastAddress) + if conn.SendRequest { + coll.sendPacket(conn.Conn, conn.MulticastAddress) + } } } diff --git a/respond/config.go b/respond/config.go index 1d381ef..383ad9f 100644 --- a/respond/config.go +++ b/respond/config.go @@ -25,6 +25,7 @@ type SiteConfig struct { type InterfaceConfig struct { InterfaceName string `toml:"ifname"` IPAddress string `toml:"ip_address"` + SendNoRequest bool `toml:"send_no_request"` MulticastAddress string `toml:"multicast_address"` Port int `toml:"port"` }