1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-07 17:47:14 +00:00

chasquid: Fail at RCPT TO time if a user does not exist

It's more convenient and in line with standard practice to fail RCPT TO if the
user does not exist.

This involves making the server and client aware of aliases, but it doesn't
end up being very convoluted, and simplifies other code.
This commit is contained in:
Alberto Bertogli
2016-09-25 21:46:32 +01:00
parent ce379dea3e
commit 0995eac474
8 changed files with 163 additions and 20 deletions

View File

@@ -120,6 +120,19 @@ func (v *Resolver) Resolve(addr string) ([]Recipient, error) {
return v.resolve(0, addr)
}
// Exists check that the address exists in the database.
// It returns the cleaned address, and a boolean indicating the result.
// The clean address can be used to look it up in other databases, even if it
// doesn't exist.
func (v *Resolver) Exists(addr string) (string, bool) {
v.mu.Lock()
defer v.mu.Unlock()
addr = v.cleanIfLocal(addr)
_, ok := v.aliases[addr]
return addr, ok
}
func (v *Resolver) resolve(rcount int, addr string) ([]Recipient, error) {
if rcount >= recursionLimit {
return nil, ErrRecursionLimitExceeded