package config import "fmt" type Interface struct { Zone string `yaml:"zone"` Interface string `yaml:"interface"` Options InterfaceOptions `yaml:"options,omitempty"` } type InterfaceOptions struct { DHCP bool `yaml:"dhcp,omitempty"` TCPFlags bool `yaml:"tcpflags,omitempty"` NoSmurfs bool `yaml:"nosmurfs,omitempty"` RouteBack bool `yaml:"routeback,omitempty"` Bridge bool `yaml:"bridge,omitempty"` Optional bool `yaml:"optional,omitempty"` } func (c *Config) validateInterfaces() error { seen := make(map[string]bool) for i, iface := range c.Interfaces { if iface.Interface == "" { return fmt.Errorf("interface[%d]: interface name required", i) } if iface.Zone == "" { return fmt.Errorf("interface[%d] %q: zone required", i, iface.Interface) } if _, ok := c.Zones[iface.Zone]; !ok { return fmt.Errorf("interface[%d] %q: zone %q not defined", i, iface.Interface, iface.Zone) } if seen[iface.Interface] { return fmt.Errorf("interface[%d]: duplicate interface %q", i, iface.Interface) } seen[iface.Interface] = true } return nil }