aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Carey <[email protected]>2019-12-04 20:37:48 -0500
committerRapptz <[email protected]>2019-12-17 00:11:40 -0500
commitbcbfc354cf7f0aa1c9b61fc29dff6a577fde1a8b (patch)
tree4bddab0f3ca80db3897707d91452d7cfda5d6cd8
parent[commands] Add guild-based permission checks (diff)
downloaddiscord.py-bcbfc354cf7f0aa1c9b61fc29dff6a577fde1a8b.tar.xz
discord.py-bcbfc354cf7f0aa1c9b61fc29dff6a577fde1a8b.zip
Add support for xsalsa20_poly1305_lite
-rw-r--r--discord/voice_client.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/discord/voice_client.py b/discord/voice_client.py
index f3729c9e..801c9900 100644
--- a/discord/voice_client.py
+++ b/discord/voice_client.py
@@ -111,9 +111,11 @@ class VoiceClient:
self._runner = None
self._player = None
self.encoder = None
+ self._lite_nonce = 0
warn_nacl = not has_nacl
supported_modes = (
+ 'xsalsa20_poly1305_lite',
'xsalsa20_poly1305_suffix',
'xsalsa20_poly1305',
)
@@ -331,6 +333,16 @@ class VoiceClient:
return header + box.encrypt(bytes(data), nonce).ciphertext + nonce
+ def _encrypt_xsalsa20_poly1305_lite(self, header, data):
+ box = nacl.secret.SecretBox(bytes(self.secret_key))
+ nonce = bytearray(24)
+
+ nonce[:4] = struct.pack('>I', self._lite_nonce)
+ self.checked_add('_lite_nonce', 1, 4294967295)
+
+ return header + box.encrypt(bytes(data), bytes(nonce)).ciphertext + nonce[:4]
+
+
def play(self, source, *, after=None):
"""Plays an :class:`AudioSource`.