Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] profile switching (multiple networks) #2401

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

oskardotglobal
Copy link
Contributor

@oskardotglobal oskardotglobal commented Aug 6, 2024

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
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

@oskardotglobal oskardotglobal marked this pull request as draft August 6, 2024 21:13
@oskardotglobal
Copy link
Contributor Author

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

@mlsmaycon
Copy link
Collaborator

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!

@oskardotglobal
Copy link
Contributor Author

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

@salja03-t21
Copy link

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?

Copy link

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

@netandreus
Copy link

Up. There is really needed feature.

@zerobearing2
Copy link

👍

@DevOpsMage
Copy link

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

@oskardotglobal
Copy link
Contributor Author

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

@JonnyBDev
Copy link

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

@mgarces
Copy link
Contributor

mgarces commented Dec 10, 2024

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.

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.

8 participants