Pull request: dhcpd: imp normalization, validation

Updates #3056.

Squashed commit of the following:

commit 875954fc8d59980a39b03032007cbc15d87801ea
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed May 5 19:54:24 2021 +0300

    all: imp err msgs

commit c6ea471038ce28f608084b59d3447ff64124260f
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed May 5 17:55:12 2021 +0300

    dhcpd: imp normalization, validation
This commit is contained in:
Ainar Garipov
2021-05-06 13:02:48 +03:00
parent b3cd33dde1
commit f717776c64
10 changed files with 299 additions and 273 deletions

View File

@@ -2,6 +2,7 @@ package dnsforward
import (
"crypto/tls"
"errors"
"fmt"
"path"
"strings"
@@ -15,7 +16,8 @@ import (
func ValidateClientID(clientID string) (err error) {
err = aghnet.ValidateDomainNameLabel(clientID)
if err != nil {
return fmt.Errorf("invalid client id: %w", err)
// Replace the domain name label wrapper with our own.
return fmt.Errorf("invalid client id %q: %w", clientID, errors.Unwrap(err))
}
return nil