mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-18 22:56:07 +00:00
Automatic Port Selection and Secured Communication (#1038)
Adds dynamic OS-selected socket port handling and secured Electron/.NET communication. The dotnet-first startup flow now generates the auth token on the .NET side and passes it to Electron through an environment variable. Electron reports the selected socket port through a temporary startup-info file, avoiding any dependency on parsing Electron console output. Also avoids logging backend startup parameters because they include the auth token.
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
{
|
||||
private ElectronProcessBase electronProcess;
|
||||
private SocketBridgeService socketBridge;
|
||||
private int? port;
|
||||
|
||||
public RuntimeControllerElectronFirst()
|
||||
{
|
||||
@@ -36,12 +35,8 @@
|
||||
|
||||
protected override Task StartCore()
|
||||
{
|
||||
this.port = ElectronNetRuntime.ElectronSocketPort;
|
||||
|
||||
if (!this.port.HasValue)
|
||||
{
|
||||
throw new Exception("No port has been specified by Electron!");
|
||||
}
|
||||
var port = ElectronNetRuntime.ElectronSocketPort.Value;
|
||||
var token = ElectronNetRuntime.ElectronAuthToken;
|
||||
|
||||
if (!ElectronNetRuntime.ElectronProcessId.HasValue)
|
||||
{
|
||||
@@ -49,7 +44,7 @@
|
||||
}
|
||||
|
||||
this.TransitionState(LifetimeState.Starting);
|
||||
this.socketBridge = new SocketBridgeService(this.port!.Value);
|
||||
this.socketBridge = new SocketBridgeService(port, token);
|
||||
this.socketBridge.Ready += this.SocketBridge_Ready;
|
||||
this.socketBridge.Stopped += this.SocketBridge_Stopped;
|
||||
this.socketBridge.Start();
|
||||
|
||||
Reference in New Issue
Block a user