netbird icon indicating copy to clipboard operation
netbird copied to clipboard

[WIP] profile switching (multiple networks)

Open oskardotglobal opened this issue 1 year ago • 5 comments

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:

  1. Rewrite the config and daemon in large parts to support this
  2. Somehow store the currently used config both in the daemon and client persistently (config for config path, anyone?)
  3. 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

oskardotglobal avatar Aug 06 '24 21:08 oskardotglobal

Never mind, this works; I just had a stale module cache from when I wrote #1161

oskardotglobal avatar Aug 06 '24 21:08 oskardotglobal

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!

mlsmaycon avatar Aug 09 '24 15:08 mlsmaycon

I've gone ahead and sent a message with my ideas in the slack channel

oskardotglobal avatar Aug 09 '24 20:08 oskardotglobal

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!

When are you planning to have this?

salja03-t21 avatar Aug 26 '24 00:08 salja03-t21

Quality Gate Failed 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

sonarqubecloud[bot] avatar Aug 29 '24 13:08 sonarqubecloud[bot]

Up. There is really needed feature.

netandreus avatar Nov 17 '24 18:11 netandreus

:+1:

zerobearing2 avatar Nov 17 '24 19:11 zerobearing2

Also looking forward to this to be included in a future release!

DevOpsMage avatar Nov 18 '24 00:11 DevOpsMage

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

oskardotglobal avatar Nov 18 '24 06:11 oskardotglobal

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. image

JonnyBDev avatar Nov 28 '24 21:11 JonnyBDev

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.

mgarces avatar Dec 10 '24 11:12 mgarces

Hi, I'm also looking forward to this being included in a future release! Do we have an ETA for this release? Thanks

ginsul avatar Jan 16 '25 03:01 ginsul

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

mlsmaycon avatar Feb 03 '25 08:02 mlsmaycon