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

[RFC] get ip addresses through connectivity manager, and get gateway ip as well #753

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Grimler91
Copy link
Member

Through connectivity manager we can get both ipv4 and ipv6 addresses, and can drop the use of the deprecated Formatter.formatIpAddress().

With both changes we get something like:

$ termux-wifi-connectioninfo 
{
  "ip": "fe80::7cf7:74ff:fe65:52be",
  "ip": "192.168.1.224",
  "ip": "fd6e:e697:d22e:0:7cf7:74ff:fe65:52be",
  "ip": "fd6e:e697:d22e:0:d536:328f:b0f:1a32",
  "gateway": "192.168.1.1",
  "bssid": "02:00:00:00:00:00",
  "frequency_mhz": 2452,
  "link_speed_mbps": 78,
  "mac_address": "02:00:00:00:00:00",
  "network_id": -1,
  "rssi": -57,
  "ssid": "<unknown ssid>",
  "ssid_hidden": false,
  "supplicant_state": "COMPLETED"
}

Going from just one ip field to several will likely break some user scripts though. Maybe we should keep printing the IPV4 address as "ip" : ... and then all of them as "ip 1" : ..., "ip 2" : ... and so on?

We can then get all the ipv4 and ipv6 addresses, and do not have to
use the deprecated Formatter.formatIpAddress.

Returns something like:
```
$ termux-wifi-connectioninfo
{
  "ip": "fe80::7cf7:74ff:fe65:52be",
  "ip": "192.168.1.224",
  "ip": "fd6e:e697:d22e:0:7cf7:74ff:fe65:52be",
  "ip": "fd6e:e697:d22e:0:d536:328f:b0f:1a32",
  "bssid": "02:00:00:00:00:00",
  "frequency_mhz": 2452,
  "link_speed_mbps": 78,
  "mac_address": "02:00:00:00:00:00",
  "network_id": -1,
  "rssi": -57,
  "ssid": "<unknown ssid>",
  "ssid_hidden": false,
  "supplicant_state": "COMPLETED"
}
```
Getting the gateway address can be useful. One use-case is for easily
ssh'ing into a device providing a hotspot, in which case one should
ssh to the gateway ip.
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.

1 participant