1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

aliases: Support '*' as the destination user

This patch implements support for aliases that contain '*' as the
destination user.

In that case, we replace it with the original user.

For example, `*: *@pond` will redirect `lilly@domain` to `lilly@pond`.

This is experimental for now, and marked as such in the documentation.
The semantics can be subtle, so we may need to adjust them later.
This commit is contained in:
Alberto Bertogli
2025-03-24 10:38:11 +00:00
parent 8e4d31c74c
commit 2ee64deec0
4 changed files with 104 additions and 0 deletions

View File

@@ -286,6 +286,16 @@ func (v *Resolver) resolve(rcount int, addr string, tr *trace.Trace) ([]Recipien
continue
}
// If the user of the destination is "*", then we replace it with the
// original user.
// This allows for catch-all aliases that forward using the original
// user, like "*: *@otherdomain".
if envelope.UserOf(r.Addr) == "*" {
newAddr := user + "@" + envelope.DomainOf(r.Addr)
tr.Debugf("%d| replacing %q with %q", rcount, r.Addr, newAddr)
r.Addr = newAddr
}
ar, err := v.resolve(rcount+1, r.Addr, tr)
if err != nil {
tr.Debugf("%d| resolve(%q) returned error: %v", rcount, r.Addr, err)