[WIP] profile switching (multiple networks)
Describe your changes
This issue attempts to support switching between multiple management servers and/or users ("networks") as described in #446.
I have thought of 3 approaches to implement this:
- Rewrite the config and daemon in large parts to support this
- Somehow store the currently used config both in the daemon and client persistently (config for config path, anyone?)
- Have multiple configs and symlink to /etc/netbird/config.json and restart the daemon after changing configs
For obvious reasons, I decided on approach 3. I'm still currently facing an issue where the service doesn't start on macOS unless I reinstall it, but otherwise this works. A GUI integration is planned, but I won't be writing support for Android / iOS anytime soon.
The usage looks like this:
netbird profiles # list profiles
netbird profile # show current profile
netbird profile <name> # switch to profile <name> (/etc/netbird/profiles/<name>.json)
Issue ticket number and link
#2233 #446 (in parts)
Checklist
- [ ] Is it a bug fix
- [ ] Is a typo/documentation fix
- [x] Is a feature enhancement
- [x] It is a refactor
- [ ] Created tests that fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
Never mind, this works; I just had a stale module cache from when I wrote #1161
Hello @oskardotglobal, thank you for your proposal to add multiple profile switching to Netbird. We appreciate your contribution and wanted to share our vision for this feature.
We’ve been planning to move configuration files to a user-specific path for increased security, especially on shared user computers. With that, profiles would be managed in the following paths:
• Default and setup-key activated profiles: /etc/netbird/profiles/default.json
• User profiles: /home/user/.config/netbird/profiles
When creating a new profile via CLI, it will initially be stored in memory, and once activated, it will be saved to the appropriate directory. For the GUI, since it’s user-bound, we plan to create the profile on disk immediately.
The most recently selected profile will be stored in a state file, allowing the application to reload this profile on system boot or daemon restart.
We envision that profile switching will be simple, with commands to select and activate profiles, but note that switching profiles will disconnect any running processes.
Finally, our GUI will display the current profile and offer easy management options, including creating, selecting, and deleting profiles.
We’d love to discuss this vision with you in more detail. Please join our Slack channel, where we can discuss further this vision.
Looking forward to your thoughts!
I've gone ahead and sent a message with my ideas in the slack channel
Hello @oskardotglobal, thank you for your proposal to add multiple profile switching to Netbird. We appreciate your contribution and wanted to share our vision for this feature.
We’ve been planning to move configuration files to a user-specific path for increased security, especially on shared user computers. With that, profiles would be managed in the following paths:
• Default and setup-key activated profiles: /etc/netbird/profiles/default.json • User profiles: /home/user/.config/netbird/profilesWhen creating a new profile via CLI, it will initially be stored in memory, and once activated, it will be saved to the appropriate directory. For the GUI, since it’s user-bound, we plan to create the profile on disk immediately.
The most recently selected profile will be stored in a state file, allowing the application to reload this profile on system boot or daemon restart.
We envision that profile switching will be simple, with commands to select and activate profiles, but note that switching profiles will disconnect any running processes.
Finally, our GUI will display the current profile and offer easy management options, including creating, selecting, and deleting profiles.
We’d love to discuss this vision with you in more detail. Please join our Slack channel, where we can discuss further this vision.
Looking forward to your thoughts!
When are you planning to have this?
Quality Gate failed
Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)
See analysis details on SonarCloud
Catch issues before they fail your Quality Gate with our IDE extension
SonarLint
Up. There is really needed feature.
:+1:
Also looking forward to this to be included in a future release!
Yeah, sorry, this PR is kind of a mess atm But I have gotten parts of it to work so it is possible this will see the light of day .. some day
The option to choose a instance like Wireguard is doing it would be great. Sorry for the red :D
Just choose which Netbird instance to connect to and let's go.
Hi there, we still don't have this feature; in the meantime, can you test this simple script that allows you to switch between installed NetBird service installs. You can create a service using
sudo netbird service install --service <profile_name> --config /etc/netbird/<profile_name>.json
The script handles multiple "profiles" and also handles the default name for service named netbird which uses the default config file, config.json.
Since you can only be running one service at a time (well, you can but then DNS, routing, etc, will compete), I ended up creating this script to handle the start/stop of each service and to show me which running "profile" is activated. I know it's a temporary solution, but at least will help handle this scenario a bit better until we implement the feature.
Hi, I'm also looking forward to this being included in a future release! Do we have an ETA for this release? Thanks
Thanks, @oskardotglobal, for your effort. I assume you don't have the time to work on it, so I am closing this PR for now. We can keep track on #3273, and with a new PR