2019-01-24 02:54:21 +01:00
|
|
|
package respondd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/FreifunkBremen/yanic/data"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (d *Daemon) updateData() {
|
2019-04-10 13:18:05 +02:00
|
|
|
for iface, iData := range d.dataByInterface {
|
|
|
|
if iData.Nodeinfo == nil {
|
|
|
|
iData.Nodeinfo = &data.Nodeinfo{}
|
2019-01-24 02:54:21 +01:00
|
|
|
}
|
2019-04-10 13:18:05 +02:00
|
|
|
if iData.Statistics == nil {
|
|
|
|
iData.Statistics = &data.Statistics{}
|
|
|
|
}
|
|
|
|
if iData.Neighbours == nil {
|
|
|
|
iData.Neighbours = &data.Neighbours{}
|
|
|
|
}
|
|
|
|
d.updateNodeinfo(iface, iData)
|
|
|
|
d.updateStatistics(iface, iData)
|
|
|
|
d.updateNeighbours(iface, iData)
|
2019-01-24 02:54:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Daemon) getData(iface string) *data.ResponseData {
|
2019-06-16 19:41:44 +02:00
|
|
|
d.dataMX.Lock()
|
|
|
|
defer d.dataMX.Unlock()
|
2019-04-10 13:18:05 +02:00
|
|
|
if iData, ok := d.dataByInterface[iface]; ok {
|
|
|
|
return iData
|
2019-01-24 02:54:21 +01:00
|
|
|
}
|
|
|
|
d.dataByInterface[iface] = &data.ResponseData{}
|
|
|
|
d.updateData()
|
|
|
|
return d.dataByInterface[iface]
|
|
|
|
}
|