Skip to content

Automatic Port Selection and Secured Communication#1038

Open
FlorianRappl wants to merge 7 commits intodevelopfrom
feature/socket-enhancements
Open

Automatic Port Selection and Secured Communication#1038
FlorianRappl wants to merge 7 commits intodevelopfrom
feature/socket-enhancements

Conversation

@FlorianRappl
Copy link
Collaborator

Follow up for #1021 - should be reviewed / merged after #1037.

Introduces an authentication token to be used in the communication between Node.js (Electron) and .NET. The same token can be used to also guard an ASP.NET Core server - allowing only access from within the boundaries of the running application.

The port is now OS-selected - guaranteeing a free accessible port. No tools to find free ports are necessary.

The owning part (e.g., Node.js for the WebSocket connection to control the Electron application) also owns / opens the port - independent of the used startup mode.

@FlorianRappl FlorianRappl added this to the 0.5.0 milestone Mar 5, 2026
@FlorianRappl FlorianRappl changed the base branch from main to develop March 5, 2026 10:57
@FlorianRappl FlorianRappl requested a review from softworkz March 5, 2026 22:21
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

pr-comment: Run #62

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
1400 1238 0 0 0 162 0 4m 8s

🎉 All tests passed!

Github Test Reporter by CTRF 💚

🔄 This comment has been updated

@FlorianRappl
Copy link
Collaborator Author

Should we move this forward @softworkz ?

@softworkz
Copy link
Collaborator

Sorry, haven't come to this yet.

Why is there a merge conflict?

@FlorianRappl
Copy link
Collaborator Author

Sorry, haven't come to this yet.

Why is there a merge conflict?

There is none. There was initially one as planned due to the splitting.

@softworkz
Copy link
Collaborator

image image

@FlorianRappl
Copy link
Collaborator Author

FlorianRappl commented Mar 15, 2026

Shows different for me:

image

Also:

image

Furthermore:

$> git pull origin develop
From https://github.com/ElectronNET/Electron.NET
 * branch            develop    -> FETCH_HEAD
Already up to date.
$> git push origin feature/socket-enhancements
Everything up-to-date

Copy link
Collaborator

@softworkz softworkz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very sorry for responding so late!

Comment on lines +163 to +167
var tcs = new TaskCompletionSource();

void Read_SocketIO_Parameters(object sender, string line)
{
await Task.Delay(10.ms()).ConfigureAwait(false);
// Look for "Electron Socket: listening on port %s at ..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a path completely without reading the process output.
(without auth token)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not do that. It's less secure and just more complicated. Let's keep it to the point.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not want to have that in our application that dotnet is relying on the console output of Electron.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have nothing against making the auth token mandatory, but it can be provided by the dotnet side as cli param, so it doesn't need to be read it from the console output. (that's no more and no less secure)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically possible, but that's another branch / logic that we would need to take care of. So I'd opt out of that.

Copy link
Collaborator

@softworkz softworkz Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just a thought. My only actual concern is the console parsing. That's admittedly a rather egoistic concern. I do not mean to say that parsing CLI output is generally wrong or bad, it's about the specific context of our app: Linux is a world of 1001 surprises, often bad surprises and I don't want to employ anything which has potential for causing bad surprises - that's why I would like to retain a path where this doesn't happen.

Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah can relate to that... My suggestion would be to have it merged / out in a preview version and test it extensively. If that does not hold / has weak points then I think a different approach must be anyway found (because I would still insist that a single flow is better than multiple - but that single flow has to work in all cases).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is this: as soon as this is merged, there is no more point for me to submit any fixes and updates, because I cannot use the packages anymore.

Beyond my own usage, introducing something new in a way that it's optional, is generally advantageous:

  • Nobody's story will be hard broken or blocked
  • It's useful for differential diagnosis when issues are reported, to determine whether it's by the new code or due to other reasons
  • It would make me very happy 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants