mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-04-02 15:33:36 +03:00
home: imp code
This commit is contained in:
parent
20be72abd4
commit
381f7666b0
1 changed files with 28 additions and 33 deletions
|
@ -717,44 +717,39 @@ func (m *tlsManager) checkPortAvailability(
|
||||||
protoDoQ = "DNS-over-QUIC"
|
protoDoQ = "DNS-over-QUIC"
|
||||||
)
|
)
|
||||||
|
|
||||||
type protoPort struct {
|
needBindingCheck := []struct {
|
||||||
network string
|
network string
|
||||||
proto string
|
proto string
|
||||||
port uint16
|
currPort uint16
|
||||||
}
|
newPort uint16
|
||||||
|
}{{
|
||||||
needBindingCheck := []protoPort{}
|
network: networkTCP,
|
||||||
|
proto: protoHTTPS,
|
||||||
if currConf.PortHTTPS != newConf.PortHTTPS {
|
currPort: currConf.PortHTTPS,
|
||||||
needBindingCheck = append(needBindingCheck, protoPort{
|
newPort: newConf.PortHTTPS,
|
||||||
network: networkTCP,
|
}, {
|
||||||
proto: protoHTTPS,
|
network: networkTCP,
|
||||||
port: newConf.PortHTTPS,
|
proto: protoDoT,
|
||||||
})
|
currPort: currConf.PortDNSOverTLS,
|
||||||
}
|
newPort: newConf.PortDNSOverTLS,
|
||||||
|
}, {
|
||||||
if currConf.PortDNSOverTLS != newConf.PortDNSOverTLS {
|
network: networkUDP,
|
||||||
needBindingCheck = append(needBindingCheck, protoPort{
|
proto: protoDoQ,
|
||||||
network: networkTCP,
|
currPort: currConf.PortDNSOverQUIC,
|
||||||
proto: protoDoT,
|
newPort: newConf.PortDNSOverQUIC,
|
||||||
port: newConf.PortDNSOverTLS,
|
}}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if currConf.PortDNSOverQUIC != newConf.PortDNSOverQUIC {
|
|
||||||
needBindingCheck = append(needBindingCheck, protoPort{
|
|
||||||
network: networkUDP,
|
|
||||||
proto: protoDoQ,
|
|
||||||
port: newConf.PortDNSOverQUIC,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var errs []error
|
var errs []error
|
||||||
for _, v := range needBindingCheck {
|
for _, v := range needBindingCheck {
|
||||||
addrPort := netip.AddrPortFrom(addr, v.port)
|
port := v.newPort
|
||||||
|
if v.currPort == port {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
addrPort := netip.AddrPortFrom(addr, port)
|
||||||
err = aghnet.CheckPort(v.network, addrPort)
|
err = aghnet.CheckPort(v.network, addrPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("port %d for %s is not available", v.port, v.proto))
|
errs = append(errs, fmt.Errorf("port %d for %s is not available", port, v.proto))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue