Pull request 1812: AG-21286

Merge in DNS/adguard-home from AG-21286 to master

Squashed commit of the following:

commit 587b4a3704fd63aa3da6c1be83f8a49bf4e27b00
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Apr 11 14:15:05 2023 +0300

    all: fix negative pause duration
This commit is contained in:
Ainar Garipov
2023-04-11 15:02:29 +03:00
parent 9e14d5f99f
commit 950ecb1f5e
4 changed files with 41 additions and 34 deletions

View File

@@ -648,17 +648,17 @@ func (s *Server) onGetCertificate(ch *tls.ClientHelloInfo) (*tls.Certificate, er
// UpdatedProtectionStatus updates protection state, if the protection was
// disabled temporarily. Returns the updated state of protection.
func (s *Server) UpdatedProtectionStatus() (enabled bool) {
func (s *Server) UpdatedProtectionStatus() (enabled bool, disabledUntil *time.Time) {
s.serverLock.RLock()
defer s.serverLock.RUnlock()
disabledUntil := s.conf.ProtectionDisabledUntil
disabledUntil = s.conf.ProtectionDisabledUntil
if disabledUntil == nil {
return s.conf.ProtectionEnabled
return s.conf.ProtectionEnabled, nil
}
if time.Now().Before(*disabledUntil) {
return false
return false, disabledUntil
}
// Update the values in a separate goroutine, unless an update is already in
@@ -671,7 +671,7 @@ func (s *Server) UpdatedProtectionStatus() (enabled bool) {
go s.enableProtectionAfterPause()
}
return true
return true, nil
}
// enableProtectionAfterPause sets the protection configuration to enabled