1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

aliases: Implement catch-all

This patch implements support for catch-all aliases, where users can add
a `*: destination` alias. Mails sent to unknown users (or other aliases)
will not be rejected, but sent to the indicated destination instead.

Please see https://github.com/albertito/chasquid/issues/23 and
https://github.com/albertito/chasquid/pull/24 for more discussion and
background.

Thanks to Alex Ellwein (aellwein@github) for the alternative patch and
help with testing; and to ThinkChaos (ThinkChaos@github) for help with
testing.
This commit is contained in:
Alberto Bertogli
2022-01-14 00:58:26 +00:00
parent 3255ff6801
commit f303e43082
7 changed files with 287 additions and 64 deletions

View File

@@ -224,7 +224,7 @@ func aliasesResolve() {
}
_ = os.Chdir(configDir)
r := aliases.NewResolver()
r := aliases.NewResolver(allUsersExist)
r.SuffixSep = *conf.SuffixSeparators
r.DropChars = *conf.DropCharacters
@@ -289,6 +289,8 @@ func domaininfoRemove() {
}
}
func allUsersExist(user, domain string) (bool, error) { return true, nil }
// chasquid-util aliases-add <source> <target>
func aliasesAdd() {
source := args["$2"]
@@ -315,7 +317,7 @@ func aliasesAdd() {
_ = os.Chdir(configDir)
// Setup alias resolver.
r := aliases.NewResolver()
r := aliases.NewResolver(allUsersExist)
r.SuffixSep = *conf.SuffixSeparators
r.DropChars = *conf.DropCharacters