diff --git a/bindata.go b/bindata.go index 2303d16..cee372a 100644 --- a/bindata.go +++ b/bindata.go @@ -1594,13 +1594,13 @@ type _bintree_t struct { var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ "assets": &_bintree_t{nil, map[string]*_bintree_t{ "images": &_bintree_t{nil, map[string]*_bintree_t{ + "ajax-loader.gif": &_bintree_t{assets_images_ajax_loader_gif, map[string]*_bintree_t{}}, "github.png": &_bintree_t{assets_images_github_png, map[string]*_bintree_t{}}, "hog.png": &_bintree_t{assets_images_hog_png, map[string]*_bintree_t{}}, - "ajax-loader.gif": &_bintree_t{assets_images_ajax_loader_gif, map[string]*_bintree_t{}}, }}, "js": &_bintree_t{nil, map[string]*_bintree_t{ - "controllers.js": &_bintree_t{assets_js_controllers_js, map[string]*_bintree_t{}}, "strutil.js": &_bintree_t{assets_js_strutil_js, map[string]*_bintree_t{}}, + "controllers.js": &_bintree_t{assets_js_controllers_js, map[string]*_bintree_t{}}, }}, "templates": &_bintree_t{nil, map[string]*_bintree_t{ "index.html": &_bintree_t{assets_templates_index_html, map[string]*_bintree_t{}}, diff --git a/mailhog/smtp/server/protocol.go b/mailhog/smtp/server/protocol.go index d7a44c2..cfe1db6 100644 --- a/mailhog/smtp/server/protocol.go +++ b/mailhog/smtp/server/protocol.go @@ -8,15 +8,14 @@ import ( "regexp" "strings" - "github.com/ian-kent/Go-MailHog/mailhog/config" "github.com/ian-kent/Go-MailHog/mailhog/data" ) // Protocol is a state machine representing an SMTP session type Protocol struct { - conf *config.Config - state State - message *data.SMTPMessage + state State + message *data.SMTPMessage + hostname string MessageIDHandler func() (string, error) LogHandler func(message string, args ...interface{}) @@ -84,9 +83,8 @@ var StateMap = map[State]string{ // NewProtocol returns a new SMTP state machine in INVALID state // handler is called when a message is received and should return a message ID -func NewProtocol(cfg *config.Config) *Protocol { +func NewProtocol() *Protocol { return &Protocol{ - conf: cfg, state: INVALID, message: &data.SMTPMessage{}, } @@ -104,11 +102,12 @@ func (proto *Protocol) logf(message string, args ...interface{}) { } // Start begins an SMTP conversation with a 220 reply -func (proto *Protocol) Start() *Reply { +func (proto *Protocol) Start(hostname string) *Reply { proto.state = ESTABLISH + proto.hostname = hostname return &Reply{ status: 220, - lines: []string{proto.conf.Hostname + " ESMTP Go-MailHog"}, + lines: []string{hostname + " ESMTP Go-MailHog"}, } } @@ -151,7 +150,7 @@ func (proto *Protocol) ProcessData(line string) (reply *Reply) { proto.message.Data = strings.TrimSuffix(proto.message.Data, "\r\n.\r\n") proto.state = MAIL - msg := proto.message.Parse(proto.conf.Hostname) + msg := proto.message.Parse(proto.hostname) if proto.MessageReceivedHandler != nil { id, err := proto.MessageReceivedHandler(msg) diff --git a/mailhog/smtp/server/session.go b/mailhog/smtp/server/session.go index 9741268..c6872b3 100644 --- a/mailhog/smtp/server/session.go +++ b/mailhog/smtp/server/session.go @@ -25,13 +25,13 @@ type Session struct { // Accept starts a new SMTP session using net.TCPConn func Accept(conn *net.TCPConn, conf *config.Config) { - proto := NewProtocol(conf) + proto := NewProtocol() session := &Session{conn, proto, conf, false, ""} proto.LogHandler = session.logf proto.MessageReceivedHandler = session.acceptMessageHandler session.logf("Starting session") - session.Write(proto.Start()) + session.Write(proto.Start(conf.Hostname)) for session.Read() == true { } session.logf("Session ended")