@@ -32,7 +32,6 @@ import (
3232 "math/rand"
3333 "net"
3434 "os"
35- "regexp"
3635 "strconv"
3736 "sync"
3837 "sync/atomic"
@@ -202,48 +201,6 @@ func shuffleHosts(hosts []*HostInfo) []*HostInfo {
202201 return shuffled
203202}
204203
205- // this is going to be version dependant and a nightmare to maintain :(
206- var protocolSupportRe = regexp .MustCompile (`the lowest supported version is \d+ and the greatest is (\d+)$` )
207- var betaProtocolRe = regexp .MustCompile (`Beta version of the protocol used \(.*\), but USE_BETA flag is unset` )
208-
209- func parseProtocolFromError (err error ) int {
210- errStr := err .Error ()
211-
212- var errProtocol ErrProtocol
213- if errors .As (err , & errProtocol ) {
214- err = errProtocol .error
215- }
216-
217- // I really wish this had the actual info in the error frame...
218- matches := betaProtocolRe .FindAllStringSubmatch (errStr , - 1 )
219- if len (matches ) == 1 {
220- var protoErr * protocolError
221- if errors .As (err , & protoErr ) {
222- version := protoErr .frame .Header ().version .version ()
223- if version > 0 {
224- return int (version - 1 )
225- }
226- }
227- return 0
228- }
229-
230- matches = protocolSupportRe .FindAllStringSubmatch (errStr , - 1 )
231- if len (matches ) != 1 || len (matches [0 ]) != 2 {
232- var protoErr * protocolError
233- if errors .As (err , & protoErr ) {
234- return int (protoErr .frame .Header ().version .version ())
235- }
236- return 0
237- }
238-
239- max , err := strconv .Atoi (matches [0 ][1 ])
240- if err != nil {
241- return 0
242- }
243-
244- return max
245- }
246-
247204const highestProtocolVersionSupported = 5
248205const lowestProtocolVersionSupported = 3
249206
0 commit comments