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