Update ip discovery to send 74 bytes (#2617)

This commit is contained in:
Kuba_Z2
2023-03-02 20:19:10 +01:00
committed by GitHub
parent abfa8d1751
commit 66e6329b9d
2 changed files with 11 additions and 9 deletions

View File

@@ -306,7 +306,7 @@ namespace Discord.Audio
{
if (_connection.State == ConnectionState.Connecting)
{
if (packet.Length != 70)
if (packet.Length != 74)
{
await _audioLogger.DebugAsync("Malformed Packet").ConfigureAwait(false);
return;
@@ -315,8 +315,8 @@ namespace Discord.Audio
int port;
try
{
ip = Encoding.UTF8.GetString(packet, 4, 70 - 6).TrimEnd('\0');
port = (packet[69] << 8) | packet[68];
ip = Encoding.UTF8.GetString(packet, 8, 74 - 10).TrimEnd('\0');
port = (packet[73] << 8) | packet[72];
}
catch (Exception ex)
{

View File

@@ -228,12 +228,14 @@ namespace Discord.Audio
#region Udp
public async Task SendDiscoveryAsync(uint ssrc)
{
var packet = new byte[70];
packet[0] = (byte)(ssrc >> 24);
packet[1] = (byte)(ssrc >> 16);
packet[2] = (byte)(ssrc >> 8);
packet[3] = (byte)(ssrc >> 0);
await SendAsync(packet, 0, 70).ConfigureAwait(false);
var packet = new byte[74];
packet[1] = 1;
packet[3] = 70;
packet[4] = (byte)(ssrc >> 24);
packet[5] = (byte)(ssrc >> 16);
packet[6] = (byte)(ssrc >> 8);
packet[7] = (byte)(ssrc >> 0);
await SendAsync(packet, 0, 74).ConfigureAwait(false);
await _sentDiscoveryEvent.InvokeAsync().ConfigureAwait(false);
}
public async Task<ulong> SendKeepaliveAsync()