From d9a5b1160cd9ac46cc76646dd419e0ad141710f2 Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 6 Jan 2021 21:35:22 -0500 Subject: [PATCH] Check major version only if it exists --- node.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/node.go b/node.go index dc2a1d6..41a3138 100644 --- a/node.go +++ b/node.go @@ -77,10 +77,11 @@ type FrameStats struct { func (node *Node) open(ctx context.Context) error { header := http.Header{} - header.Set("User-Agent", gavalinkUserAgent()) header.Set("Authorization", node.config.Password) header.Set("Num-Shards", strconv.Itoa(node.manager.shards)) header.Set("User-Id", node.manager.userID) + header.Set("Client-Name", "Gavalink") + header.Set("User-Agent", gavalinkUserAgent()) if node.manager.capabilities != nil { v := make([]string, 0) @@ -104,16 +105,19 @@ func (node *Node) open(ctx context.Context) error { return err } + // TODO: This isn't officially required, so we ignore it for now if it's empty. vstr := resp.Header.Get("Lavalink-Major-Version") - v, err := strconv.Atoi(vstr) + if vstr != "" { + v, err := strconv.Atoi(vstr) - if err != nil { - return err - } + if err != nil { + return err + } - if v < 3 { - return errInvalidVersion + if v < 3 { + return errInvalidVersion + } } node.wsConn = ws