Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 355fa3e

Browse files
Merge pull request stealthcopter#42 from stealthcopter/feature/develop
Feature/develop
2 parents d3d8f3b + 90d766b commit 355fa3e

File tree

16 files changed

+95
-22
lines changed

16 files changed

+95
-22
lines changed

.circleci/key.p12.enc

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
/captures
1111
TODO
1212
key.p12
13+
/keystore

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ android {
3232
applicationId "com.stealthcotper.networktools"
3333
minSdkVersion minSdkVer
3434
targetSdkVersion targetSdkVer
35-
versionCode versionName
36-
versionName versionCode
35+
versionName appVersionName
36+
versionCode appVersionCode
3737
archivesBaseName = "AndroidNetworkTools"
3838
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3939
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ subprojects {
3030
ext.targetSdkVer = 27
3131
ext.supportLibVer = "27.1.1"
3232

33-
ext.versionName = "0.4.0"
34-
ext.versionCode = 14
33+
ext.appVersionName = "0.4.0"
34+
ext.appVersionCode = 14
3535
}

library/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,20 @@ dependencies {
88
testImplementation 'org.mockito:mockito-core:2.10.0'
99
}
1010

11+
task sourcesJar(type: Jar, dependsOn: classes) {
12+
classifier = 'sources'
13+
from sourceSets.main.allSource
14+
}
15+
16+
task javadocJar(type: Jar) {
17+
classifier = 'javadoc'
18+
from javadoc
19+
}
20+
21+
artifacts {
22+
archives sourcesJar
23+
archives javadocJar
24+
}
25+
1126
sourceCompatibility = "1.7"
1227
targetCompatibility = "1.7"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
/**
1010
* Created by mat on 09/12/15.
11-
* <p/>
11+
*
1212
* Looks at the file at /proc/net/arp to fromIPAddress ip/mac addresses from the cache
1313
* We assume that the file has this structure:
14-
* <p/>
14+
*
1515
* IP address HW type Flags HW address Mask Device
1616
* 192.168.18.11 0x1 0x2 00:04:20:06:55:1a * eth0
1717
* 192.168.18.36 0x1 0x2 00:22:43:ab:2a:5b * eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public void cancel() {
154154
* request
155155
*
156156
* @return - ping result
157+
* @throws UnknownHostException - if the host cannot be resolved
157158
*/
158159
public PingResult doPing() throws UnknownHostException {
159160
cancelled = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public interface PortListener {
5454
* @param address - Address to be pinged
5555
* @return this object to allow chaining
5656
* @throws UnknownHostException - if no IP address for the
57-
* <code>host</code> could be found, or if a scope_id was specified
57+
* {@code host} could be found, or if a scope_id was specified
5858
* for a global IPv6 address.
5959
*/
6060
public static PortScan onAddress(String address) throws UnknownHostException {

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public interface OnSubnetDeviceFound {
3434

3535
/**
3636
* Find devices on the subnet working from the local device ip address
37+
*
38+
* @return - this for chaining
3739
*/
3840
public static SubnetDevices fromLocalAddress() {
3941
InetAddress ipv4 = IPTools.getLocalIPv4Address();
@@ -47,6 +49,8 @@ public static SubnetDevices fromLocalAddress() {
4749

4850
/**
4951
* @param inetAddress - an ip address in the subnet
52+
*
53+
* @return - this for chaining
5054
*/
5155
public static SubnetDevices fromIPAddress(InetAddress inetAddress) {
5256
return fromIPAddress(inetAddress.getHostAddress());
@@ -55,6 +59,8 @@ public static SubnetDevices fromIPAddress(InetAddress inetAddress) {
5559
/**
5660
* @param ipAddress - the ipAddress string of any device in the subnet i.e. "192.168.0.1"
5761
* the final part will be ignored
62+
*
63+
* @return - this for chaining
5864
*/
5965
public static SubnetDevices fromIPAddress(final String ipAddress) {
6066

@@ -84,6 +90,8 @@ public static SubnetDevices fromIPAddress(final String ipAddress) {
8490

8591
/**
8692
* @param ipAddresses - the ipAddresses of devices to be checked
93+
*
94+
* @return - this for chaining
8795
*/
8896
public static SubnetDevices fromIPList(final List<String> ipAddresses) {
8997

@@ -100,8 +108,10 @@ public static SubnetDevices fromIPList(final List<String> ipAddresses) {
100108
/**
101109
* @param noThreads set the number of threads to work with, note we default to a large number
102110
* as these requests are network heavy not cpu heavy.
103-
* @return self
104-
* @throws IllegalAccessException
111+
*
112+
* @throws IllegalArgumentException - if invalid number of threads requested
113+
*
114+
* @return - this for chaining
105115
*/
106116
public SubnetDevices setNoThreads(int noThreads) throws IllegalArgumentException {
107117
if (noThreads < 1) throw new IllegalArgumentException("Cannot have less than 1 thread");
@@ -112,9 +122,13 @@ public SubnetDevices setNoThreads(int noThreads) throws IllegalArgumentException
112122
/**
113123
* Sets the timeout for each address we try to ping
114124
*
125+
* @param timeOutMillis - timeout in milliseconds for each ping
126+
*
115127
* @return this object to allow chaining
128+
*
129+
* @throws IllegalArgumentException - if timeout is less than zero
116130
*/
117-
public SubnetDevices setTimeOutMillis(int timeOutMillis) {
131+
public SubnetDevices setTimeOutMillis(int timeOutMillis) throws IllegalArgumentException {
118132
if (timeOutMillis < 0) throw new IllegalArgumentException("Timeout cannot be less than 0");
119133
this.timeOutMillis = timeOutMillis;
120134
return this;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public void wake() throws IOException {
141141
/**
142142
* Asynchronous call of the wake method. This will be performed on the background thread
143143
* and optionally fire a listener when complete, or when an error occurs
144+
*
145+
* @param wakeOnLanListener - listener to call on result
144146
*/
145147
public void wake(final WakeOnLanListener wakeOnLanListener) {
146148

@@ -165,6 +167,9 @@ public void run() {
165167
*
166168
* @param ipStr - IP String to send to
167169
* @param macStr - MAC address to wake up
170+
*
171+
* @throws IllegalArgumentException - invalid ip or mac
172+
* @throws IOException - error sending packet
168173
*/
169174
public static void sendWakeOnLan(String ipStr, String macStr) throws IllegalArgumentException, IOException {
170175
sendWakeOnLan(ipStr, macStr, DEFAULT_PORT, DEFAULT_TIMEOUT_MILLIS, DEFAULT_NO_PACKETS);
@@ -178,6 +183,9 @@ public static void sendWakeOnLan(String ipStr, String macStr) throws IllegalArgu
178183
* @param port - port to send packet to
179184
* @param timeoutMillis - timeout (millis)
180185
* @param packets - number of packets to send
186+
*
187+
* @throws IllegalArgumentException - invalid ip or mac
188+
* @throws IOException - error sending packet
181189
*/
182190
public static void sendWakeOnLan(final String ipStr, final String macStr, final int port, final int timeoutMillis, final int packets) throws IllegalArgumentException, IOException {
183191
if (ipStr == null) throw new IllegalArgumentException("Address cannot be null");
@@ -193,6 +201,9 @@ public static void sendWakeOnLan(final String ipStr, final String macStr, final
193201
* @param port - port to send packet to
194202
* @param timeoutMillis - timeout (millis)
195203
* @param packets - number of packets to send
204+
*
205+
* @throws IllegalArgumentException - invalid ip or mac
206+
* @throws IOException - error sending packet
196207
*/
197208
public static void sendWakeOnLan(final InetAddress address, final String macStr, final int port, final int timeoutMillis, final int packets) throws IllegalArgumentException, IOException {
198209
if (address == null) throw new IllegalArgumentException("Address cannot be null");

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ private PingNative() {
1818

1919
public static PingResult ping(InetAddress host, PingOptions pingOptions) throws IOException, InterruptedException {
2020
PingResult pingResult = new PingResult(host);
21+
22+
if (host == null) {
23+
pingResult.isReachable = false;
24+
return pingResult;
25+
}
26+
2127
StringBuilder echo = new StringBuilder();
2228
Runtime runtime = Runtime.getRuntime();
2329

@@ -86,13 +92,15 @@ public static PingResult ping(InetAddress host, PingOptions pingOptions) throws
8692
* # activity_ping 321321.
8793
* activity_ping: unknown host 321321.
8894
*
89-
* 1. Check if output contains 0% packet loss : Branch to success -> Get stats
90-
* 2. Check if output contains 100% packet loss : Branch to fail -> No stats
91-
* 3. Check if output contains 25% packet loss : Branch to partial success -> Get stats
95+
* 1. Check if output contains 0% packet loss : Branch to success - Get stats
96+
* 2. Check if output contains 100% packet loss : Branch to fail - No stats
97+
* 3. Check if output contains 25% packet loss : Branch to partial success - Get stats
9298
* 4. Check if output contains "unknown host"
9399
*
94-
* @param pingResult
95-
* @param s
100+
* @param pingResult - the current ping result
101+
* @param s - result from ping command
102+
*
103+
* @return The ping result
96104
*/
97105
public static PingResult getPingStats(PingResult pingResult, String s) {
98106
String pingError;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public static PingResult doPing(InetAddress ia, PingOptions pingOptions) {
4646
* @param ia - address to ping
4747
* @param pingOptions - ping command options
4848
* @return - the ping results
49-
* @throws IOException
50-
* @throws InterruptedException
49+
* @throws IOException - IO error running ping command
50+
* @throws InterruptedException - thread interupt
5151
*/
5252
public static PingResult doNativePing(InetAddress ia, PingOptions pingOptions) throws IOException, InterruptedException {
5353
return PingNative.ping(ia, pingOptions);
@@ -64,6 +64,12 @@ public static PingResult doNativePing(InetAddress ia, PingOptions pingOptions) t
6464
*/
6565
public static PingResult doJavaPing(InetAddress ia, PingOptions pingOptions) {
6666
PingResult pingResult = new PingResult(ia);
67+
68+
if (ia == null) {
69+
pingResult.isReachable = false;
70+
return pingResult;
71+
}
72+
6773
try {
6874
long startTime = System.nanoTime();
6975
final boolean reached = ia.isReachable(null, pingOptions.getTimeToLive(), pingOptions.getTimeoutMillis());

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ public class PortScanTCP {
1414
private PortScanTCP() {
1515
}
1616

17+
/**
18+
* Check if a port is open with TCP
19+
*
20+
* @param ia - address to scan
21+
* @param portNo - port to scan
22+
* @param timeoutMillis - timeout
23+
* @return - true if port is open, false if not or unknown
24+
*/
1725
public static boolean scanAddress(InetAddress ia, int portNo, int timeoutMillis) {
1826

1927
Socket s = null;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ public class PortScanUDP {
1414
private PortScanUDP() {
1515
}
1616

17+
/**
18+
* Check if a port is open with UDP, note that this isn't reliable
19+
* as UDP will does not send ACKs
20+
*
21+
* @param ia - address to scan
22+
* @param portNo - port to scan
23+
* @param timeoutMillis - timeout
24+
* @return - true if port is open, false if not or unknown
25+
*/
1726
public static boolean scanAddress(InetAddress ia, int portNo, int timeoutMillis) {
1827

1928
try {

scripts/github-release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ GITHUB_UPLOAD_URL="https://uploads.github.com/repos/stealthcopter/AndroidNetwork
1616

1717
function create_github_release {
1818

19-
version=`cat $1/build.gradle | grep -m 1 versionName | cut -d'"' -f 2`
19+
version=$2
2020

2121
echo "Uploading release"
2222

@@ -33,7 +33,7 @@ function create_github_release {
3333
echo "Found id $id"
3434

3535
# Upload apk file
36-
GITHUB_RELEASE_FILE_PATH="app/build/outputs/apk/release/AndroidNetworkTools.apk"
36+
GITHUB_RELEASE_FILE_PATH="app/build/outputs/apk/release/AndroidNetworkTools-release.apk"
3737
GITHUB_RELASE_FILENAME="AndroidNetworkTools.apk"
3838
curl -H "Content-Type:application/zip" -H "Authorization: token $GITHUB_RELEASE_TOKEN" --data-binary @"$GITHUB_RELEASE_FILE_PATH" $GITHUB_UPLOAD_URL$id/assets?name=$GITHUB_RELASE_FILENAME
3939

@@ -57,7 +57,7 @@ function create_github_release {
5757

5858
if [[ $GIT_TAG != *"undefined"* ]]; then
5959
echo "Creating github release for tag $GIT_TAG"
60-
if create_github_release $GITHUB_RELEASE_MODULE; then
60+
if create_github_release $GITHUB_RELEASE_MODULE $GIT_TAG; then
6161
webhook $GITHUB_RELEASE_MODULE "$GITHUB_RELEASE_NAME" "Created github release for tag $TAG"
6262
else
6363
webhook $GITHUB_RELEASE_MODULE "$GITHUB_RELEASE_NAME" "Failed to create github release for tag $TAG :("

scripts/upload-apks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function upload_to_beta {
2222
function upload_to_google_play {
2323
echo "Uploading $1 to Google Play"
2424

25-
if ./gradlew :$1:publishApkRegularRelease ; then
25+
if ./gradlew :$1:publishApkRelease ; then
2626
webhook $1 "$APP_RELEASE_NAME" "Uploading to Google Play Succeeded"
2727
else
2828
webhook $1 "$APP_RELEASE_NAME" "Uploading to Google Play FAILED :("
@@ -39,7 +39,7 @@ function upload_to_google_play {
3939
# Print the git commit message
4040
echo "Git commit message: ${GIT_COMMIT_DESC}"
4141

42-
if [[ $GIT_COMMIT_DESC == *"#DEPLOY"* ]]; then
42+
if [[ $GIT_COMMIT_DESC == *"#PLAY_BETA"* ]]; then
4343
upload_to_google_play "app"
4444
else
4545
echo "Not publishing to Google Play as deploy not found in commit message"

0 commit comments

Comments
 (0)