Procházet zdrojové kódy

Missing \r\n after EHLO (#44)

Fix Missing \r\n after EHLO

Added missing \r\n after HELO response.
Clients would never care for the SIZE response
Philipp Resch před 8 roky
rodič
revize
0a1bf91ef8
1 změnil soubory, kde provedl 5 přidání a 2 odebrání
  1. 5 2
      server.go

+ 5 - 2
server.go

@@ -13,9 +13,10 @@ import (
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
 
 
-	"github.com/flashmob/go-guerrilla/backends"
 	"sync"
 	"sync"
 	"sync/atomic"
 	"sync/atomic"
+
+	"github.com/flashmob/go-guerrilla/backends"
 )
 )
 
 
 const (
 const (
@@ -281,12 +282,14 @@ func (server *server) handleClient(client *client) {
 		server.clientPool.GetActiveClientsCount(), time.Now().Format(time.RFC3339), runtime.NumGoroutine())
 		server.clientPool.GetActiveClientsCount(), time.Now().Format(time.RFC3339), runtime.NumGoroutine())
 
 
 	helo := fmt.Sprintf("250 %s Hello", sc.Hostname)
 	helo := fmt.Sprintf("250 %s Hello", sc.Hostname)
-	ehlo := fmt.Sprintf("250-%s Hello", sc.Hostname)
+	// ehlo is a multi-line reply and need additional \r\n at the end
+	ehlo := fmt.Sprintf("250-%s Hello\r\n", sc.Hostname)
 
 
 	// Extended feature advertisements
 	// Extended feature advertisements
 	messageSize := fmt.Sprintf("250-SIZE %d\r\n", sc.MaxSize)
 	messageSize := fmt.Sprintf("250-SIZE %d\r\n", sc.MaxSize)
 	pipelining := "250-PIPELINING\r\n"
 	pipelining := "250-PIPELINING\r\n"
 	advertiseTLS := "250-STARTTLS\r\n"
 	advertiseTLS := "250-STARTTLS\r\n"
+	// the last line doesn't need \r\n since string will be printed as a new line
 	help := "250 HELP"
 	help := "250 HELP"
 
 
 	if sc.TLSAlwaysOn {
 	if sc.TLSAlwaysOn {