From e2b655a93949ec8a66c512db47617400b036c428 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 14 Aug 2024 13:28:33 +0100 Subject: [PATCH] verify vivox requests --- .../FreeSwitchVoice/FreeSwitchVoiceModule.cs | 24 ++++++++++++++++--- .../Voice/VivoxVoice/VivoxVoiceModule.cs | 19 +++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 4b1142820f..ba442275b0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice //private static readonly string m_chatSessionRequestPath = "0209/"; // Control info - private static bool m_Enabled = false; + private static bool m_Enabled = false; // FreeSwitch server is going to contact us and ask us all // sorts of things. @@ -111,8 +111,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice try { - string serviceDll = m_Config.GetString("LocalServiceModule", - String.Empty); + string serviceDll = m_Config.GetString("LocalServiceModule", String.Empty); if (serviceDll.Length == 0) { @@ -325,6 +324,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.DebugFormat( "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request for {0}", agentID.ToString()); + Stream inputStream = request.InputStream; + if (inputStream.Length > 0) + { + OSD tmp = OSDParser.DeserializeLLSDXml(inputStream); + request.InputStream.Dispose(); + + if (tmp is OSDMap map) + { + if (map.TryGetValue("voice_server_type", out OSD vstosd)) + { + if (vstosd is OSDString vst && !((string)vst).Equals("vivox", StringComparison.OrdinalIgnoreCase)) + { + response.RawBuffer = Util.UTF8.GetBytes(""); + return; + } + } + } + } + response.StatusCode = (int)HttpStatusCode.OK; ScenePresence avatar = scene.GetScenePresence(agentID); diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index e9ccaa50d8..258db57118 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -459,6 +459,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice response.StatusCode = (int)HttpStatusCode.OK; try { + Stream inputStream = request.InputStream; + if (inputStream.Length > 0) + { + OSD tmp = OSDParser.DeserializeLLSDXml(inputStream); + request.InputStream.Dispose(); + + if (tmp is OSDMap map) + { + if (map.TryGetValue("voice_server_type", out OSD vstosd)) + { + if (vstosd is OSDString vst && !((string)vst).Equals("vivox", StringComparison.OrdinalIgnoreCase)) + { + response.RawBuffer = Util.UTF8.GetBytes(""); + return; + } + } + } + } + ScenePresence avatar = null; string avatarName = null;