mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-07-02 10:38:16 +00:00
fix: improve CS LAN IP handling and update fallback debug session URL in DebugSessionRequestHandler
This commit is contained in:
parent
907eb2f397
commit
782bb6c057
1 changed files with 21 additions and 17 deletions
|
|
@ -58,15 +58,18 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
|
||||||
// Start the WS Server
|
// Start the WS Server
|
||||||
Debug.WebsocketSink.StartServerAndSetPort(port);
|
Debug.WebsocketSink.StartServerAndSetPort(port);
|
||||||
Debug.SetWebSocketMinimumDebugLevel(Serilog.Events.LogEventLevel.Verbose);
|
Debug.SetWebSocketMinimumDebugLevel(Serilog.Events.LogEventLevel.Verbose);
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to forward the port to the CS LAN
|
// Attempt to get the CS LAN IP and forward the port
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
var csAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
|
||||||
|
EthernetAdapterType.EthernetCSAdapter);
|
||||||
|
csIp = CrestronEthernetHelper.GetEthernetParameter(
|
||||||
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId);
|
||||||
|
|
||||||
|
if (port > 0)
|
||||||
{
|
{
|
||||||
var csAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
|
|
||||||
EthernetAdapterType.EthernetCSAdapter);
|
|
||||||
csIp = CrestronEthernetHelper.GetEthernetParameter(
|
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId);
|
|
||||||
|
|
||||||
var result = CrestronEthernetHelper.AddPortForwarding(
|
var result = CrestronEthernetHelper.AddPortForwarding(
|
||||||
(ushort)port, (ushort)port, csIp,
|
(ushort)port, (ushort)port, csIp,
|
||||||
CrestronEthernetHelper.ePortMapTransport.TCP);
|
CrestronEthernetHelper.ePortMapTransport.TCP);
|
||||||
|
|
@ -80,25 +83,26 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Port {0} forwarded to CS LAN for debug websocket", port);
|
Debug.LogMessage(LogEventLevel.Information, "Port {0} forwarded to CS LAN for debug websocket", port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
}
|
||||||
{
|
catch (ArgumentException)
|
||||||
Debug.LogMessage(LogEventLevel.Debug, "This processor does not have a CS LAN adapter; skipping port forwarding");
|
{
|
||||||
}
|
Debug.LogMessage(LogEventLevel.Debug, "This processor does not have a CS LAN adapter; skipping port forwarding");
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
Debug.LogMessage(LogEventLevel.Warning, "Error automatically forwarding debug websocket port to CS LAN: {0}", ex.Message);
|
{
|
||||||
}
|
Debug.LogMessage(LogEventLevel.Warning, "Error automatically forwarding debug websocket port to CS LAN: {0}", ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = Debug.WebsocketSink.Url;
|
var url = Debug.WebsocketSink.Url;
|
||||||
|
|
||||||
object data = new
|
var data = new
|
||||||
{
|
{
|
||||||
url = Debug.WebsocketSink.Url,
|
url = Debug.WebsocketSink.Url,
|
||||||
csLanUrl = csIp != null ? url.Replace(ip, csIp) : null
|
fallbackUrl = csIp != null ? url.Replace(csIp, ip) : null
|
||||||
};
|
};
|
||||||
|
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Debug Session URL: {0}", url);
|
Debug.LogMessage(LogEventLevel.Information, "Debug Session URL: {0}", url);
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Fallback Debug Session URL: {0}", data.fallbackUrl);
|
||||||
|
|
||||||
// Return the port number with the full url of the WS Server
|
// Return the port number with the full url of the WS Server
|
||||||
var res = JsonConvert.SerializeObject(data);
|
var res = JsonConvert.SerializeObject(data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue