Validation fixes

This commit is contained in:
Neil Alexander
2021-07-08 22:38:18 +01:00
parent 73ec35d5fa
commit f9ae101d38
4 changed files with 15 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package smtpserver
import (
"bytes"
"crypto/ed25519"
"encoding/hex"
"fmt"
"io"
"time"
@@ -26,7 +27,13 @@ func (s *SessionRemote) Mail(from string, opts smtp.MailOptions) error {
return fmt.Errorf("mail.ParseAddress: %w", err)
}
if local := s.state.RemoteAddr.String(); local != host {
pks, err := hex.DecodeString(host)
if err != nil {
return fmt.Errorf("hex.DecodeString: %w", err)
}
remote := base62.EncodeToString(pks)
if local := s.state.RemoteAddr.String(); local != remote {
return fmt.Errorf("not allowed to send incoming mail as %s", from)
}