netbirdio / netbird

Connect your devices into a secure WireGuard®-based overlay network with SSO, MFA and granular access controls.
https://netbird.io
BSD 3-Clause "New" or "Revised" License
10.78k stars 486 forks source link

Alternative socket address via --daemon-addr or NB_DAEMON_ADDR not always respected #2013

Open oddlama opened 4 months ago

oddlama commented 4 months ago

Describe the problem

When running the netbird ui on an alternative socket (netbird-ui --daemon-addr=unix:///var/run/netbird-home/sock), clicking on "Network Routes" fails because it still tries to connect to the default socket on /var/run/netbird/sock.

image

Weirdly, a similar issue is occurring on the CLI tool and environment variables:

export NB_DAEMON_ADDR=${NB_DAEMON_ADDR-'unix:///var/run/netbird-home/sock'}
export NB_SERVICE=${NB_SERVICE-'netbird-home'}
exec netbird  "$@"

Executing this wrapper (let's call it netbird-home) will work just fine when using e.g. netbird-home up, and the daemon address is correctly used. But executing netbird-home routes list tries to connect to /var/run/netbird/sock and results in:

Error: failed to connect to daemon error: context deadline exceeded
If the daemon is not running please run: 
netbird service install 
netbird service start

Executing netbird-home routes --daemon-addr=unix:///var/run/netbird-home/sock list instead works, so somehow the environment variable seems to not be respected for routes.

To Reproduce

  1. Change the socket address
  2. Set the NB_DAEMON_ADDR environment variable to the new socket and make sure the old one doesn't exist
  3. Execute netbird up (works)
  4. Execute netbird routes list (doesn't work)

Expected behavior

The correct socket should always be used.

Are you using NetBird Cloud?

Self-hosted

NetBird version

0.27.4

NetBird status -d output:

If applicable, add the `netbird status -d' command output.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

pascal-fischer commented 4 months ago

Hi @oddlama, the the routes command is not reading the env variables. This is a bug. We will fix it.