barista icon indicating copy to clipboard operation
barista copied to clipboard

VPN state always 0

Open leosunmo opened this issue 4 years ago • 4 comments

Thanks for all of your hard work on Barista, love it!

I wanted to display my VPN connectivity status on the bar but it seems tun0's state is always 0, whether it's connected or not. I use openVPN through whatever the default Gnome network manager is.

As far as I can tell it should work fine, using nmcli I get:

$ nmcli c show | grep tun0
tun0                     a4a86581-c0e4-45c2-8c06-be6875710044  tun       tun0

and ifconfig displays what I would expect:

$ fconfig tun0
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet x.x.x.x  netmask 255.255.255.0  destination x.x.x.x

My code looks something like this:

	mod := v.Output(func(state vpn.State) bar.Output {
		s := &pango.Node{}
		switch state {
		case vpn.Connected:
			s = pango.Textf(" %s", "VPN")
		case vpn.Waiting:
			s = pango.Textf(" %s", "...",)
		case vpn.Disconnected:
			s = pango.Textf(" %s", "OFF")
		default:
			return nil
		}

and It'll always display "OFF".

Am I missing something or is there some incompatibility issue?

I'm on Ubuntu 20.04:

Distributor ID:	Ubuntu
Description:	Ubuntu 20.04 LTS
Release:	20.04
Codename:	focal

Linux 5.4.0-31-generic #35-Ubuntu SMP Thu May 7 20:20:34 UTC 2020 x86_64 GNU/Linux

leosunmo avatar May 29 '20 22:05 leosunmo

I think this code is wrong. All VPNs I've seen (OpenVPN and Wireguard) perpetually have "unknown" operstate.

https://github.com/soumya92/barista/blob/e4b58e5439b3da96e53066d717c90d7e818f74e1/modules/vpn/vpn.go#L100-L109

WGH- avatar Jun 04 '20 22:06 WGH-

I think this code is wrong. All VPNs I've seen (OpenVPN and Wireguard) perpetually have "unknown" operstate.

https://github.com/soumya92/barista/blob/e4b58e5439b3da96e53066d717c90d7e818f74e1/modules/vpn/vpn.go#L100-L109

This was my hunch as well, but I didn't have enough time to read through all of the code to be 100% sure.

leosunmo avatar Jun 04 '20 22:06 leosunmo

vpn module would be useful if it could query some extra status via VPN-specific API, but right now it provides even less value than netinfo, since it only reports status, whereas netinfo reports IP addresses.

WGH- avatar Jun 04 '20 22:06 WGH-

FYI, you can view the current operstate with ip link, for example (after state):

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
3: wlp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DORMANT group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX  brd ff:ff:ff:ff:ff:ff
32: foovpn: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 100
    link/ether b6:49:b7:06:a8:6c brd ff:ff:ff:ff:ff:ff

WGH- avatar Jun 06 '20 14:06 WGH-