mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 19:08:29 +00:00
feat: enhance WebSocket services with HTTP GET handler for certificate confirmation and increase timeout for port forwarding
This commit is contained in:
parent
a18f7800d1
commit
a732c5e08e
6 changed files with 53 additions and 5 deletions
|
|
@ -196,7 +196,7 @@ public class DebugSessionRequestHandler : WebApiBaseRequestHandler
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Information, "No debug websocket connection within 30 seconds; removing port forward for port {0}", port);
|
||||
Debug.LogMessage(LogEventLevel.Information, "No debug websocket connection within timeout; removing port forward for port {0}", port);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -217,7 +217,7 @@ public class DebugSessionRequestHandler : WebApiBaseRequestHandler
|
|||
{
|
||||
Debug.LogMessage(LogEventLevel.Warning, "Error removing port forwarding on timeout: {0}", ex.Message);
|
||||
}
|
||||
}, 30000);
|
||||
}, 120000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ public class RoutingFeedbackSessionRequestHandler : WebApiBaseRequestHandler
|
|||
{
|
||||
Debug.LogMessage(LogEventLevel.Warning, "Error removing port forwarding on timeout: {0}", ex.Message);
|
||||
}
|
||||
}, 30000);
|
||||
}, 120000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ public class RoutingFeedbackWebsocket : IKeyed
|
|||
_httpsServer.SslConfiguration.ClientCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
|
||||
_httpsServer.AddWebSocketService<RoutingFeedbackClient>(_path);
|
||||
_httpsServer.OnGet += HandleHttpGet;
|
||||
_httpsServer.Log.Level = LogLevel.Warn;
|
||||
_httpsServer.Start();
|
||||
|
||||
|
|
@ -338,6 +339,16 @@ public class RoutingFeedbackWebsocket : IKeyed
|
|||
service.Sessions.Broadcast(message);
|
||||
}
|
||||
|
||||
private void HandleHttpGet(object sender, HttpRequestEventArgs e)
|
||||
{
|
||||
var res = e.Response;
|
||||
var body = System.Text.Encoding.UTF8.GetBytes(
|
||||
"<html><body><h2>Certificate accepted.</h2><p>You can close this tab and return to the application.</p></body></html>");
|
||||
res.ContentType = "text/html";
|
||||
res.ContentLength64 = body.Length;
|
||||
res.Close(body, true);
|
||||
}
|
||||
|
||||
private static X509Certificate2 LoadCert(string certPath, string certPassword)
|
||||
{
|
||||
return new X509Certificate2(certPath, certPassword, X509KeyStorageFlags.EphemeralKeySet);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue