Pull request: all: imp uniq validation err msgs
Updates #3975. Squashed commit of the following: commit f8578c2afb1bb5786e7b855a1715e0757bc08510 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Dec 28 16:39:13 2021 +0300 aghalgo: imp docs commit d9fc625f7c4ede2cf4b0683ad5efd0ddf9b966b1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Dec 28 16:21:24 2021 +0300 all: imp uniq validation err msgs
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghalgo"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
|
||||
"github.com/AdguardTeam/golibs/errors"
|
||||
@@ -250,7 +251,9 @@ func (t *TLSMod) handleTLSValidate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if setts.Enabled {
|
||||
if err = validatePorts(
|
||||
uv := aghalgo.UniquenessValidator{}
|
||||
addPorts(
|
||||
uv,
|
||||
config.BindPort,
|
||||
config.BetaBindPort,
|
||||
config.DNS.Port,
|
||||
@@ -258,8 +261,11 @@ func (t *TLSMod) handleTLSValidate(w http.ResponseWriter, r *http.Request) {
|
||||
setts.PortDNSOverTLS,
|
||||
setts.PortDNSOverQUIC,
|
||||
setts.PortDNSCrypt,
|
||||
); err != nil {
|
||||
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
||||
)
|
||||
|
||||
err = uv.Validate(aghalgo.IntIsBefore)
|
||||
if err != nil {
|
||||
aghhttp.Error(r, w, http.StatusBadRequest, "validating ports: %s", err)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -338,7 +344,9 @@ func (t *TLSMod) handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if data.Enabled {
|
||||
if err = validatePorts(
|
||||
uv := aghalgo.UniquenessValidator{}
|
||||
addPorts(
|
||||
uv,
|
||||
config.BindPort,
|
||||
config.BetaBindPort,
|
||||
config.DNS.Port,
|
||||
@@ -346,7 +354,10 @@ func (t *TLSMod) handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
|
||||
data.PortDNSOverTLS,
|
||||
data.PortDNSOverQUIC,
|
||||
data.PortDNSCrypt,
|
||||
); err != nil {
|
||||
)
|
||||
|
||||
err = uv.Validate(aghalgo.IntIsBefore)
|
||||
if err != nil {
|
||||
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user