mirror of
https://github.com/coredns/coredns.git
synced 2026-09-01 09:37:05 -04:00
18 lines
527 B
Go
18 lines
527 B
Go
|
|
package tsig
|
||
|
|
|
||
|
|
import "context"
|
||
|
|
|
||
|
|
type validatedKeyNameKey struct{}
|
||
|
|
|
||
|
|
// ValidatedKeyName returns the normalized name of the TSIG key validated by
|
||
|
|
// the tsig plugin. The boolean is false for unsigned requests and requests the
|
||
|
|
// plugin did not validate.
|
||
|
|
func ValidatedKeyName(ctx context.Context) (string, bool) {
|
||
|
|
name, ok := ctx.Value(validatedKeyNameKey{}).(string)
|
||
|
|
return name, ok
|
||
|
|
}
|
||
|
|
|
||
|
|
func withValidatedKeyName(ctx context.Context, name string) context.Context {
|
||
|
|
return context.WithValue(ctx, validatedKeyNameKey{}, name)
|
||
|
|
}
|