File tree Expand file tree Collapse file tree 13 files changed +8
-36
lines changed
library/src/main/java/com/stealthcopter/networktools Expand file tree Collapse file tree 13 files changed +8
-36
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ subprojects {
30
30
ext. targetSdkVer = 29
31
31
ext. supportLibVer = " 27.1.1"
32
32
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 )
34
34
ext. appVersionName = " 0.4.5.2"
35
35
ext. appVersionCode = 20
36
36
}
Original file line number Diff line number Diff line change 7
7
import java .util .HashMap ;
8
8
9
9
/**
10
- * Created by mat on 09/12/15.
11
- *
12
10
* Looks at the file at /proc/net/arp to fromIPAddress ip/mac addresses from the cache
13
11
* We assume that the file has this structure:
14
12
*
Original file line number Diff line number Diff line change 8
8
import java .util .Enumeration ;
9
9
import java .util .regex .Pattern ;
10
10
11
- /**
12
- * Created by mat on 14/12/15.
13
- */
14
11
public class IPTools {
15
12
16
13
/**
Original file line number Diff line number Diff line change 8
8
import java .net .InetAddress ;
9
9
import java .net .UnknownHostException ;
10
10
11
- /**
12
- * Created by mat on 09/12/15.
13
- */
14
11
public class Ping {
15
12
16
13
// Only try ping using the java method
Original file line number Diff line number Diff line change 11
11
import java .util .concurrent .Executors ;
12
12
import java .util .concurrent .TimeUnit ;
13
13
14
- /**
15
- * Created by mat on 14/12/15.
16
- */
17
14
public class PortScan {
18
15
19
16
private static final int TIMEOUT_LOCALHOST = 25 ;
Original file line number Diff line number Diff line change 12
12
import java .util .concurrent .Executors ;
13
13
import java .util .concurrent .TimeUnit ;
14
14
15
- /**
16
- * Created by mat on 03/11/17.
17
- */
18
15
public class SubnetDevices {
19
16
private int noThreads = 100 ;
20
17
@@ -71,15 +68,20 @@ public static SubnetDevices fromIPAddress(final String ipAddress) {
71
68
throw new IllegalArgumentException ("Invalid IP Address" );
72
69
}
73
70
71
+ String segment = ipAddress .substring (0 , ipAddress .lastIndexOf ("." ) + 1 );
72
+
74
73
SubnetDevices subnetDevice = new SubnetDevices ();
75
74
76
75
subnetDevice .addresses = new ArrayList <>();
77
76
78
77
// 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
+ }
80
83
81
84
// Add all missing addresses in subnet
82
- String segment = ipAddress .substring (0 , ipAddress .lastIndexOf ("." ) + 1 );
83
85
for (int j = 0 ; j < 255 ; j ++) {
84
86
if (!subnetDevice .addresses .contains (segment + j )) {
85
87
subnetDevice .addresses .add (segment + j );
Original file line number Diff line number Diff line change 6
6
import java .net .InetAddress ;
7
7
8
8
/**
9
- * Created by mat on 09/12/15.
10
9
*
11
10
* Tested this and it wakes my computer up :)
12
11
*
Original file line number Diff line number Diff line change 7
7
import java .io .InputStreamReader ;
8
8
import java .net .InetAddress ;
9
9
10
- /**
11
- * Created by mat on 09/12/15.
12
- */
13
10
public class PingNative {
14
11
15
12
// This class is not to be instantiated
Original file line number Diff line number Diff line change 2
2
3
3
import java .net .InetAddress ;
4
4
5
- /**
6
- * Created by mat on 09/12/15.
7
- */
8
5
public class PingResult {
9
6
public final InetAddress ia ;
10
7
public boolean isReachable ;
Original file line number Diff line number Diff line change 2
2
3
3
import java .net .InetAddress ;
4
4
5
- /**
6
- * Created by mat on 09/12/15.
7
- */
8
5
public class PingStats {
9
6
private final InetAddress ia ;
10
7
private final long noPings ;
Original file line number Diff line number Diff line change 3
3
import java .io .IOException ;
4
4
import java .net .InetAddress ;
5
5
6
- /**
7
- * Created by mat on 09/12/15.
8
- */
9
6
public class PingTools {
10
7
11
8
// This class is not to be instantiated
Original file line number Diff line number Diff line change 5
5
import java .net .InetSocketAddress ;
6
6
import java .net .Socket ;
7
7
8
- /**
9
- * Created by mat on 13/12/15.
10
- */
11
8
public class PortScanTCP {
12
9
13
10
// This class is not to be instantiated
Original file line number Diff line number Diff line change 5
5
import java .net .InetAddress ;
6
6
import java .net .SocketTimeoutException ;
7
7
8
- /**
9
- * Created by mat on 13/12/15.
10
- */
11
8
public class PortScanUDP {
12
9
13
10
// This class is not to be instantiated
You can’t perform that action at this time.
0 commit comments