diff options
author | Jordan <me@jordan.im> | 2022-09-30 11:52:44 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2022-09-30 11:52:44 -0700 |
commit | 0192a4e3f1c90df255e44831a579d9b0f611a543 (patch) | |
tree | 52c6bfa35b5491560af253a5e5ba90ed8a729871 /vendor/github.com/bwmarrin/discordgo/voice.go | |
parent | 66bfe530b4fd5cb9755337ce718df26ee81f1b77 (diff) | |
download | keep-0192a4e3f1c90df255e44831a579d9b0f611a543.tar.gz keep-0192a4e3f1c90df255e44831a579d9b0f611a543.zip |
go.mod: bump discordgo, go-sqlite3, x/net
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo/voice.go')
-rw-r--r-- | vendor/github.com/bwmarrin/discordgo/voice.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/voice.go b/vendor/github.com/bwmarrin/discordgo/voice.go index aedb879..efd8809 100644 --- a/vendor/github.com/bwmarrin/discordgo/voice.go +++ b/vendor/github.com/bwmarrin/discordgo/voice.go @@ -120,9 +120,9 @@ func (v *VoiceConnection) ChangeChannel(channelID string, mute, deaf bool) (err v.log(LogInformational, "called") data := voiceChannelJoinOp{4, voiceChannelJoinData{&v.GuildID, &channelID, mute, deaf}} - v.wsMutex.Lock() + v.session.wsMutex.Lock() err = v.session.wsConn.WriteJSON(data) - v.wsMutex.Unlock() + v.session.wsMutex.Unlock() if err != nil { return } @@ -304,7 +304,7 @@ func (v *VoiceConnection) open() (err error) { // Connect to VoiceConnection Websocket vg := "wss://" + strings.TrimSuffix(v.endpoint, ":80") v.log(LogInformational, "connecting to voice endpoint %s", vg) - v.wsConn, _, err = websocket.DefaultDialer.Dial(vg, nil) + v.wsConn, _, err = v.session.Dialer.Dial(vg, nil) if err != nil { v.log(LogWarning, "error connecting to voice endpoint %s, %s", vg, err) v.log(LogDebug, "voice struct: %#v\n", v) @@ -323,7 +323,9 @@ func (v *VoiceConnection) open() (err error) { } data := voiceHandshakeOp{0, voiceHandshakeData{v.GuildID, v.UserID, v.sessionID, v.token}} + v.wsMutex.Lock() err = v.wsConn.WriteJSON(data) + v.wsMutex.Unlock() if err != nil { v.log(LogWarning, "error sending init packet, %s", err) return @@ -829,7 +831,12 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct p.SSRC = binary.BigEndian.Uint32(recvbuf[8:12]) // decrypt opus data copy(nonce[:], recvbuf[0:12]) - p.Opus, _ = secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey) + + if opus, ok := secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey); ok { + p.Opus = opus + } else { + return + } // extension bit set, and not a RTCP packet if ((recvbuf[0] & 0x10) == 0x10) && ((recvbuf[1] & 0x80) == 0) { @@ -870,7 +877,11 @@ func (v *VoiceConnection) reconnect() { v.reconnecting = true v.Unlock() - defer func() { v.reconnecting = false }() + defer func() { + v.Lock() + v.reconnecting = false + v.Unlock() + }() // Close any currently open connections v.Close() |