From 0ef6527165e2cc02a405687f3a29f726c5474ea1 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 22 Mar 2017 18:31:23 +0700 Subject: [PATCH] simplify version negotiation code in the client --- client.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/client.go b/client.go index 906f55abd..2525a97df 100644 --- a/client.go +++ b/client.go @@ -186,24 +186,16 @@ func (c *client) handlePacket(remoteAddr net.Addr, packet []byte) error { } func (c *client) handlePacketWithVersionFlag(hdr *PublicHeader) error { - var hasCommonVersion bool // check if we're supporting any of the offered versions for _, v := range hdr.SupportedVersions { // check if the server sent the offered version in supported versions if v == c.version { return qerr.Error(qerr.InvalidVersionNegotiationPacket, "Server already supports client's version and should have accepted the connection.") } - if v != protocol.VersionUnsupported { - hasCommonVersion = true - } - } - if !hasCommonVersion { - utils.Infof("No common version found.") - return qerr.InvalidVersion } ok, highestSupportedVersion := protocol.HighestSupportedVersion(hdr.SupportedVersions) if !ok { - return qerr.VersionNegotiationMismatch + return qerr.InvalidVersion } // switch to negotiated version @@ -224,9 +216,6 @@ func (c *client) handlePacketWithVersionFlag(hdr *PublicHeader) error { if c.config.ConnState != nil { go c.config.ConnState(c.session, ConnStateVersionNegotiated) } - if err != nil { - return err - } return nil // version negotiation packets have no payload }