package server import ( "fmt" "net/netip" log "git.wntrmute.dev/kyle/goutils/syslog" "git.wntrmute.dev/kyle/kdhcp/iptools" ) // pools.go adds pool functionality to the server. func (srv *Server) loadPoolsFromConfig() error { for host, ip := range srv.Config.Statics { addr, ok := netip.AddrFromSlice(ip.To4()) if !ok { return fmt.Errorf("server: while instantiating pools, could not load IP %s", ip) } log.Debugf("server: added static host entry %s -> %s", host, addr) srv.Static[host] = &iptools.LeaseInfo{ HostName: host, Addr: addr, } } for name, ipRange := range srv.Config.Pools { pool, err := iptools.NewPool(name, ipRange) if err != nil { return fmt.Errorf("server: couldn't load pool %s: %w", name, err) } log.Debugf("server: added pool %s: %s -> %s", name, ipRange.Start, ipRange.End) srv.Pools[name] = pool } return nil }