Vitals icon indicating copy to clipboard operation
Vitals copied to clipboard

Added: Private IP

Open al26p opened this issue 1 year ago • 3 comments

Hi !

A quick approach to retrieve local IP from ip route using GLib.

Should answers to #254

al26p avatar Apr 25 '23 19:04 al26p

I appreciate this PR. Is there a way to pull this data from a file in /proc or /sys? Shelling to disk will cause lag in the system (such as when scrolling bodies of text, etc). A group of individuals is working on Nvidia GPU support which shells to disk (only way). If shelling is the only way, we'll likely have to combine this code into a separate branch with the Nvidia code and add an alert that tells the user to expect lags - otherwise I'll get a flood of bug reports about lagging

corecoding avatar May 10 '23 13:05 corecoding

You can find the IPs of current NICs in /proc/net/fib_trie. Parsing might be a little tricky, searching for something like "/32 host LOCAL" should do the trick for IPv4.

CheariX avatar Jul 14 '23 07:07 CheariX

Hello,

Right now I am using gnome-extension-lan-ip-address to 'pin' my local IP. On the one hand I like that there is no icon next to it, but on the other, I would rather have it included in vitals. (Thank you for this extension btw.) The other extension uses ip route get 1.1.1.1 to see which ip is used to access the internet.

This comment suggests an easy way to parse /proc/net/fib_trie. I have written the function to do it and I would like to make my first contribution to a Gnome extension. I would like to have your thoughts on a problem I'm having. In the case where there are multiple IP addresses due to being connected to a VPN client or are using both WIFI and ethernet, how could we differentiate the IPs?

Example: (If you see at the bottom of the comment, I have pasted my fib_trie with and without a VPN connection.)

When I am on my laptop, 99% of the time I have the 192.168.1.118 address, and that's what I want to be displayed on the top panel. However, when I connect to a VPN, I want that address to change to the one the VPN gives me (or cycle them).

We could display all of them in the drop down menu, but what about pinning? We can't pin all of them because it would take up too much space. Do we pin "LAN Address" and cycle through them (except '127.0.0.1') every few seconds? I fear it would bring in bug reports from people thinking that their IP changes every "X" seconds. Can we disable pinning "LAN Address"? Pinning one of them would be weird, because the whole point of pinning your ip adress is to see which one is active.

I think a hybrid solution would be best. Use the same implementation as lan-ip-address as an opt-in metric, "Active LAN IP". It won't add unnecessary pings when it's disabled, yet it would integrate one more data point and a whole extra extension for users. On top of that, add a "LAN Address" list created from /proc/net/fib_trie and either disable pinning or cycle through them every few seconds. Not many people use VPNs or multiple NIC's, so for most of the user-base this implementation will be all they need.

I wish someone comes up with a better idea.

Without VPN

Local:
  +-- 0.0.0.0/0 3 0 5
     |-- 0.0.0.0
        /0 universe UNICAST
     +-- 127.0.0.0/8 2 0 2
        +-- 127.0.0.0/31 1 0 0
           |-- 127.0.0.0
              /8 host LOCAL
           |-- 127.0.0.1
              /32 host LOCAL
        |-- 127.255.255.255
           /32 link BROADCAST
     +-- 192.168.1.0/24 2 0 1
        |-- 192.168.1.0
           /24 link UNICAST
        |-- 192.168.1.118
           /32 host LOCAL
        |-- 192.168.1.255
           /32 link BROADCAST
With VPN

Local:
  +-- 0.0.0.0/0 3 0 4
     |-- 0.0.0.0
        /0 universe UNICAST
        /0 universe UNICAST
     +-- 127.0.0.0/8 2 0 2
        +-- 127.0.0.0/31 1 0 0
           |-- 127.0.0.0
              /8 host LOCAL
           |-- 127.0.0.1
              /32 host LOCAL
        |-- 127.255.255.255
           /32 link BROADCAST
     +-- 172.39.0.0/18 2 0 2
        |-- 172.39.0.1
           /32 universe UNICAST
        +-- 172.39.47.92/30 2 0 2
           |-- 172.39.47.93
              /32 link UNICAST
           |-- 172.39.47.94
              /32 host LOCAL
     +-- 192.0.0.0/6 2 0 2
        +-- 192.168.1.0/24 2 0 1
           +-- 192.168.1.0/31 1 0 0
              |-- 192.168.1.0
                 /24 link UNICAST
              |-- 192.168.1.1
                 /32 link UNICAST
           |-- 192.168.1.118
              /32 host LOCAL
           |-- 192.168.1.255
              /32 link BROADCAST
        |-- 195.251.255.75
           /32 universe UNICAST

ispanos avatar Sep 14 '23 16:09 ispanos