watcher: a name removed from the targets leaves the state (closes #223)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The port checks, which the first check after startup runs after its DNS checks, now also remove the domain and hostname entries of names no longer in DNSWATCHER_TARGETS, and the certificate entries of those names and of addresses a name no longer resolves to. A configured domain's own records, saved as a hostname entry under its name, are kept, and so are the certificate entries of a configured name none of whose nameservers answered, as its port entries already were. Nothing is notified. Model: opus-5-5
This commit is contained in:
@@ -291,6 +291,27 @@ func (s *State) GetDomainState(
|
||||
return ds, ok
|
||||
}
|
||||
|
||||
// DeleteDomainState removes a domain state entry.
|
||||
func (s *State) DeleteDomainState(domain string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
delete(s.snapshot.Domains, domain)
|
||||
}
|
||||
|
||||
// GetAllDomainNames returns the names of all domain state entries.
|
||||
func (s *State) GetAllDomainNames() []string {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
names := make([]string, 0, len(s.snapshot.Domains))
|
||||
for name := range s.snapshot.Domains {
|
||||
names = append(names, name)
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
// SetHostnameState updates the state for a hostname.
|
||||
func (s *State) SetHostnameState(
|
||||
hostname string,
|
||||
@@ -314,6 +335,28 @@ func (s *State) GetHostnameState(
|
||||
return hs, ok
|
||||
}
|
||||
|
||||
// DeleteHostnameState removes a hostname state entry.
|
||||
func (s *State) DeleteHostnameState(hostname string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
delete(s.snapshot.Hostnames, hostname)
|
||||
}
|
||||
|
||||
// GetAllHostnames returns the names of all hostname state entries,
|
||||
// which include each apex domain's own records.
|
||||
func (s *State) GetAllHostnames() []string {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
names := make([]string, 0, len(s.snapshot.Hostnames))
|
||||
for name := range s.snapshot.Hostnames {
|
||||
names = append(names, name)
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
// SetPortState updates the state for a port.
|
||||
func (s *State) SetPortState(key string, ps *PortState) {
|
||||
s.mu.Lock()
|
||||
@@ -376,6 +419,27 @@ func (s *State) GetCertificateState(
|
||||
return cs, ok
|
||||
}
|
||||
|
||||
// DeleteCertificateState removes a certificate state entry.
|
||||
func (s *State) DeleteCertificateState(key string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
delete(s.snapshot.Certificates, key)
|
||||
}
|
||||
|
||||
// GetAllCertificateKeys returns all certificate state keys.
|
||||
func (s *State) GetAllCertificateKeys() []string {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
keys := make([]string, 0, len(s.snapshot.Certificates))
|
||||
for k := range s.snapshot.Certificates {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
// checkDataDirWritable creates the data directory if needed, then writes
|
||||
// and removes the temp file that Save uses. It runs at startup so that an
|
||||
// unwritable directory stops the process, instead of the process running
|
||||
|
||||
Reference in New Issue
Block a user