linuxmint / cinnamon-spices-applets

Applets for the Cinnamon desktop
http://cinnamon-spices.linuxmint.com
606 stars 508 forks source link

vnstat@linuxmint.com does not work with VPN #2158

Open NathanSalapat opened 5 years ago

NathanSalapat commented 5 years ago

Applet version: 1.0.2 Cinnamon version 4.0.8 Distribution Mint 19.1

Notify author of applet @pdcurtis

Issue When connected to a VPN output never seems to be updated. It lists tun0 as the active interface but Vnstat reports there is no such database. When running vnstat -i enp3s0 I get the exected output in the terminal showing network traffic. vnstat

Steps to reproduce Connect to a VPN and check the output

Expected behaviour The applet shouldn't try to create a graph from a database that vnstat reports doesn't exist.

Other information I did some digging and found out how to reload the code so I could do some testing. un-commenting the line that prints an error listing the interface reports enp3s0 and tun0. As far as I can tell the _updateDevice function prints the error twice, once with each of the interfaces. I can't figure out why it's reporting both interfaces though.

pdcurtis commented 5 years ago

I think the problems is with vnstat which needs to be set up for every interface that it is building a database for. It is automatically set up for interfaces present when it is installed by Mint. That will not have occurred for VPNs. It is an old program and the addition of interfaces is not trivial, I have done it for Bluetooth and mobile internet dongles. It is documented and man vnstat should provide information but will need some experimenting even if it is possible.

The applet only detects interfaces which are managed by the Network Manager and I would not expect two to show up, in fact I have difficulty seeing how that can happen in a single cycle.

You may want to try my other applet the Network Usage Monitor with alerts as that shows what has been detected and is active using similar code.

I currently do not have access to Linux machine where I can test but I can see you have done a lot of coding so the essential thing is to get vnstat creating a database after which you can fix the device to get vnstati to display the correct interface.

NathanSalapat commented 5 years ago

I've done a manual fix where I commented out the code that detects the interface and assigned the name of my connection to the variable, so it's working.

If it disconnect from the VPN the applet detects just the wired connection, as it should, and everything works correctly then. I think a check to see if vnstat can return a database from the connection could be helpful, but I'm not sure what that would look like in code, or how I'd use that to try the other interface.

pdcurtis commented 5 years ago

@NathanSalapat Would it be useful to VPN users to be able to have two instances of the applet or the matching desklet (which already allows multiple instances) so you can see more than one interface, a manually set one for the VPN tunnel and the automatically detected one covering other traffic? This would be for 'advanced' users as vnstat would still need to be set up for the VPN.