1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-19 14:57:04 +00:00

Log how many things were loaded for each domain

This patch makes chasquid log how many users, aliases and DKIM keys were
loaded for each domain.

This makes it easier to confirm changes, and troubleshoot problems
related to these per-domain configuration files.
This commit is contained in:
Alberto Bertogli
2024-05-10 11:42:07 +01:00
parent e6a9410377
commit aae0367c60
7 changed files with 45 additions and 24 deletions

View File

@@ -347,7 +347,7 @@ func (v *Resolver) AddDomain(domain string) {
// AddAliasesFile to the resolver. The file will be parsed, and an error
// returned if it does not parse correctly. Note that the file not existing
// does NOT result in an error.
func (v *Resolver) AddAliasesFile(domain, path string) error {
func (v *Resolver) AddAliasesFile(domain, path string) (int, error) {
// We unconditionally add the domain and file on our list.
// Even if the file does not exist now, it may later. This makes it be
// consider when doing Reload.
@@ -360,10 +360,10 @@ func (v *Resolver) AddAliasesFile(domain, path string) error {
aliases, err := v.parseFile(domain, path)
if os.IsNotExist(err) {
return nil
return 0, nil
}
if err != nil {
return err
return 0, err
}
// Add the aliases to the resolver, overriding any previous values.
@@ -373,7 +373,7 @@ func (v *Resolver) AddAliasesFile(domain, path string) error {
}
v.mu.Unlock()
return nil
return len(aliases), nil
}
// AddAliasForTesting adds an alias to the resolver, for testing purposes.