Forbid logins on the SMTP-STARTTLS port
Also, introduce the outline of a framework to handle message sending differently to message receipt.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package smtp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@@ -9,26 +9,33 @@ import (
|
||||
"ur.gs/crockery/internal/store"
|
||||
)
|
||||
|
||||
type Handler interface {
|
||||
Name() string
|
||||
Send(from string, to []string, r io.Reader) error
|
||||
}
|
||||
|
||||
// type Session implements the User interface for emersion/go-smtp
|
||||
type Session struct {
|
||||
ID uint64
|
||||
Account *store.Account
|
||||
ServiceName string
|
||||
ID uint64
|
||||
Account *store.Account
|
||||
Handler Handler
|
||||
}
|
||||
|
||||
func (s *Session) Send(from string, to []string, r io.Reader) error {
|
||||
// FIXME: TODO: don't keep this lot forever, it's for debugging purposes
|
||||
data, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("%s session %d for %s: from=%s, to=%s, r=<<EOF\n%s\nEOF", s.ServiceName, s.ID, s.Account.Username, from, to, string(data))
|
||||
log.Printf("%s session %d for %s: from=%s, to=%s, r=<<EOF\n%s\nEOF", s.Handler.Name(), s.ID, s.Account.Username, from, to, string(data))
|
||||
|
||||
return fmt.Errorf("Not yet implemented")
|
||||
memR := bytes.NewReader(data)
|
||||
return s.Handler.Send(from, to, memR)
|
||||
}
|
||||
|
||||
func (s *Session) Logout() error {
|
||||
log.Printf("Ending %s session %d for %s", s.ServiceName, s.ID, s.Account.Username)
|
||||
log.Printf("Ending %s session %d for %s", s.Handler.Name(), s.ID, s.Account.Username)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user