/*
* Copyright (C) 2024 Jonni Liljamo <jonni@liljamo.com>
*
* This file is licensed under AGPL-3.0-or-later, see NOTICE and LICENSE for
* more information.
*/
package dns
import (
"log/slog"
"strings"
)
func zoneOf(fqdn string, zone string) bool {
// Get the index of the first '.', and compare everything after that to zone.
if index := strings.IndexByte(fqdn, '.'); index >= 0 {
index++
return fqdn[index:] == zone
}
// Probably both fqdn and zone were just '.'. Crossing my fingers and hoping
// this can't be reached in correct configuration.
slog.Error("Invalid use of zone_of", slog.String("fqdn", fqdn), slog.String("zone", zone))
return false
}