Kaynağa Gözat

Do not share Server instance with multiple listeners
to avoid mixing TLS and non TLS configurations in the same server.

Bernhard Froehlich 6 yıl önce
ebeveyn
işleme
b53d620dd5
2 değiştirilmiş dosya ile 8 ekleme ve 9 silme
  1. 7 7
      main.go
  2. 1 2
      smtp-proxy.ini

+ 7 - 7
main.go

@@ -41,18 +41,17 @@ func main() {
 
 	iniflags.Parse()
 
-	server := &smtpd.Server{
-		Hostname:	*hostName,
-		WelcomeMessage: *welcomeMsg,
-		Handler:        handler,
-		ForceTLS:	*localForceTLS,
-	}
-
 	listeners := strings.Split(*listen, " ")
 
 	for i := range(listeners) {
 		listener := listeners[i]
 
+		server := &smtpd.Server{
+			Hostname:	*hostName,
+			WelcomeMessage: *welcomeMsg,
+			Handler:        handler,
+		}
+
 		if strings.Index(listeners[i], "://") == -1 {
 			;
 		} else if strings.HasPrefix(listeners[i], "tls://") || strings.HasPrefix(listeners[i], "starttls://") {
@@ -69,6 +68,7 @@ func main() {
 				log.Fatal(err)
 			}
 
+			server.ForceTLS = *localForceTLS
 			server.TLSConfig = &tls.Config {
 				Certificates: [] tls.Certificate{cert},
 			}

+ 1 - 2
smtp-proxy.ini

@@ -18,8 +18,7 @@
 ;local_key  = smtpd.key
 
 ; Enforce encrypted connection on STARTTLS ports before
-; accepting mails from client. Cannot be used with plain
-; non encrypted listeners.
+; accepting mails from client.
 ;local_forcetls = false
 
 ; Relay all mails to this SMTP server