Gut the Session interface

This commit is contained in:
2018-03-08 00:17:44 +00:00
parent 1d0fdec642
commit 442ca833ea
5 changed files with 30 additions and 49 deletions

View File

@@ -3,6 +3,7 @@ package smtp
import (
"context"
"fmt"
"io"
"log"
"sync/atomic"
@@ -58,14 +59,21 @@ func (m *mta) Login(user, pass string) (smtp.User, error) {
}
func (m *mta) AnonymousLogin() (smtp.User, error) {
sid := atomic.AddUint64(&m.sid, uint64(1))
session := &Session{
ID: atomic.AddUint64(&m.sid, uint64(1)),
Account: nil,
Handler: &Receiver{},
ID: fmt.Sprintf("smtp:%d", sid),
Handler: m,
}
log.Printf("Beginning SMTP session %d", session.ID)
log.Printf("Beginning session %d", session.ID)
// FIXME: TODO: Track ongoing sessions for termination or notifications
return session, nil
}
// User implementation for go-smtp after this point
// Since only anonymous login is permitted, there's no need to introduce an
// intermediary to track the logged-in user.
func (m *mta) ServeSMTP(from string, to []string, r io.Reader) error {
return fmt.Errorf("Not yet implemented")
}