Răsfoiți Sursa

Ensure that authentication was successfull before we relay mails

Bernhard Froehlich 6 ani în urmă
părinte
comite
38aa14ddbf
1 a modificat fișierele cu 4 adăugiri și 0 ștergeri
  1. 4 0
      main.go

+ 4 - 0
main.go

@@ -122,6 +122,10 @@ func authChecker(peer smtpd.Peer, username string, password string) error {
 }
 
 func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error {
+	if *allowedUsers != "" && peer.Username == "" {
+		return smtpd.Error{Code: 530, Message: "Authentication Required"}
+	}
+
 	peerIP := ""
 	if addr, ok := peer.Addr.(*net.TCPAddr); ok {
 		peerIP = addr.IP.String()