From 6eda87ab56ddb43b5d36e1b85d4370cf80af877f Mon Sep 17 00:00:00 2001 From: Dan Duong Date: Tue, 15 Jan 2019 18:46:07 -0800 Subject: [PATCH 1/2] Allow protocol versions greater than 3.8 --- client.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 91402c9..5990f1f 100644 --- a/client.go +++ b/client.go @@ -312,10 +312,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 From 028051a7e876f8cad082c7d20412f6f935a6ec51 Mon Sep 17 00:00:00 2001 From: Dan Duong Date: Tue, 11 Feb 2020 15:53:37 -0800 Subject: [PATCH 2/2] Close the serverMessages channel when the server shuts down. --- client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client.go b/client.go index 5990f1f..79198d8 100644 --- a/client.go +++ b/client.go @@ -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 } @@ -419,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