Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Allow server protocol versions greater than 3.8 #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func Client(c net.Conn, cfg *ClientConfig) (*ClientConn, error) {

if err := conn.handshake(); err != nil {
conn.Close()
if cfg.ServerMessageCh != nil {
close(cfg.ServerMessageCh)
}
return nil, err
}

Expand Down Expand Up @@ -312,10 +315,9 @@ func (c *ClientConn) handshake() error {
return err
}
if maxMajor < 3 {
return fmt.Errorf("unsupported major version, less than 3: %d", maxMajor)
}
if maxMinor < 8 {
return fmt.Errorf("unsupported minor version, less than 8: %d", maxMinor)
return fmt.Errorf("unsupported version, less than 3.8: %d.%d", maxMajor, maxMinor)
} else if maxMajor == 3 && maxMinor < 8 {
return fmt.Errorf("unsupported version, less than 3.8: %d.%d", maxMajor, maxMinor)
}

// Respond with the version we will support
Expand Down Expand Up @@ -420,6 +422,11 @@ FindAuth:
// mainLoop reads messages sent from the server and routes them to the
// proper channels for users of the client to read.
func (c *ClientConn) mainLoop() {
defer func() {
if c.config.ServerMessageCh != nil {
close(c.config.ServerMessageCh)
}
}()
defer c.Close()

// Build the map of available server messages
Expand Down