Update dependencies and copyright year (#2436)

- aiohttp 3.5
- websockets 7
- Rapptz/discord.py@700dbb5
- A few others

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
Toby Harradine
2019-02-13 10:49:11 +11:00
committed by Toby Harradine
parent cfd8ef6025
commit 7c8ac9cd54
52 changed files with 423 additions and 280 deletions

View File

@@ -3,7 +3,7 @@
"""
The MIT License (MIT)
Copyright (c) 2015-2017 Rapptz
Copyright (c) 2015-2019 Rapptz
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -105,6 +105,7 @@ class VoiceClient:
self._connected = threading.Event()
self._handshake_complete = asyncio.Event(loop=self.loop)
self.mode = None
self._connections = 0
self.sequence = 0
self.timestamp = 0
@@ -113,6 +114,7 @@ class VoiceClient:
self.encoder = opus.Encoder()
warn_nacl = not has_nacl
supported_modes = ("xsalsa20_poly1305_suffix", "xsalsa20_poly1305")
@property
def guild(self):
@@ -305,22 +307,30 @@ class VoiceClient:
def _get_voice_packet(self, data):
header = bytearray(12)
nonce = bytearray(24)
box = nacl.secret.SecretBox(bytes(self.secret_key))
# Formulate header
# Formulate rtp header
header[0] = 0x80
header[1] = 0x78
struct.pack_into(">H", header, 2, self.sequence)
struct.pack_into(">I", header, 4, self.timestamp)
struct.pack_into(">I", header, 8, self.ssrc)
# Copy header to nonce's first 12 bytes
encrypt_packet = getattr(self, "_encrypt_" + self.mode)
return encrypt_packet(header, data)
def _encrypt_xsalsa20_poly1305(self, header, data):
box = nacl.secret.SecretBox(bytes(self.secret_key))
nonce = bytearray(24)
nonce[:12] = header
# Encrypt and return the data
return header + box.encrypt(bytes(data), bytes(nonce)).ciphertext
def _encrypt_xsalsa20_poly1305_suffix(self, header, data):
box = nacl.secret.SecretBox(bytes(self.secret_key))
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE)
return header + box.encrypt(bytes(data), nonce).ciphertext + nonce
def play(self, source, *, after=None):
"""Plays an :class:`AudioSource`.