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

Subnet is returned as 255.255.255.255 instead of 255.255.255.0 #633

Closed
C-Otto opened this issue Oct 25, 2022 · 6 comments · Fixed by #634
Closed

Subnet is returned as 255.255.255.255 instead of 255.255.255.0 #633

C-Otto opened this issue Oct 25, 2022 · 6 comments · Fixed by #634
Labels
bug Something isn't working released

Comments

@C-Otto
Copy link
Contributor

C-Otto commented Oct 25, 2022

Environment

System:
    OS: Linux 5.18 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600K
    Memory: 13.71 GB / 31.11 GB
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.18.0 - /usr/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.19.2 - /usr/bin/npm
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 17.0.4 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.67.4 => 0.67.4 
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

Android 11

Versions

  • Android: 11 (8901.4.A.0017.3 release-keys)
  • react-native-netinfo: 9.3.4
  • react-native: 0.67.4
  • react: 17.0.2

Description

On my Android 11 device (Fairphone 3+) running NetInfo.fetch gives correct information, aside from subnet:

[{"details":{"isConnectionExpensive":false,"txLinkSpeed":57,"rxLinkSpeed":-1,"linkSpeed":57,"subnet":"255.255.255.255","ipAddress":"10.0.0.133","frequency":2462,"strength":72,"bssid":"xxx","ssid":"xxx"},"isConnected":true,"type":"wifi","isInternetReachable":true,"isWifiEnabled":true}]

The correct network information would be 10.0.0.133/24, i.e. a subnet of 255.255.255.0. On my desktop machine (in the same network) I see

inet 10.0.0.2/24 brd 10.0.0.255 scope global dynamic noprefixroute eno1
       valid_lft 860383sec preferred_lft 860383sec

When checking the network details manully (long-pressing on the Wifi icon) I also get a subnet mask of 255.255.255.0.

@C-Otto C-Otto added the bug Something isn't working label Oct 25, 2022
@C-Otto
Copy link
Contributor Author

C-Otto commented Oct 25, 2022

Same issue with 9.3.5, react-native 0.68.4.

@mikehardy
Copy link
Contributor

Very odd - haven't seen this before - next step will be do instrument the java code where we pull the info from the device and see what the system APIs are returning, then dig in from there. Curious for results 🤔

@C-Otto
Copy link
Contributor Author

C-Otto commented Oct 25, 2022

I added some debug code:

String debug = String.format("%s %s %s %d", netAddress, netAddress.getInterfaceAddresses(), netAddress.getInterfaceAddresses().get(1), netAddress.getInterfaceAddresses().get(1).getNetworkPrefixLength());

This gives:

name:wlan0 (wlan0) [/fe80::e0d0:cfff:fe98:54f4%wlan0/64 [null], /2a0a:a540:4ee9:0:e0d0:cfff:fe98:54f4/64 [null], /2a0a:a540:4ee9:0:5cbd:e442:6b8c:e03/64 [null], /10.0.0.133/24 [/10.0.0.255]] /2a0a:a540:4ee9:0:e0d0:cfff:fe98:54f4/64 [null] 64]]

I guess your code doesn't like IPv6?

@mikehardy
Copy link
Contributor

I guess your code doesn't like IPv6?

It's open source, it's your code 😆

If there's something that needs to change I'm open to any+all reasonable PRs

This module existed long before I had heard of react-native, and it'll be here long after I've stopped hitting the "merge" button, I imagine you are correct and it's just IPv4-only at the moment, or incorrectly-IPv6

@mikehardy
Copy link
Contributor

You win the internet points for the day for nailing this with what appears to be a squeaky clean PR. Chapeau

github-actions bot pushed a commit that referenced this issue Oct 26, 2022
## [9.3.6](v9.3.5...v9.3.6) (2022-10-26)

### Bug Fixes

* **android:** return netmask of first IPv4 address ([#634](#634)) ([f740f45](f740f45)), closes [#633](#633)
@matt-oakes
Copy link
Collaborator

🎉 This issue has been resolved in version 9.3.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants