mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-25 07:43:06 -07:00
feat: dynamic reread of aliases
This commit is contained in:
committed by
Bernhard Fröhlich
parent
381a9b334b
commit
b164ce1387
20
aliases.go
20
aliases.go
@@ -5,10 +5,15 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type AliasMap map[string]string
|
||||
|
||||
var (
|
||||
aliasesMutex sync.RWMutex
|
||||
)
|
||||
|
||||
func AliasLoadFile(file string) (AliasMap, error) {
|
||||
aliasMap := make(AliasMap)
|
||||
count := 0
|
||||
@@ -50,3 +55,18 @@ func AliasLoadFile(file string) (AliasMap, error) {
|
||||
}
|
||||
return aliasMap, nil
|
||||
}
|
||||
|
||||
func LoadAliases(filename string) error {
|
||||
newAliases, err := AliasLoadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
aliasesMutex.Lock()
|
||||
defer aliasesMutex.Unlock()
|
||||
|
||||
// Update the aliases map
|
||||
aliasesList = newAliases
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user