-
Notifications
You must be signed in to change notification settings - Fork 13
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
Acters
wants to merge
9
commits into
phavekes:main
Choose a base branch
from
Acters:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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
Captures right-click for copying the current viewed IP to the clipboard. cleaned up the code a little.
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This works in GNOME 46.
Made changes to switch from
GLib.spawn_command_line_sync
toGio.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 needtun0
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
andcurl -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.