From ffe0ef235d5dca6afdde03890286bd4c510005ae Mon Sep 17 00:00:00 2001 From: Tyler Date: Mon, 14 Oct 2019 19:18:25 -0400 Subject: [PATCH] Ensure voice downloads are authenticated --- model.go | 9 +++++++-- node.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/model.go b/model.go index 895d89c..f51c4c7 100644 --- a/model.go +++ b/model.go @@ -90,7 +90,8 @@ type VoiceServerUpdate struct { type VoiceProcessingData struct { io.ReadCloser - Client *http.Client + node *Node + UserID string URL string File string @@ -99,7 +100,11 @@ type VoiceProcessingData struct { } func (v *VoiceProcessingData) open() error { - res, err := v.Client.Get(v.URL) + req, err := http.NewRequest(http.MethodGet, v.URL, nil) + + req.Header.Set("Authorization", v.node.config.Password) + + res, err := v.node.client.Do(req) if err != nil { return err diff --git a/node.go b/node.go index 0c1cdf7..aebb06f 100644 --- a/node.go +++ b/node.go @@ -208,7 +208,7 @@ func (node *Node) onEvent(v *fastjson.Value, msg []byte) error { track := jsonStringValue(v, "track") data := &VoiceProcessingData{ - Client: node.client, + node: node, UserID: jsonStringValue(v, "userId"), URL: fmt.Sprintf("%s/audio/%s", node.config.REST, track), File: track,