configurate interfaces for mac, addresses and traffic

This commit is contained in:
Martin/Geno 2019-06-23 04:06:01 +02:00 committed by genofire
parent 0b22130eb5
commit 220e8bf97e
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
4 changed files with 17 additions and 4 deletions

View File

@ -15,7 +15,9 @@ hostname = ""
site_code = "ffhb" site_code = "ffhb"
domain_code = "" domain_code = ""
vpn = false vpn = false
traffic_interfaces = [ "eth0" ] interface_mac = "eth0"
interfaces_traffic = [ "eth0" ]
interfaces_address = [ "br-ffhb", "eth0" ]
[defaults.location] [defaults.location]
latitude = 53.112446246 latitude = 53.112446246

View File

@ -41,7 +41,9 @@ type AnswerConfig struct {
DomainCode string `toml:"domain_code"` DomainCode string `toml:"domain_code"`
Location *data.Location `json:"location,omitempty"` Location *data.Location `json:"location,omitempty"`
VPN bool `toml:"vpn"` 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) { func (d *Daemon) getAnswer(iface string) (*AnswerConfig, string) {

View File

@ -60,14 +60,23 @@ func (d *Daemon) updateNodeinfo(iface string, resp *data.ResponseData) {
resp.Nodeinfo.Software.Babeld.Version = babel.Version() 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 == "" { 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]) 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) resp.Nodeinfo.Network.Addresses = getAddresses(iface)
} else { } else {
resp.Nodeinfo.Network.Addresses = []string{} 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) resp.Nodeinfo.Network.Mesh = make(map[string]*data.NetworkInterface)
for _, bface := range d.Batman { for _, bface := range d.Batman {

View File

@ -37,7 +37,7 @@ func (d *Daemon) updateStatistics(iface string, resp *data.ResponseData) {
allowedInterfaces := make(map[string]bool) allowedInterfaces := make(map[string]bool)
for _, iface := range config.TrafficInterfaces { for _, iface := range config.InterfacesTraffic {
allowedInterfaces[iface] = true allowedInterfaces[iface] = true
} }