wip: package updates

This commit is contained in:
Andrew Welker 2025-07-04 12:15:41 -05:00 committed by Neil Dorin
parent 7bd3ccd54b
commit 4e5b8f3897
8 changed files with 70 additions and 56 deletions

View file

@ -28,7 +28,7 @@ namespace PepperDash.Core
/// </summary>
public class DebugWebsocketSink : ILogEventSink
{
private HttpServer _httpsServer;
private WebSocketServer _wsServer;
private string _path = "/debug/join/";
private const string _certificateName = "selfCres";
@ -38,8 +38,8 @@ namespace PepperDash.Core
{ get
{
if(_httpsServer == null) return 0;
return _httpsServer.Port;
if(_wsServer == null) return 0;
return _wsServer.Port;
}
}
@ -47,15 +47,15 @@ namespace PepperDash.Core
{
get
{
if (_httpsServer == null) return "";
return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)}:{_httpsServer.Port}{_httpsServer.WebSocketServices[_path].Path}";
if (_wsServer == null) return "";
return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)}:{_wsServer.Port}{_wsServer.WebSocketServices[_path].Path}";
}
}
/// <summary>
/// Gets or sets the IsRunning
/// </summary>
public bool IsRunning { get => _httpsServer?.IsListening ?? false; }
public bool IsRunning { get => _wsServer?.IsListening ?? false; }
private readonly ITextFormatter _textFormatter;
@ -118,12 +118,12 @@ namespace PepperDash.Core
/// </summary>
public void Emit(LogEvent logEvent)
{
if (_httpsServer == null || !_httpsServer.IsListening) return;
if (_wsServer == null || !_wsServer.IsListening) return;
var sw = new StringWriter();
_textFormatter.Format(logEvent, sw);
_httpsServer.WebSocketServices.Broadcast(sw.ToString());
_wsServer.WebSocketServices.Broadcast(sw.ToString());
}
@ -142,17 +142,16 @@ namespace PepperDash.Core
{
try
{
_httpsServer = new HttpServer(port, true);
ServerSslConfiguration sslConfig = null;
if (!string.IsNullOrWhiteSpace(certPath))
{
Debug.Console(0, "Assigning SSL Configuration");
_httpsServer.SslConfiguration = new ServerSslConfiguration(new X509Certificate2(certPath, certPassword))
sslConfig = new ServerSslConfiguration(new X509Certificate2(certPath, certPassword))
{
ClientCertificateRequired = false,
CheckCertificateRevocation = false,
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls,
EnabledSslProtocols = SslProtocols.Tls12,
//this is just to test, you might want to actually validate
ClientCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
{
@ -161,11 +160,18 @@ namespace PepperDash.Core
}
};
}
_wsServer = new WebSocketServer(port, true);
if (sslConfig != null)
{
_wsServer.SslConfiguration.ServerCertificate = sslConfig.ServerCertificate;
}
Debug.Console(0, "Adding Debug Client Service");
_httpsServer.AddWebSocketService<DebugClient>(_path);
_wsServer.AddWebSocketService<DebugClient>(_path);
Debug.Console(0, "Assigning Log Info");
_httpsServer.Log.Level = LogLevel.Trace;
_httpsServer.Log.Output = (d, s) =>
_wsServer.Log.Level = LogLevel.Trace;
_wsServer.Log.Output = (d, s) =>
{
uint level;
@ -198,7 +204,7 @@ namespace PepperDash.Core
};
Debug.Console(0, "Starting");
_httpsServer.Start();
_wsServer.Start();
Debug.Console(0, "Ready");
}
catch (Exception ex)
@ -213,9 +219,9 @@ namespace PepperDash.Core
public void StopServer()
{
Debug.Console(0, "Stopping Websocket Server");
_httpsServer?.Stop();
_wsServer?.Stop();
_httpsServer = null;
_wsServer = null;
}
}

View file

@ -5,7 +5,7 @@
<PropertyGroup>
<RootNamespace>PepperDash.Core</RootNamespace>
<AssemblyName>PepperDashCore</AssemblyName>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net8</TargetFramework>
<Deterministic>true</Deterministic>
<NeutralLanguage>en</NeutralLanguage>
<OutputPath>bin\$(Configuration)\</OutputPath>
@ -42,18 +42,18 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="Crestron.SimplSharp.SDK.Library" Version="2.21.90" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.1" />
<PackageReference Include="Crestron.SimplSharp.SDK.Library" Version="2.21.128" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4">
<Aliases>global,NewtonsoftJson</Aliases>
</PackageReference>
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SSH.NET" Version="2024.2.0" />
<PackageReference Include="WebSocketSharp" Version="1.0.3-rc11" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.Expressions" Version="5.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageReference Include="SSH.NET" Version="2025.0.0" />
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6'">
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">

View file

@ -25,7 +25,8 @@
<DocumentationFile>bin\$(Configuration)\PepperDash_Essentials_Core.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" />
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.128" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
<ItemGroup>
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />

View file

@ -29,6 +29,7 @@
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" />
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.128" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
</Project>

View file

@ -33,7 +33,8 @@
<Compile Remove="Messengers\SIMPLVtcMessenger.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" />
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.128" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Core\PepperDash.Core.csproj" />

View file

@ -38,7 +38,8 @@
<Compile Remove="RoomBridges\SourceDeviceMapDictionary.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" />
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.128" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
</ItemGroup>
<ItemGroup>

View file

@ -1,29 +1,26 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Collections.Concurrent;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto.Prng;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System.Collections.Generic;
using System;
using System.Net.Http;
using Crestron.SimplSharp;
using System.Linq;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core.Web;
using PepperDash.Essentials.RoomBridges;
using Crestron.SimplSharp.WebScripting;
using PepperDash.Essentials.WebApiHandlers;
using Serilog.Events;
using WebSocketSharp;
using WebSocketSharp.Net;
using WebSocketSharp.Server;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System.IO;
using Newtonsoft.Json;
using PepperDash.Core;
using Serilog.Events;
using PepperDash.Essentials.RoomBridges;
namespace PepperDash.Essentials.WebSocketServer
{
@ -51,7 +48,7 @@ namespace PepperDash.Essentials.WebSocketServer
private HttpServer _server;
/// <summary>
/// Gets the HttpServer instance
/// Gets the WebSocketServer instance
/// </summary>
public HttpServer Server => _server;
@ -269,24 +266,31 @@ namespace PepperDash.Essentials.WebSocketServer
_server = new HttpServer(Port, false);
_server.OnGet += Server_OnGet;
_server.OnOptions += Server_OnOptions;
_server.OnGet += (sender, e) => Server_OnGet(sender, e);
_server.OnOptions += (sender, e) => Server_OnOptions(sender, e);
if (_parent.Config.DirectServer.Logging.EnableRemoteLogging)
{
_server.OnPost += Server_OnPost;
_server.OnPost += (sender, e) => Server_OnPost(sender, e);
}
if (_parent.Config.DirectServer.Secure)
{
this.LogInformation("Adding SSL Configuration to server");
_server.SslConfiguration = new ServerSslConfiguration(new X509Certificate2($"\\user\\{certificateName}.pfx", certificatePassword))
ServerSslConfiguration sslConfig = null;
sslConfig = new ServerSslConfiguration(new X509Certificate2($"\\user\\{certificateName}.pfx", certificatePassword))
{
ClientCertificateRequired = false,
CheckCertificateRevocation = false,
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11
};
_server.SslConfiguration.ServerCertificate = sslConfig.ServerCertificate;
}
_server.Log.Output = (data, message) => Utilities.ConvertWebsocketLog(data, message, this);

View file

@ -51,8 +51,8 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.21.90" />
<PackageReference Include="System.IO.Compression" Version="4.0.0" />
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.21.128" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Core\PepperDash.Core.csproj" />