Platform Specific Launcher - ozouai/HostsETC GitHub Wiki
Platform Specific Launcher
The Platform Specific Launcher is a native application built for the intended operating system. It's needed mainly to properly elevate privileges to allow for editing of the host file.
Currently, only the MacOS launcher is available, but more will come soon.
Launching Steps
First the launcher should display a configuration screen, allowing users to make changes to the launch parameters of the server. The list of options and their types are:
- Listen Address [string] (-listen:XXX)
- Listen Port [string] (-port:XXX)
- Restrict Hosts? [boolean] (-restricted?)
These parameters are then mapped into the argument list for the server executable, and launched with administrative permission.
Ensure that you only escalate the privileges when necessary. Best right before the user launches the application.
Next you can start the GUI from the Electron executable. The GUI will also take a port option (-port:XXX) to locate the server on the localhost. Later version will have more features.
Once the server and GUI have started, minimize the application to the tray. The tray menu should have a menu with the following options
- Edit Configuration
- Exit
When Edit Configuration
is pressed, simply display the same configuration window as initial.
When Exit
is pressed, the NodeJS server must be terminated. To do this, either send a termination signal if the process allows, or disconnect the STDOUT. The server executable is configured to automatically exit itself in the event the STDOUT pipe is broken.