1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
Files
stackexchange-dnscontrol/pkg/rfc4183/mode.go
Tom Limoncelli 1d96981e11 NEW FEATURE: Add RFC4183 support to REV() (#2879)
Co-authored-by: Thomas Misilo <tmisilo@ksu.edu>
Co-authored-by: Jeffrey Cafferata <jeffrey@jcid.nl>
2024-04-03 16:01:55 -04:00

48 lines
811 B
Go

package rfc4183
import (
"fmt"
"strings"
)
var newmode bool
var modeset bool
func SetCompatibilityMode(m string) error {
if modeset {
return fmt.Errorf("ERROR: REVCOMPAT() already set")
}
modeset = true
switch strings.ToLower(m) {
case "rfc2317", "2317", "2", "old":
newmode = false
case "rfc4183", "4183", "4":
newmode = true
default:
return fmt.Errorf("invalid value %q, must be rfc2317 or rfc4182", m)
}
return nil
}
func IsRFC4183Mode() bool {
return newmode
}
var warningNeeded bool = false
func NeedsWarning() {
warningNeeded = true
}
func PrintWarning() {
if modeset {
// No warnings if REVCOMPAT() was used.
return
}
if !warningNeeded {
return
}
fmt.Printf("WARNING: REV() breaking change coming in v5.0. See https://docs.dnscontrol.org/functions/REVCOMPAT\n")
}