diff --git a/config-respondd_example.toml b/config-respondd_example.toml index 497f2b72..17f9738a 100644 --- a/config-respondd_example.toml +++ b/config-respondd_example.toml @@ -15,7 +15,9 @@ hostname = "" site_code = "ffhb" domain_code = "" vpn = false -traffic_interfaces = [ "eth0" ] +interface_mac = "eth0" +interfaces_traffic = [ "eth0" ] +interfaces_address = [ "br-ffhb", "eth0" ] [defaults.location] latitude = 53.112446246 diff --git a/respond/daemon/config.go b/respond/daemon/config.go index ebfd0e8c..e6d0407e 100644 --- a/respond/daemon/config.go +++ b/respond/daemon/config.go @@ -41,7 +41,9 @@ type AnswerConfig struct { DomainCode string `toml:"domain_code"` Location *data.Location `json:"location,omitempty"` VPN bool `toml:"vpn"` - TrafficInterfaces []string `toml:"traffic_interfaces"` + InterfaceMAC string `toml:"interface_mac"` + InterfacesTraffic []string `toml:"interfaces_traffic"` + InterfacesAddress []string `toml:"interfaces_address"` } func (d *Daemon) getAnswer(iface string) (*AnswerConfig, string) { diff --git a/respond/daemon/nodeinfo.go b/respond/daemon/nodeinfo.go index 283b980f..5cdee57a 100644 --- a/respond/daemon/nodeinfo.go +++ b/respond/daemon/nodeinfo.go @@ -60,14 +60,23 @@ func (d *Daemon) updateNodeinfo(iface string, resp *data.ResponseData) { resp.Nodeinfo.Software.Babeld.Version = babel.Version() } + if config.InterfaceMAC != "" { + i, err := net.InterfaceByName(config.InterfaceMAC) + if err == nil { + resp.Nodeinfo.Network.Mac = i.HardwareAddr.String() + } + } if resp.Nodeinfo.Network.Mac == "" { resp.Nodeinfo.Network.Mac = fmt.Sprintf("%s:%s:%s:%s:%s:%s", nodeID[0:2], nodeID[2:4], nodeID[4:6], nodeID[6:8], nodeID[8:10], nodeID[10:12]) } - if iface != "" { + if iface != "" && len(config.InterfacesAddress) == 0 { resp.Nodeinfo.Network.Addresses = getAddresses(iface) } else { resp.Nodeinfo.Network.Addresses = []string{} + for _, ifname := range config.InterfacesAddress { + resp.Nodeinfo.Network.Addresses = append(resp.Nodeinfo.Network.Addresses, getAddresses(ifname)...) + } } resp.Nodeinfo.Network.Mesh = make(map[string]*data.NetworkInterface) for _, bface := range d.Batman { diff --git a/respond/daemon/statistics.go b/respond/daemon/statistics.go index 4b23530d..c4fa07a4 100644 --- a/respond/daemon/statistics.go +++ b/respond/daemon/statistics.go @@ -37,7 +37,7 @@ func (d *Daemon) updateStatistics(iface string, resp *data.ResponseData) { allowedInterfaces := make(map[string]bool) - for _, iface := range config.TrafficInterfaces { + for _, iface := range config.InterfacesTraffic { allowedInterfaces[iface] = true }