-
Notifications
You must be signed in to change notification settings - Fork 3
/
interface.go
76 lines (64 loc) · 3.25 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package popart
import (
"io"
)
// Handler is an object capable of serving a POP3 connection.
type Handler interface {
// AuthenticatePASS is generally the first method called on a Handler
// and should authentication fail it will return an error. It is
// expected though that if the authentication is successful the handler
// will be able to associate all subsequent operations with this
// particular user without an explicit need to pass username to each and
// every method.
AuthenticatePASS(username, password string) error
// AuthenticateAPOP provides an alternative method of POP3
// authentication where instead of a username/password combination the
// client generates an md5 hexdigest based on a shared secret and the
// banner displayed by the server at the beginning of the connection.
// As per RFC1939 a server MUST support at least one authentication
// mechanism but does not need to support any particular one.
AuthenticateAPOP(username, hexdigest string) error
// DeleteMessage takes a list of ordinal number of messages in a user's
// maildrop and deletes them. If this method fails it is expected that
// *none* of the messages will be deleted.
// Note: you can not assume that message IDs will come in any particular
// order.
DeleteMessages(numbers []uint64) error
// GetMessageReader takes an ordinal number of a message in a user's
// maildrop and returns an io.ReadCloser allowing the content of the
// message to be read. The server will take care of closing the data
// source.
GetMessageReader(number uint64) (io.ReadCloser, error)
// GetMessageCount returns a number of messages waiting in the user's
// maildrop.
GetMessageCount() (uint64, error)
// GetMessageCount takes and ordinal number of a message in a user's
// maildrop and returns it's locally (per-maildrop) unique ID that is
// persistent between sessions.
GetMessageID(number uint64) (string, error)
// GetMessageCount takes an ordinal number of a message in a users's
// maildrop and returns its size in bytes. This may differ from what is
// eventually returned to the client because of line ending replacements
// and dot escapes but it should be reasonably close nevertheless.
GetMessageSize(number uint64) (uint64, error)
// HandleSessionError would be invoked if the code *outside* of the
// handler errors produces an error. The session itself will terminate
// but this is a chance to log an error the way
HandleSessionError(err error)
// LockMaildrop puts a global lock on the user's maildrop so that
// any concurrent sessions that attempt to communicate with the server
// should fail until the current session calls UnlockMaildrop. This
// method should return an error if it is not possible to lock the
// maildrop.
LockMaildrop() error
// SetBanner is called by APOP-enabled servers at the beginning of the
// session. It is expected that the banner is stored somewhere since it
// is expected that it will be available for proper handling of the
// AuthenticateAPOP call.
SetBanner(banner string) error
// UnlockMaildrop releases global maildrop lock so that other clients
// can connect and initiate their sessions. It is generally the very
// last thing that will be called on a connection under normal
// circumstances.
UnlockMaildrop() error
}