Pull request: 4276 upd quic port
Merge in DNS/adguard-home from 4276-doq-port to master
Closes #4276.
Squashed commit of the following:
commit cbdde622b54d0d5d11d1b4809f95a41ace990a1b
Merge: d32c13e9 2c33ab6a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Wed Mar 23 15:47:43 2022 +0300
Merge branch 'master' into 4276-doq-port
commit d32c13e98f0fed2c863160e4e2de02ae3038e3df
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Mon Mar 21 21:55:09 2022 +0300
all: fix link
commit 0afd702f5192d727927df2f8d95b9317811a1be0
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Mon Mar 21 21:47:38 2022 +0300
all: imp docs, log changes
commit 9a77fc3daf78d32c577f1bc49aa1f8bc352d44e3
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Mon Mar 21 21:41:30 2022 +0300
home: upd quic port
This commit is contained in:
@@ -292,18 +292,20 @@ func parseConfig() (err error) {
|
||||
uc := aghalg.UniqChecker{}
|
||||
addPorts(
|
||||
uc,
|
||||
config.BindPort,
|
||||
config.BetaBindPort,
|
||||
config.DNS.Port,
|
||||
tcpPort(config.BindPort),
|
||||
tcpPort(config.BetaBindPort),
|
||||
udpPort(config.DNS.Port),
|
||||
)
|
||||
|
||||
if config.TLS.Enabled {
|
||||
addPorts(
|
||||
uc,
|
||||
config.TLS.PortHTTPS,
|
||||
config.TLS.PortDNSOverTLS,
|
||||
config.TLS.PortDNSOverQUIC,
|
||||
config.TLS.PortDNSCrypt,
|
||||
// TODO(e.burkov): Consider adding a udpPort with the same value if
|
||||
// we ever support the HTTP/3 for web admin interface.
|
||||
tcpPort(config.TLS.PortHTTPS),
|
||||
tcpPort(config.TLS.PortDNSOverTLS),
|
||||
udpPort(config.TLS.PortDNSOverQUIC),
|
||||
tcpPort(config.TLS.PortDNSCrypt),
|
||||
)
|
||||
}
|
||||
if err = uc.Validate(aghalg.IntIsBefore); err != nil {
|
||||
@@ -321,11 +323,23 @@ func parseConfig() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// addPorts is a helper for ports validation. It skips zero ports.
|
||||
func addPorts(uc aghalg.UniqChecker, ports ...int) {
|
||||
// udpPort is the port number for UDP protocol.
|
||||
type udpPort int
|
||||
|
||||
// tcpPort is the port number for TCP protocol.
|
||||
type tcpPort int
|
||||
|
||||
// addPorts is a helper for ports validation. It skips zero ports. Each of
|
||||
// ports should be either a udpPort or a tcpPort.
|
||||
func addPorts(uc aghalg.UniqChecker, ports ...interface{}) {
|
||||
for _, p := range ports {
|
||||
if p != 0 {
|
||||
uc.Add(p)
|
||||
switch p := p.(type) {
|
||||
case tcpPort, udpPort:
|
||||
if p != 0 {
|
||||
uc.Add(p)
|
||||
}
|
||||
default:
|
||||
// Go on.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func (req *checkConfReq) validateWeb(uc aghalg.UniqChecker) (err error) {
|
||||
defer func() { err = errors.Annotate(err, "validating ports: %w") }()
|
||||
|
||||
port := req.Web.Port
|
||||
addPorts(uc, config.BetaBindPort, port)
|
||||
addPorts(uc, tcpPort(config.BetaBindPort), tcpPort(port))
|
||||
if err = uc.Validate(aghalg.IntIsBefore); err != nil {
|
||||
// Avoid duplicating the error into the status of DNS.
|
||||
uc[port] = 1
|
||||
@@ -135,7 +135,7 @@ func (req *checkConfReq) validateDNS(uc aghalg.UniqChecker) (canAutofix bool, er
|
||||
defer func() { err = errors.Annotate(err, "validating ports: %w") }()
|
||||
|
||||
port := req.DNS.Port
|
||||
addPorts(uc, port)
|
||||
addPorts(uc, udpPort(port))
|
||||
if err = uc.Validate(aghalg.IntIsBefore); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const (
|
||||
defaultPortDNS = 53
|
||||
defaultPortHTTP = 80
|
||||
defaultPortHTTPS = 443
|
||||
defaultPortQUIC = 784
|
||||
defaultPortQUIC = 853
|
||||
defaultPortTLS = 853
|
||||
)
|
||||
|
||||
|
||||
@@ -305,17 +305,17 @@ func setupConfig(args options) (err error) {
|
||||
uc := aghalg.UniqChecker{}
|
||||
addPorts(
|
||||
uc,
|
||||
args.bindPort,
|
||||
config.BetaBindPort,
|
||||
config.DNS.Port,
|
||||
tcpPort(args.bindPort),
|
||||
tcpPort(config.BetaBindPort),
|
||||
udpPort(config.DNS.Port),
|
||||
)
|
||||
if config.TLS.Enabled {
|
||||
addPorts(
|
||||
uc,
|
||||
config.TLS.PortHTTPS,
|
||||
config.TLS.PortDNSOverTLS,
|
||||
config.TLS.PortDNSOverQUIC,
|
||||
config.TLS.PortDNSCrypt,
|
||||
tcpPort(config.TLS.PortHTTPS),
|
||||
tcpPort(config.TLS.PortDNSOverTLS),
|
||||
udpPort(config.TLS.PortDNSOverQUIC),
|
||||
tcpPort(config.TLS.PortDNSCrypt),
|
||||
)
|
||||
}
|
||||
if err = uc.Validate(aghalg.IntIsBefore); err != nil {
|
||||
|
||||
@@ -253,13 +253,13 @@ func (t *TLSMod) handleTLSValidate(w http.ResponseWriter, r *http.Request) {
|
||||
uc := aghalg.UniqChecker{}
|
||||
addPorts(
|
||||
uc,
|
||||
config.BindPort,
|
||||
config.BetaBindPort,
|
||||
config.DNS.Port,
|
||||
setts.PortHTTPS,
|
||||
setts.PortDNSOverTLS,
|
||||
setts.PortDNSOverQUIC,
|
||||
setts.PortDNSCrypt,
|
||||
tcpPort(config.BindPort),
|
||||
tcpPort(config.BetaBindPort),
|
||||
udpPort(config.DNS.Port),
|
||||
tcpPort(setts.PortHTTPS),
|
||||
tcpPort(setts.PortDNSOverTLS),
|
||||
udpPort(setts.PortDNSOverQUIC),
|
||||
tcpPort(setts.PortDNSCrypt),
|
||||
)
|
||||
|
||||
err = uc.Validate(aghalg.IntIsBefore)
|
||||
@@ -346,13 +346,13 @@ func (t *TLSMod) handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
|
||||
uc := aghalg.UniqChecker{}
|
||||
addPorts(
|
||||
uc,
|
||||
config.BindPort,
|
||||
config.BetaBindPort,
|
||||
config.DNS.Port,
|
||||
data.PortHTTPS,
|
||||
data.PortDNSOverTLS,
|
||||
data.PortDNSOverQUIC,
|
||||
data.PortDNSCrypt,
|
||||
tcpPort(config.BindPort),
|
||||
tcpPort(config.BetaBindPort),
|
||||
udpPort(config.DNS.Port),
|
||||
tcpPort(data.PortHTTPS),
|
||||
tcpPort(data.PortDNSOverTLS),
|
||||
udpPort(data.PortDNSOverQUIC),
|
||||
tcpPort(data.PortDNSCrypt),
|
||||
)
|
||||
|
||||
err = uc.Validate(aghalg.IntIsBefore)
|
||||
|
||||
Reference in New Issue
Block a user