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

Update to GNOME 46, change to Async, use IP command, dynamically add interfaces, copy to clipboard feature #13

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Acters
Copy link

@Acters Acters commented Aug 22, 2024

This works in GNOME 46.
Made changes to switch from GLib.spawn_command_line_sync to Gio.Subprocess (GLib.spawn_command_line_async is not properly handled in GNOME Shell extensions, so don't bother with that). This should now be resistant to freezing and will silently fail instead. (all errors are caught and logged to console, and status bar will say "None")
It should be possible to introduce dynamically building different interface names and associated IP/IPv6 addresses instead of hard coding the tun0, vpn0, and eth0 interfaces. It is more work than I desire as I am content with knowing vpn IPv4 address.

Will now use IP command to get interface IP addresses instead with hard coded interface names, and updated parsing the output. Again, This is a simple stop-gap for listing IP addresses, there needs to be a more dynamic approach to identifying Interfaces and cycling through the list. Yet, for my use case, I only need tun0 IPv4 address. Hence the rather limited approach.

Fixes #12 and #11
Note: It does not freeze, but will keep the previous displayed label until it is able to decide to show "None" or the newly retrieved info.

Also, changed default to be VPN.

Edit: I've noticed that with my current DNS setup with TLS (DoT), the public IP I receive is of the Cloudflare DNS server. If I use Cloudflare's instead of google, then I receive nothing. However for some reason, IPv6 works fine. I wonder why that is.
So I guess, I will be changing the WAN IPv4 & IPv6 retrieval to be curl -4 icanhazip.com and curl -6 icanhazip.com as it is more reliable at the expense of speed.

I might as well update my repository to completely change the code to be asynchronous and implement the dynamic IP retrieval and switcher.

Edit: I added copy to clipboard feature since IPv6 can be annoying to type.
Also, made some more changes to make it a little clean.
This should be more feature complete and closely resemble what the extension's name is.
I rather not clutter up the GNOME Extension page with more implementations of the same thing. So if you wish to pull this version and host it on the GNOME website, then please do so.

Acters added 4 commits August 21, 2024 22:55
This works in GNOME 46.
Made changes to switch from `GLib.spawn_command_line_sync` to `Gio.Subprocess` because `GLib.spawn_command_line_async` is not properly handled in GNOME Shell extensions. This should now be resistant to freezing and will silently fail instead. (all errors are caught and logged to console, and status bar will say "None" or "Error...")
Will now use `IP` command to get interface addresses instead, and updated parsing the output to match.
The changes are in the core logic of the extension that allows it to dynamically build a list of interfaces with their IPv4 and IPv6 address.
The toggle will now not force update and will only cycle through the list of interfaces.
Switched getting WAN Public IP retrieval to `curl --max-time 5 -4 icanhazip.com` and `curl --max-time 5 -6 icanhazip.com` for IPv4 and IPv6 respectively because certain DNS configurations can prevent identifying the real Public IP address.
There are now extra checks to not display "None" when there is no IPv4 or IPv6 address or the Interface goes offline/disappears. This, also, means that it can now handle interfaces where there is only IPv4 or IPv6.
`selected_interface = ['lo','IPv4'];` is wrong, it should be `selected_interface = ['lo','IPv4Address'];`
add additional check to prevent skipping IPv4 addresses when the previous interface only had IPv4
@Acters Acters changed the title Update to GNOME 46, change to Async, use IP command Update to GNOME 46, change to Async, use IP command, dynamically add interfaces Aug 22, 2024
Acters added 3 commits August 22, 2024 21:35
Captures right-click for copying the current viewed IP to the clipboard.
cleaned up the code a little.
@Acters Acters changed the title Update to GNOME 46, change to Async, use IP command, dynamically add interfaces Update to GNOME 46, change to Async, use IP command, dynamically add interfaces, copy to clipboard feature Aug 23, 2024
Acters added 2 commits August 23, 2024 01:52
Updated Notifications system to reuse the previously displayed Notification and prevent it from hiding until after the user has stopped copying the IP Address.
This is to prevent the corner case where the user accidentally copies an IP Address and decides to quickly toggle to a different IP Address and copy it.
The copying to clipboard would have still worked without this change, but this is a quality of life change so that the user can spam copy the addresses without clogging up the notification channel.
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.

Compatibility for GNOME 46
1 participant