Skip to content

Commit

Permalink
Change auth replies from string to []byte
Browse files Browse the repository at this point in the history
  • Loading branch information
Neopallium authored and emersion committed Mar 8, 2019
1 parent 76ca910 commit b06b466
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Client struct {
conn *imap.Conn
isTLS bool

replies chan string
replies chan []byte
loggedOut chan struct{}
upgrading bool

Expand Down Expand Up @@ -167,8 +167,8 @@ func (c *Client) readOnce() (bool, error) {
return true, nil
}

func (c *Client) writeReply(reply string) error {
if _, err := c.conn.Writer.Write([]byte(reply)); err != nil {
func (c *Client) writeReply(reply []byte) error {
if _, err := c.conn.Writer.Write(reply); err != nil {
return err
}
// Flush reply
Expand Down Expand Up @@ -562,7 +562,7 @@ func New(conn net.Conn) (*Client, error) {

c := &Client{
conn: imap.NewConn(conn, r, w),
replies: make(chan string),
replies: make(chan []byte),
loggedOut: make(chan struct{}),
state: imap.ConnectingState,
ErrorLog: log.New(os.Stderr, "imap/client: ", log.LstdFlags),
Expand Down
2 changes: 1 addition & 1 deletion client/cmd_noauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *Client) Authenticate(auth sasl.Client) error {
res := &responses.Authenticate{
Mechanism: auth,
InitialResponse: ir,
AuthReply: func(reply string) error {
AuthReply: func(reply []byte) error {
c.replies <- reply
return nil
},
Expand Down
4 changes: 2 additions & 2 deletions responses/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/emersion/go-sasl"
)

type AuthReplyFunc func(reply string) error
type AuthReplyFunc func(reply []byte) error

// An AUTHENTICATE response.
type Authenticate struct {
Expand All @@ -17,7 +17,7 @@ type Authenticate struct {
}

func (r *Authenticate) writeLine(l string) error {
return r.AuthReply(l + "\r\n")
return r.AuthReply([]byte(l + "\r\n"))
}

func (r *Authenticate) cancel() error {
Expand Down

0 comments on commit b06b466

Please sign in to comment.