func (cs *Configs) Get(ip net.IP, mac net.HardwareAddr) string {
	for _, c := range *cs {
		if c.Match(ip, mac) {
			return c.Config
		}
	}
	return ""
}
Get returns the configuration matching the ip and mac conditions.
package config
import (
	"bytes"
	"fmt"
	"net"
	"strings"
)
type config struct {
	Config string
	Prefix *net.IPNet
	MAC    net.HardwareAddr
}
func newConfig(v string) (config, error) {
	idx := strings.IndexByte(v, '=')
	if idx == -1 {
		return config{Config: v}, nil
	}
	cond := strings.TrimSpace(v[:idx])
	conf := strings.TrimSpace(v[idx+1:])
	c := config{Config: conf}
	if _, ipnet, err := net.ParseCIDR(cond); err == nil {
		c.Prefix = ipnet
	} else if mac, err := net.ParseMAC(cond); err == nil {
		c.MAC = mac
	} else {
		return config{}, fmt.Errorf("%s: invalid condition format", cond)
	}
	return c, nil
}
func (c config) Match(ip net.IP, mac net.HardwareAddr) bool {
	if c.Prefix != nil {
		if ip == nil {
			return false
		}
		if !c.Prefix.Contains(ip) {
			return false
		}
	}
	if c.MAC != nil {
		if mac == nil {
			return false
		}
		if !bytes.Equal(c.MAC, mac) {
			return false
		}
	}
	return true
}
func (c config) String() string {
	if c.MAC != nil {
		return fmt.Sprintf("%s=%s", c.MAC, c.Config)
	}
	if c.Prefix != nil {
		return fmt.Sprintf("%s=%s", c.Prefix, c.Config)
	}
	return c.Config
}
type Configs []config