From 299fc001d5985cfceef05af2b11d355ff832f081 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Fri, 27 Apr 2018 15:11:37 +0100 Subject: [PATCH] voice: start using provided IP rather than manually resolving --- krypton | 1 + src/client/voice/VoiceConnection.js | 19 +++++++------------ src/client/voice/networking/VoiceUDPClient.js | 18 ------------------ 3 files changed, 8 insertions(+), 30 deletions(-) create mode 160000 krypton diff --git a/krypton b/krypton new file mode 160000 index 000000000..63551eb93 --- /dev/null +++ b/krypton @@ -0,0 +1 @@ +Subproject commit 63551eb93b19d87b900fb2504a2d911cade19cac diff --git a/src/client/voice/VoiceConnection.js b/src/client/voice/VoiceConnection.js index ac07232ff..d779a7671 100644 --- a/src/client/voice/VoiceConnection.js +++ b/src/client/voice/VoiceConnection.js @@ -252,6 +252,11 @@ class VoiceConnection extends EventEmitter { */ this.emit('failed', new Error(reason)); } else { + /** + * Emitted whenever the connection encounters an error. + * @event VoiceConnection#error + * @param {Error} error The encountered error + */ this.emit('error', new Error(reason)); } this.status = VoiceStatus.DISCONNECTED; @@ -377,20 +382,10 @@ class VoiceConnection extends EventEmitter { * @param {Object} data The received data * @private */ - onReady({ port, ssrc }) { + onReady({ port, ssrc, ip }) { this.authentication.port = port; this.authentication.ssrc = ssrc; - - const udp = this.sockets.udp; - /** - * Emitted whenever the connection encounters an error. - * @event VoiceConnection#error - * @param {Error} error The encountered error - */ - udp.findEndpointAddress() - .then(address => { - udp.createUDPSocket(address); - }, e => this.emit('error', e)); + this.sockets.udp.createUDPSocket(ip); } /** diff --git a/src/client/voice/networking/VoiceUDPClient.js b/src/client/voice/networking/VoiceUDPClient.js index 38dd389f3..418b98cfd 100644 --- a/src/client/voice/networking/VoiceUDPClient.js +++ b/src/client/voice/networking/VoiceUDPClient.js @@ -1,5 +1,4 @@ const udp = require('dgram'); -const dns = require('dns'); const { VoiceOPCodes } = require('../../../util/Constants'); const EventEmitter = require('events'); const { Error } = require('../../../errors'); @@ -66,23 +65,6 @@ class VoiceConnectionUDPClient extends EventEmitter { return this.voiceConnection.authentication.port; } - /** - * Tries to resolve the voice server endpoint to an address. - * @returns {Promise} - */ - findEndpointAddress() { - return new Promise((resolve, reject) => { - dns.lookup(this.voiceConnection.authentication.endpoint, (error, address) => { - if (error) { - reject(error); - return; - } - this.discordAddress = address; - resolve(address); - }); - }); - } - /** * Send a packet to the UDP client. * @param {Object} packet The packet to send