diff --git a/.circleci/key.p12.enc b/.circleci/key.p12.enc
index be3d8cf..ed07f35 100644
Binary files a/.circleci/key.p12.enc and b/.circleci/key.p12.enc differ
diff --git a/.gitignore b/.gitignore
index f88df09..255e0fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@
/captures
TODO
key.p12
+/keystore
diff --git a/app/build.gradle b/app/build.gradle
index 05c5390..11a38af 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -32,8 +32,8 @@ android {
applicationId "com.stealthcotper.networktools"
minSdkVersion minSdkVer
targetSdkVersion targetSdkVer
- versionCode versionName
- versionName versionCode
+ versionName appVersionName
+ versionCode appVersionCode
archivesBaseName = "AndroidNetworkTools"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
diff --git a/build.gradle b/build.gradle
index 92d1190..90c9eb9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -30,6 +30,6 @@ subprojects {
ext.targetSdkVer = 27
ext.supportLibVer = "27.1.1"
- ext.versionName = "0.4.0"
- ext.versionCode = 14
+ ext.appVersionName = "0.4.0"
+ ext.appVersionCode = 14
}
diff --git a/library/build.gradle b/library/build.gradle
index 6715221..e3cfdfd 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -8,5 +8,20 @@ dependencies {
testImplementation 'org.mockito:mockito-core:2.10.0'
}
+task sourcesJar(type: Jar, dependsOn: classes) {
+ classifier = 'sources'
+ from sourceSets.main.allSource
+}
+
+task javadocJar(type: Jar) {
+ classifier = 'javadoc'
+ from javadoc
+}
+
+artifacts {
+ archives sourcesJar
+ archives javadocJar
+}
+
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
\ No newline at end of file
diff --git a/library/src/main/java/com/stealthcopter/networktools/ARPInfo.java b/library/src/main/java/com/stealthcopter/networktools/ARPInfo.java
index 46d4878..2c07a99 100644
--- a/library/src/main/java/com/stealthcopter/networktools/ARPInfo.java
+++ b/library/src/main/java/com/stealthcopter/networktools/ARPInfo.java
@@ -8,10 +8,10 @@
/**
* Created by mat on 09/12/15.
- *
+ *
* Looks at the file at /proc/net/arp to fromIPAddress ip/mac addresses from the cache
* We assume that the file has this structure:
- *
+ *
* IP address HW type Flags HW address Mask Device
* 192.168.18.11 0x1 0x2 00:04:20:06:55:1a * eth0
* 192.168.18.36 0x1 0x2 00:22:43:ab:2a:5b * eth0
diff --git a/library/src/main/java/com/stealthcopter/networktools/Ping.java b/library/src/main/java/com/stealthcopter/networktools/Ping.java
index 2d711bd..304c54e 100644
--- a/library/src/main/java/com/stealthcopter/networktools/Ping.java
+++ b/library/src/main/java/com/stealthcopter/networktools/Ping.java
@@ -154,6 +154,7 @@ public void cancel() {
* request
*
* @return - ping result
+ * @throws UnknownHostException - if the host cannot be resolved
*/
public PingResult doPing() throws UnknownHostException {
cancelled = false;
diff --git a/library/src/main/java/com/stealthcopter/networktools/PortScan.java b/library/src/main/java/com/stealthcopter/networktools/PortScan.java
index e47de2e..ef9f0bc 100644
--- a/library/src/main/java/com/stealthcopter/networktools/PortScan.java
+++ b/library/src/main/java/com/stealthcopter/networktools/PortScan.java
@@ -54,7 +54,7 @@ public interface PortListener {
* @param address - Address to be pinged
* @return this object to allow chaining
* @throws UnknownHostException - if no IP address for the
- * host
could be found, or if a scope_id was specified
+ * {@code host} could be found, or if a scope_id was specified
* for a global IPv6 address.
*/
public static PortScan onAddress(String address) throws UnknownHostException {
diff --git a/library/src/main/java/com/stealthcopter/networktools/SubnetDevices.java b/library/src/main/java/com/stealthcopter/networktools/SubnetDevices.java
index 65dc7d3..f42b9ee 100644
--- a/library/src/main/java/com/stealthcopter/networktools/SubnetDevices.java
+++ b/library/src/main/java/com/stealthcopter/networktools/SubnetDevices.java
@@ -34,6 +34,8 @@ public interface OnSubnetDeviceFound {
/**
* Find devices on the subnet working from the local device ip address
+ *
+ * @return - this for chaining
*/
public static SubnetDevices fromLocalAddress() {
InetAddress ipv4 = IPTools.getLocalIPv4Address();
@@ -47,6 +49,8 @@ public static SubnetDevices fromLocalAddress() {
/**
* @param inetAddress - an ip address in the subnet
+ *
+ * @return - this for chaining
*/
public static SubnetDevices fromIPAddress(InetAddress inetAddress) {
return fromIPAddress(inetAddress.getHostAddress());
@@ -55,6 +59,8 @@ public static SubnetDevices fromIPAddress(InetAddress inetAddress) {
/**
* @param ipAddress - the ipAddress string of any device in the subnet i.e. "192.168.0.1"
* the final part will be ignored
+ *
+ * @return - this for chaining
*/
public static SubnetDevices fromIPAddress(final String ipAddress) {
@@ -84,6 +90,8 @@ public static SubnetDevices fromIPAddress(final String ipAddress) {
/**
* @param ipAddresses - the ipAddresses of devices to be checked
+ *
+ * @return - this for chaining
*/
public static SubnetDevices fromIPList(final List ipAddresses) {
@@ -100,8 +108,10 @@ public static SubnetDevices fromIPList(final List ipAddresses) {
/**
* @param noThreads set the number of threads to work with, note we default to a large number
* as these requests are network heavy not cpu heavy.
- * @return self
- * @throws IllegalAccessException
+ *
+ * @throws IllegalArgumentException - if invalid number of threads requested
+ *
+ * @return - this for chaining
*/
public SubnetDevices setNoThreads(int noThreads) throws IllegalArgumentException {
if (noThreads < 1) throw new IllegalArgumentException("Cannot have less than 1 thread");
@@ -112,9 +122,13 @@ public SubnetDevices setNoThreads(int noThreads) throws IllegalArgumentException
/**
* Sets the timeout for each address we try to ping
*
+ * @param timeOutMillis - timeout in milliseconds for each ping
+ *
* @return this object to allow chaining
+ *
+ * @throws IllegalArgumentException - if timeout is less than zero
*/
- public SubnetDevices setTimeOutMillis(int timeOutMillis) {
+ public SubnetDevices setTimeOutMillis(int timeOutMillis) throws IllegalArgumentException {
if (timeOutMillis < 0) throw new IllegalArgumentException("Timeout cannot be less than 0");
this.timeOutMillis = timeOutMillis;
return this;
diff --git a/library/src/main/java/com/stealthcopter/networktools/WakeOnLan.java b/library/src/main/java/com/stealthcopter/networktools/WakeOnLan.java
index d7ad69f..53adb5f 100644
--- a/library/src/main/java/com/stealthcopter/networktools/WakeOnLan.java
+++ b/library/src/main/java/com/stealthcopter/networktools/WakeOnLan.java
@@ -141,6 +141,8 @@ public void wake() throws IOException {
/**
* Asynchronous call of the wake method. This will be performed on the background thread
* and optionally fire a listener when complete, or when an error occurs
+ *
+ * @param wakeOnLanListener - listener to call on result
*/
public void wake(final WakeOnLanListener wakeOnLanListener) {
@@ -165,6 +167,9 @@ public void run() {
*
* @param ipStr - IP String to send to
* @param macStr - MAC address to wake up
+ *
+ * @throws IllegalArgumentException - invalid ip or mac
+ * @throws IOException - error sending packet
*/
public static void sendWakeOnLan(String ipStr, String macStr) throws IllegalArgumentException, IOException {
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
* @param port - port to send packet to
* @param timeoutMillis - timeout (millis)
* @param packets - number of packets to send
+ *
+ * @throws IllegalArgumentException - invalid ip or mac
+ * @throws IOException - error sending packet
*/
public static void sendWakeOnLan(final String ipStr, final String macStr, final int port, final int timeoutMillis, final int packets) throws IllegalArgumentException, IOException {
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
* @param port - port to send packet to
* @param timeoutMillis - timeout (millis)
* @param packets - number of packets to send
+ *
+ * @throws IllegalArgumentException - invalid ip or mac
+ * @throws IOException - error sending packet
*/
public static void sendWakeOnLan(final InetAddress address, final String macStr, final int port, final int timeoutMillis, final int packets) throws IllegalArgumentException, IOException {
if (address == null) throw new IllegalArgumentException("Address cannot be null");
diff --git a/library/src/main/java/com/stealthcopter/networktools/ping/PingNative.java b/library/src/main/java/com/stealthcopter/networktools/ping/PingNative.java
index ff14754..33daba2 100644
--- a/library/src/main/java/com/stealthcopter/networktools/ping/PingNative.java
+++ b/library/src/main/java/com/stealthcopter/networktools/ping/PingNative.java
@@ -18,6 +18,12 @@ private PingNative() {
public static PingResult ping(InetAddress host, PingOptions pingOptions) throws IOException, InterruptedException {
PingResult pingResult = new PingResult(host);
+
+ if (host == null) {
+ pingResult.isReachable = false;
+ return pingResult;
+ }
+
StringBuilder echo = new StringBuilder();
Runtime runtime = Runtime.getRuntime();
@@ -86,13 +92,15 @@ public static PingResult ping(InetAddress host, PingOptions pingOptions) throws
* # activity_ping 321321.
* activity_ping: unknown host 321321.
*
- * 1. Check if output contains 0% packet loss : Branch to success -> Get stats
- * 2. Check if output contains 100% packet loss : Branch to fail -> No stats
- * 3. Check if output contains 25% packet loss : Branch to partial success -> Get stats
+ * 1. Check if output contains 0% packet loss : Branch to success - Get stats
+ * 2. Check if output contains 100% packet loss : Branch to fail - No stats
+ * 3. Check if output contains 25% packet loss : Branch to partial success - Get stats
* 4. Check if output contains "unknown host"
*
- * @param pingResult
- * @param s
+ * @param pingResult - the current ping result
+ * @param s - result from ping command
+ *
+ * @return The ping result
*/
public static PingResult getPingStats(PingResult pingResult, String s) {
String pingError;
diff --git a/library/src/main/java/com/stealthcopter/networktools/ping/PingTools.java b/library/src/main/java/com/stealthcopter/networktools/ping/PingTools.java
index 0bd13c2..ffce1e7 100644
--- a/library/src/main/java/com/stealthcopter/networktools/ping/PingTools.java
+++ b/library/src/main/java/com/stealthcopter/networktools/ping/PingTools.java
@@ -46,8 +46,8 @@ public static PingResult doPing(InetAddress ia, PingOptions pingOptions) {
* @param ia - address to ping
* @param pingOptions - ping command options
* @return - the ping results
- * @throws IOException
- * @throws InterruptedException
+ * @throws IOException - IO error running ping command
+ * @throws InterruptedException - thread interupt
*/
public static PingResult doNativePing(InetAddress ia, PingOptions pingOptions) throws IOException, InterruptedException {
return PingNative.ping(ia, pingOptions);
@@ -64,6 +64,12 @@ public static PingResult doNativePing(InetAddress ia, PingOptions pingOptions) t
*/
public static PingResult doJavaPing(InetAddress ia, PingOptions pingOptions) {
PingResult pingResult = new PingResult(ia);
+
+ if (ia == null) {
+ pingResult.isReachable = false;
+ return pingResult;
+ }
+
try {
long startTime = System.nanoTime();
final boolean reached = ia.isReachable(null, pingOptions.getTimeToLive(), pingOptions.getTimeoutMillis());
diff --git a/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanTCP.java b/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanTCP.java
index c2537d5..34050b8 100644
--- a/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanTCP.java
+++ b/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanTCP.java
@@ -14,6 +14,14 @@ public class PortScanTCP {
private PortScanTCP() {
}
+ /**
+ * Check if a port is open with TCP
+ *
+ * @param ia - address to scan
+ * @param portNo - port to scan
+ * @param timeoutMillis - timeout
+ * @return - true if port is open, false if not or unknown
+ */
public static boolean scanAddress(InetAddress ia, int portNo, int timeoutMillis) {
Socket s = null;
diff --git a/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanUDP.java b/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanUDP.java
index efd1939..fd58e56 100644
--- a/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanUDP.java
+++ b/library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanUDP.java
@@ -14,6 +14,15 @@ public class PortScanUDP {
private PortScanUDP() {
}
+ /**
+ * Check if a port is open with UDP, note that this isn't reliable
+ * as UDP will does not send ACKs
+ *
+ * @param ia - address to scan
+ * @param portNo - port to scan
+ * @param timeoutMillis - timeout
+ * @return - true if port is open, false if not or unknown
+ */
public static boolean scanAddress(InetAddress ia, int portNo, int timeoutMillis) {
try {
diff --git a/scripts/github-release.sh b/scripts/github-release.sh
index 90ddc51..e1ec1f5 100755
--- a/scripts/github-release.sh
+++ b/scripts/github-release.sh
@@ -16,7 +16,7 @@ GITHUB_UPLOAD_URL="https://uploads.github.com/repos/stealthcopter/AndroidNetwork
function create_github_release {
- version=`cat $1/build.gradle | grep -m 1 versionName | cut -d'"' -f 2`
+ version=$2
echo "Uploading release"
@@ -33,7 +33,7 @@ function create_github_release {
echo "Found id $id"
# Upload apk file
- GITHUB_RELEASE_FILE_PATH="app/build/outputs/apk/release/AndroidNetworkTools.apk"
+ GITHUB_RELEASE_FILE_PATH="app/build/outputs/apk/release/AndroidNetworkTools-release.apk"
GITHUB_RELASE_FILENAME="AndroidNetworkTools.apk"
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
@@ -57,7 +57,7 @@ function create_github_release {
if [[ $GIT_TAG != *"undefined"* ]]; then
echo "Creating github release for tag $GIT_TAG"
- if create_github_release $GITHUB_RELEASE_MODULE; then
+ if create_github_release $GITHUB_RELEASE_MODULE $GIT_TAG; then
webhook $GITHUB_RELEASE_MODULE "$GITHUB_RELEASE_NAME" "Created github release for tag $TAG"
else
webhook $GITHUB_RELEASE_MODULE "$GITHUB_RELEASE_NAME" "Failed to create github release for tag $TAG :("
diff --git a/scripts/upload-apks.sh b/scripts/upload-apks.sh
index 085e4d6..8a6ebb6 100755
--- a/scripts/upload-apks.sh
+++ b/scripts/upload-apks.sh
@@ -22,7 +22,7 @@ function upload_to_beta {
function upload_to_google_play {
echo "Uploading $1 to Google Play"
- if ./gradlew :$1:publishApkRegularRelease ; then
+ if ./gradlew :$1:publishApkRelease ; then
webhook $1 "$APP_RELEASE_NAME" "Uploading to Google Play Succeeded"
else
webhook $1 "$APP_RELEASE_NAME" "Uploading to Google Play FAILED :("
@@ -39,7 +39,7 @@ function upload_to_google_play {
# Print the git commit message
echo "Git commit message: ${GIT_COMMIT_DESC}"
-if [[ $GIT_COMMIT_DESC == *"#DEPLOY"* ]]; then
+if [[ $GIT_COMMIT_DESC == *"#PLAY_BETA"* ]]; then
upload_to_google_play "app"
else
echo "Not publishing to Google Play as deploy not found in commit message"