2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 14:15:14 +00:00

Made getLocalIpAddress ignore rmnet-related interfaces.

Any interface with "rmnet" in it is an internal interface that has to do
with the device's cellular connection or USB tethering.  Since those
interfaces might give IPv4 addresses that are unreachable from any other
device, this change makes getLocalIpAddress ignore anything rmnet-related.

BUG: 337685
This commit is contained in:
Nicholas Killewald
2017-05-06 14:26:37 +02:00
committed by Albert Vaca
parent 9d1734406b
commit c5022358de

View File

@@ -144,6 +144,17 @@ class SimpleSftpServer {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
// Anything with rmnet is related to cellular connections or USB
// tethering mechanisms. See:
//
// https://android.googlesource.com/kernel/msm/+/android-msm-flo-3.4-kitkat-mr1/Documentation/usb/gadget_rmnet.txt
//
// If we run across an interface that has this, we can safely
// ignore it. In fact, it's much safer to do. If we don't, we
// might get invalid IP adddresses out of it.
if(intf.getDisplayName().contains("rmnet")) continue;
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {