mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-13 12:37:07 +00:00
wip: package updates
This commit is contained in:
parent
7bd3ccd54b
commit
4e5b8f3897
8 changed files with 70 additions and 56 deletions
|
|
@ -28,7 +28,7 @@ namespace PepperDash.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DebugWebsocketSink : ILogEventSink
|
public class DebugWebsocketSink : ILogEventSink
|
||||||
{
|
{
|
||||||
private HttpServer _httpsServer;
|
private WebSocketServer _wsServer;
|
||||||
|
|
||||||
private string _path = "/debug/join/";
|
private string _path = "/debug/join/";
|
||||||
private const string _certificateName = "selfCres";
|
private const string _certificateName = "selfCres";
|
||||||
|
|
@ -38,8 +38,8 @@ namespace PepperDash.Core
|
||||||
{ get
|
{ get
|
||||||
{
|
{
|
||||||
|
|
||||||
if(_httpsServer == null) return 0;
|
if(_wsServer == null) return 0;
|
||||||
return _httpsServer.Port;
|
return _wsServer.Port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,15 +47,15 @@ namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_httpsServer == null) return "";
|
if (_wsServer == null) return "";
|
||||||
return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)}:{_httpsServer.Port}{_httpsServer.WebSocketServices[_path].Path}";
|
return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)}:{_wsServer.Port}{_wsServer.WebSocketServices[_path].Path}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the IsRunning
|
/// Gets or sets the IsRunning
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRunning { get => _httpsServer?.IsListening ?? false; }
|
public bool IsRunning { get => _wsServer?.IsListening ?? false; }
|
||||||
|
|
||||||
|
|
||||||
private readonly ITextFormatter _textFormatter;
|
private readonly ITextFormatter _textFormatter;
|
||||||
|
|
@ -118,12 +118,12 @@ namespace PepperDash.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Emit(LogEvent logEvent)
|
public void Emit(LogEvent logEvent)
|
||||||
{
|
{
|
||||||
if (_httpsServer == null || !_httpsServer.IsListening) return;
|
if (_wsServer == null || !_wsServer.IsListening) return;
|
||||||
|
|
||||||
var sw = new StringWriter();
|
var sw = new StringWriter();
|
||||||
_textFormatter.Format(logEvent, sw);
|
_textFormatter.Format(logEvent, sw);
|
||||||
|
|
||||||
_httpsServer.WebSocketServices.Broadcast(sw.ToString());
|
_wsServer.WebSocketServices.Broadcast(sw.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,17 +142,16 @@ namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_httpsServer = new HttpServer(port, true);
|
ServerSslConfiguration sslConfig = null;
|
||||||
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(certPath))
|
if (!string.IsNullOrWhiteSpace(certPath))
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Assigning SSL Configuration");
|
Debug.Console(0, "Assigning SSL Configuration");
|
||||||
_httpsServer.SslConfiguration = new ServerSslConfiguration(new X509Certificate2(certPath, certPassword))
|
sslConfig = new ServerSslConfiguration(new X509Certificate2(certPath, certPassword))
|
||||||
{
|
{
|
||||||
ClientCertificateRequired = false,
|
ClientCertificateRequired = false,
|
||||||
CheckCertificateRevocation = false,
|
CheckCertificateRevocation = false,
|
||||||
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls,
|
EnabledSslProtocols = SslProtocols.Tls12,
|
||||||
//this is just to test, you might want to actually validate
|
//this is just to test, you might want to actually validate
|
||||||
ClientCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
|
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");
|
Debug.Console(0, "Adding Debug Client Service");
|
||||||
_httpsServer.AddWebSocketService<DebugClient>(_path);
|
_wsServer.AddWebSocketService<DebugClient>(_path);
|
||||||
Debug.Console(0, "Assigning Log Info");
|
Debug.Console(0, "Assigning Log Info");
|
||||||
_httpsServer.Log.Level = LogLevel.Trace;
|
_wsServer.Log.Level = LogLevel.Trace;
|
||||||
_httpsServer.Log.Output = (d, s) =>
|
_wsServer.Log.Output = (d, s) =>
|
||||||
{
|
{
|
||||||
uint level;
|
uint level;
|
||||||
|
|
||||||
|
|
@ -198,7 +204,7 @@ namespace PepperDash.Core
|
||||||
};
|
};
|
||||||
Debug.Console(0, "Starting");
|
Debug.Console(0, "Starting");
|
||||||
|
|
||||||
_httpsServer.Start();
|
_wsServer.Start();
|
||||||
Debug.Console(0, "Ready");
|
Debug.Console(0, "Ready");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -213,9 +219,9 @@ namespace PepperDash.Core
|
||||||
public void StopServer()
|
public void StopServer()
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Stopping Websocket Server");
|
Debug.Console(0, "Stopping Websocket Server");
|
||||||
_httpsServer?.Stop();
|
_wsServer?.Stop();
|
||||||
|
|
||||||
_httpsServer = null;
|
_wsServer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<RootNamespace>PepperDash.Core</RootNamespace>
|
<RootNamespace>PepperDash.Core</RootNamespace>
|
||||||
<AssemblyName>PepperDashCore</AssemblyName>
|
<AssemblyName>PepperDashCore</AssemblyName>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net8</TargetFramework>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||||
|
|
@ -42,18 +42,18 @@
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
|
<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.1" />
|
||||||
<PackageReference Include="Crestron.SimplSharp.SDK.Library" Version="2.21.90" />
|
<PackageReference Include="Crestron.SimplSharp.SDK.Library" Version="2.21.128" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4">
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4">
|
||||||
<Aliases>global,NewtonsoftJson</Aliases>
|
<Aliases>global,NewtonsoftJson</Aliases>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
<PackageReference Include="Serilog" Version="4.3.0" />
|
||||||
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
|
<PackageReference Include="Serilog.Expressions" Version="5.0.0" />
|
||||||
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
|
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||||
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
<PackageReference Include="SSH.NET" Version="2025.0.0" />
|
||||||
<PackageReference Include="WebSocketSharp" Version="1.0.3-rc11" />
|
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net6'">
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@
|
||||||
<DocumentationFile>bin\$(Configuration)\PepperDash_Essentials_Core.xml</DocumentationFile>
|
<DocumentationFile>bin\$(Configuration)\PepperDash_Essentials_Core.xml</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />
|
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />
|
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<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>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -33,7 +33,8 @@
|
||||||
<Compile Remove="Messengers\SIMPLVtcMessenger.cs" />
|
<Compile Remove="Messengers\SIMPLVtcMessenger.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PepperDash.Core\PepperDash.Core.csproj" />
|
<ProjectReference Include="..\PepperDash.Core\PepperDash.Core.csproj" />
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@
|
||||||
<Compile Remove="RoomBridges\SourceDeviceMapDictionary.cs" />
|
<Compile Remove="RoomBridges\SourceDeviceMapDictionary.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<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" />
|
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,26 @@
|
||||||
using System;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
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;
|
||||||
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.Core.Web;
|
||||||
using PepperDash.Essentials.RoomBridges;
|
using Crestron.SimplSharp.WebScripting;
|
||||||
using PepperDash.Essentials.WebApiHandlers;
|
using PepperDash.Essentials.WebApiHandlers;
|
||||||
using Serilog.Events;
|
|
||||||
using WebSocketSharp;
|
using WebSocketSharp;
|
||||||
using WebSocketSharp.Net;
|
using WebSocketSharp.Net;
|
||||||
using WebSocketSharp.Server;
|
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
|
namespace PepperDash.Essentials.WebSocketServer
|
||||||
{
|
{
|
||||||
|
|
@ -51,7 +48,7 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||||
private HttpServer _server;
|
private HttpServer _server;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the HttpServer instance
|
/// Gets the WebSocketServer instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HttpServer Server => _server;
|
public HttpServer Server => _server;
|
||||||
|
|
||||||
|
|
@ -269,24 +266,31 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||||
|
|
||||||
_server = new HttpServer(Port, false);
|
_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)
|
if (_parent.Config.DirectServer.Logging.EnableRemoteLogging)
|
||||||
{
|
{
|
||||||
_server.OnPost += Server_OnPost;
|
_server.OnPost += (sender, e) => Server_OnPost(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_parent.Config.DirectServer.Secure)
|
if (_parent.Config.DirectServer.Secure)
|
||||||
{
|
{
|
||||||
this.LogInformation("Adding SSL Configuration to server");
|
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,
|
ClientCertificateRequired = false,
|
||||||
CheckCertificateRevocation = false,
|
CheckCertificateRevocation = false,
|
||||||
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11
|
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_server.SslConfiguration.ServerCertificate = sslConfig.ServerCertificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
_server.Log.Output = (data, message) => Utilities.ConvertWebsocketLog(data, message, this);
|
_server.Log.Output = (data, message) => Utilities.ConvertWebsocketLog(data, message, this);
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.21.90" />
|
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.21.128" />
|
||||||
<PackageReference Include="System.IO.Compression" Version="4.0.0" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PepperDash.Core\PepperDash.Core.csproj" />
|
<ProjectReference Include="..\PepperDash.Core\PepperDash.Core.csproj" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue