21 // Mcall represents a message passed between mailmux clients and servers.
22 // Operations requested by clients are T-messages (such as Tregister).
23 // Servers respond with the corresponding R-message (such as Rregister).
24 // Servers may instead respond with Rerror to inform the client, with a diagnostic message,
25 // that the request was not completed successfully.
26 // This design is loosely based on the Plan 9 network file protocol 9P.
29 Username string `json:",omitempty"` // Tregister, Rregister
30 Password string `json:",omitempty"` // Tregister
31 Error string `json:",omitempty"` // Rerror
32 Aliases []Alias `json:",omitempty"` // Rnew, Rlist, Tremove
33 Expiry time.Time `json:",omitempty"` // Tnew, Rnew
36 // ParseMcall parses and validates a JSON-encoded Mcall from r.
37 func ParseMcall(r io.Reader) (*Mcall, error) {
39 if err := json.NewDecoder(r).Decode(&mc); err != nil {
45 return nil, errors.New("empty error message")
47 case Tregister, Tnew, Tlist, Tremove:
48 if mc.Username == "" {
49 return nil, errors.New("empty username")
50 } else if mc.Password == "" {
51 return nil, errors.New("empty password")