DEVELOPMENT ENVIRONMENT

~liljamo/felu

ref: 4992844348f2ecabf096daf60a71f737a928683a felu/internal/dns/misc.go -rw-r--r-- 675 bytes
49928443Jonni Liljamo docs: update README.md 23 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * 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
}