Skip to content

Commit 89b2c44

Browse files
committed
Fixed subnet devices returning out of scope IPs and removed pointless comments
1 parent 7cb2a5a commit 89b2c44

File tree

13 files changed

+8
-36
lines changed

13 files changed

+8
-36
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ subprojects {
3030
ext.targetSdkVer = 29
3131
ext.supportLibVer = "27.1.1"
3232

33-
// When updating these, remember to update the vars in app/build.gradle (for FDroid comptability)
33+
// When updating these, remember to update the vars in app/build.gradle (for FDroid compatibility)
3434
ext.appVersionName = "0.4.5.2"
3535
ext.appVersionCode = 20
3636
}

library/src/main/java/com/stealthcopter/networktools/ARPInfo.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.util.HashMap;
88

99
/**
10-
* Created by mat on 09/12/15.
11-
*
1210
* Looks at the file at /proc/net/arp to fromIPAddress ip/mac addresses from the cache
1311
* We assume that the file has this structure:
1412
*

library/src/main/java/com/stealthcopter/networktools/IPTools.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
import java.util.Enumeration;
99
import java.util.regex.Pattern;
1010

11-
/**
12-
* Created by mat on 14/12/15.
13-
*/
1411
public class IPTools {
1512

1613
/**

library/src/main/java/com/stealthcopter/networktools/Ping.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
import java.net.InetAddress;
99
import java.net.UnknownHostException;
1010

11-
/**
12-
* Created by mat on 09/12/15.
13-
*/
1411
public class Ping {
1512

1613
// Only try ping using the java method

library/src/main/java/com/stealthcopter/networktools/PortScan.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
import java.util.concurrent.Executors;
1212
import java.util.concurrent.TimeUnit;
1313

14-
/**
15-
* Created by mat on 14/12/15.
16-
*/
1714
public class PortScan {
1815

1916
private static final int TIMEOUT_LOCALHOST = 25;

library/src/main/java/com/stealthcopter/networktools/SubnetDevices.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import java.util.concurrent.Executors;
1313
import java.util.concurrent.TimeUnit;
1414

15-
/**
16-
* Created by mat on 03/11/17.
17-
*/
1815
public class SubnetDevices {
1916
private int noThreads = 100;
2017

@@ -71,15 +68,20 @@ public static SubnetDevices fromIPAddress(final String ipAddress) {
7168
throw new IllegalArgumentException("Invalid IP Address");
7269
}
7370

71+
String segment = ipAddress.substring(0, ipAddress.lastIndexOf(".") + 1);
72+
7473
SubnetDevices subnetDevice = new SubnetDevices();
7574

7675
subnetDevice.addresses = new ArrayList<>();
7776

7877
// Get addresses from ARP Info first as they are likely to be reachable
79-
subnetDevice.addresses.addAll(ARPInfo.getAllIPAddressesInARPCache());
78+
for(String ip : ARPInfo.getAllIPAddressesInARPCache()) {
79+
if (ip.startsWith(segment)) {
80+
subnetDevice.addresses.add(ip);
81+
}
82+
}
8083

8184
// Add all missing addresses in subnet
82-
String segment = ipAddress.substring(0, ipAddress.lastIndexOf(".") + 1);
8385
for (int j = 0; j < 255; j++) {
8486
if (!subnetDevice.addresses.contains(segment + j)) {
8587
subnetDevice.addresses.add(segment + j);

library/src/main/java/com/stealthcopter/networktools/WakeOnLan.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.net.InetAddress;
77

88
/**
9-
* Created by mat on 09/12/15.
109
*
1110
* Tested this and it wakes my computer up :)
1211
*

library/src/main/java/com/stealthcopter/networktools/ping/PingNative.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import java.io.InputStreamReader;
88
import java.net.InetAddress;
99

10-
/**
11-
* Created by mat on 09/12/15.
12-
*/
1310
public class PingNative {
1411

1512
// This class is not to be instantiated

library/src/main/java/com/stealthcopter/networktools/ping/PingResult.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import java.net.InetAddress;
44

5-
/**
6-
* Created by mat on 09/12/15.
7-
*/
85
public class PingResult {
96
public final InetAddress ia;
107
public boolean isReachable;

library/src/main/java/com/stealthcopter/networktools/ping/PingStats.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import java.net.InetAddress;
44

5-
/**
6-
* Created by mat on 09/12/15.
7-
*/
85
public class PingStats {
96
private final InetAddress ia;
107
private final long noPings;

library/src/main/java/com/stealthcopter/networktools/ping/PingTools.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import java.io.IOException;
44
import java.net.InetAddress;
55

6-
/**
7-
* Created by mat on 09/12/15.
8-
*/
96
public class PingTools {
107

118
// This class is not to be instantiated

library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanTCP.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import java.net.InetSocketAddress;
66
import java.net.Socket;
77

8-
/**
9-
* Created by mat on 13/12/15.
10-
*/
118
public class PortScanTCP {
129

1310
// This class is not to be instantiated

library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanUDP.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import java.net.InetAddress;
66
import java.net.SocketTimeoutException;
77

8-
/**
9-
* Created by mat on 13/12/15.
10-
*/
118
public class PortScanUDP {
129

1310
// This class is not to be instantiated

0 commit comments

Comments
 (0)