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

aliases: Implement "via" aliases

This patch implements "via" aliases, which let us explicitly select a
server to use for delivery.

This feature is useful in different scenarios, such as a secondary MX
server that forwards all incoming email to a primary.

For now, it is experimental and the syntax and semantics are subject to
change.
This commit is contained in:
Alberto Bertogli
2025-04-06 12:35:51 +01:00
parent 1cf24ba94a
commit 9999a69086
28 changed files with 671 additions and 74 deletions

View File

@@ -57,11 +57,27 @@ def msg_equals(expected, msg):
if expected[h] == "*":
continue
if not flexible_eq(val, msg[h]):
print("Header %r differs:" % h)
print("Exp: %r" % val)
print("Got: %r" % msg[h])
diff = True
msg_hdr_vals = msg.get_all(h, [])
if len(msg_hdr_vals) == 1:
if not flexible_eq(val, msg[h]):
print("Header %r differs:" % h)
print("Exp: %r" % val)
print("Got: %r" % msg[h])
diff = True
else:
# We have multiple values for this header, so we need to check each
# one, and only return a diff if none of them match.
# Note this will result in a false positive if two headers match
# the same expected one, but this is good enough for now.
for msg_hdr_val in msg_hdr_vals:
if flexible_eq(val, msg_hdr_val):
break
else:
print("Header %r differs, no matching header found" % h)
print("Exp: %r" % val)
for i, msg_hdr_val in enumerate(msg_hdr_vals):
print("Got %d: %r" % (i, msg_hdr_val))
diff = True
if diff:
return False