mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-05-08 04:46:28 +03:00
Validation fixes
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user