mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-03-30 22:13:32 +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"
|
||||
)
|
||||
|
||||
type protoPort struct {
|
||||
network string
|
||||
proto string
|
||||
port uint16
|
||||
}
|
||||
|
||||
needBindingCheck := []protoPort{}
|
||||
|
||||
if currConf.PortHTTPS != newConf.PortHTTPS {
|
||||
needBindingCheck = append(needBindingCheck, protoPort{
|
||||
network: networkTCP,
|
||||
proto: protoHTTPS,
|
||||
port: newConf.PortHTTPS,
|
||||
})
|
||||
}
|
||||
|
||||
if currConf.PortDNSOverTLS != newConf.PortDNSOverTLS {
|
||||
needBindingCheck = append(needBindingCheck, protoPort{
|
||||
network: networkTCP,
|
||||
proto: protoDoT,
|
||||
port: newConf.PortDNSOverTLS,
|
||||
})
|
||||
}
|
||||
|
||||
if currConf.PortDNSOverQUIC != newConf.PortDNSOverQUIC {
|
||||
needBindingCheck = append(needBindingCheck, protoPort{
|
||||
network: networkUDP,
|
||||
proto: protoDoQ,
|
||||
port: newConf.PortDNSOverQUIC,
|
||||
})
|
||||
}
|
||||
needBindingCheck := []struct {
|
||||
network string
|
||||
proto string
|
||||
currPort uint16
|
||||
newPort uint16
|
||||
}{{
|
||||
network: networkTCP,
|
||||
proto: protoHTTPS,
|
||||
currPort: currConf.PortHTTPS,
|
||||
newPort: newConf.PortHTTPS,
|
||||
}, {
|
||||
network: networkTCP,
|
||||
proto: protoDoT,
|
||||
currPort: currConf.PortDNSOverTLS,
|
||||
newPort: newConf.PortDNSOverTLS,
|
||||
}, {
|
||||
network: networkUDP,
|
||||
proto: protoDoQ,
|
||||
currPort: currConf.PortDNSOverQUIC,
|
||||
newPort: newConf.PortDNSOverQUIC,
|
||||
}}
|
||||
|
||||
var errs []error
|
||||
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)
|
||||
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