From 1a0ea4119e0a3f949745a6d9e5509e3881421f88 Mon Sep 17 00:00:00 2001 From: Austin Noska Date: Mon, 10 Aug 2020 17:24:32 -0400 Subject: [PATCH] feat: Add property to IcdEnvironment to determine if SSL communication is enabled --- CHANGELOG.md | 1 + ICD.Common.Utils/IcdEnvironment.SimplSharp.cs | 33 +++++++++++++++++++ ICD.Common.Utils/IcdEnvironment.Standard.cs | 9 +++++ 3 files changed, 43 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd90838..3cae47f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added Collection extensions for setting and adding ranges of items - Added a method for getting the total number of seconds in a date - Added extensions to raise events with common event args using the data directly + - Added property to IcdEnvironment to determine whether SSL communication is enabled ### Changed - Repeater changed to use configured callbacks instead of a dumb event diff --git a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs index df8795f..3259f2b 100644 --- a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs +++ b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs @@ -128,6 +128,39 @@ namespace ICD.Common.Utils } } + /// + /// Gets the SSL state of the processor. + /// + [PublicAPI] + public static bool SslEnabled + { + get + { + const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param = + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_SSL_OFF_STATUS; + const EthernetAdapterType type = EthernetAdapterType.EthernetLANAdapter; + + try + { + short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type); + if (id >= InitialParametersClass.NumberOfEthernetInterfaces) + return false; + + string status = CrestronEthernetHelper.GetEthernetParameter(param, id); + + if (!string.IsNullOrEmpty(status) && !status.Equals(INVALID_VALUE)) + // GET_SSL_OFF_STATUS return OFF for SSL is Enabled and ON for SSL is disabled + return status == "OFF"; + + return false; + } + catch (ArgumentException) + { + return false; + } + } + } + /// /// Gets the hostname of the processor. /// diff --git a/ICD.Common.Utils/IcdEnvironment.Standard.cs b/ICD.Common.Utils/IcdEnvironment.Standard.cs index c735ca8..fcccc2e 100644 --- a/ICD.Common.Utils/IcdEnvironment.Standard.cs +++ b/ICD.Common.Utils/IcdEnvironment.Standard.cs @@ -73,6 +73,15 @@ namespace ICD.Common.Utils } } + /// + /// Exists for parity with SimplSharp processors which have the ability to enable/disable SSL communication. + /// + [PublicAPI] + public static bool SslEnabled + { + get { return true; } + } + /// /// Gets the hostname of the processor. ///