diff --git a/smtp/session.go b/smtp/session.go index b4882b8..2922688 100644 --- a/smtp/session.go +++ b/smtp/session.go @@ -31,6 +31,7 @@ import ( type SMTPSession struct { connection net.Conn host string + buffer [4096]byte ReversePathBuffer *string ForwardPathBuffer []string @@ -38,10 +39,8 @@ type SMTPSession struct { func MakeSMTPSession(connection net.Conn, host string) SMTPSession { return SMTPSession{ - connection, - host, - nil, - []string{}, + connection: connection, + host: host, } } @@ -103,15 +102,14 @@ func (self *SMTPSession) TraceSession(direction string, message string) { } -var buffer = [1024]byte{} func (self *SMTPSession) Read(delimiter string) (string, error) { var message string for !strings.Contains(message, delimiter) { - num_read, err := self.connection.Read(buffer[:]) + num_read, err := self.connection.Read(self.buffer[:]) if err != nil { return "", err } - message += string(buffer[:num_read]) + message += string(self.buffer[:num_read]) } self.TraceSession(" ->", message)