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

Skip to content

Commit 7514475

Browse files
committed
Added javadoc
1 parent d2cce89 commit 7514475

File tree

11 files changed

+70
-16
lines changed

11 files changed

+70
-16
lines changed

library/build.gradle

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

11+
task javadocJar(type: Jar) {
12+
classifier = 'javadoc'
13+
from javadoc
14+
}
15+
16+
artifacts {
17+
archives javadocJar
18+
}
19+
1120
sourceCompatibility = "1.7"
1221
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
@@ -141,6 +141,7 @@ public void cancel() {
141141
* request
142142
*
143143
* @return - ping result
144+
* @throws UnknownHostException - if the host cannot be resolved
144145
*/
145146
public PingResult doPing() throws UnknownHostException {
146147
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: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ public static PingResult ping(InetAddress host, int timeOutMillis) throws IOExce
8686
* # activity_ping 321321.
8787
* activity_ping: unknown host 321321.
8888
*
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
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
9292
* 4. Check if output contains "unknown host"
9393
*
94-
* @param pingResult
95-
* @param s
94+
* @param pingResult - the current ping result
95+
* @param s - result from ping command
96+
*
97+
* @return The ping result
9698
*/
9799
public static PingResult getPingStats(PingResult pingResult, String s) {
98100
String pingError;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public static PingResult doPing(InetAddress ia, int timeOutMillis) {
4545
* @param ia - address to ping
4646
* @param timeOutMillis - timeout in millisecdonds
4747
* @return - the ping results
48-
* @throws IOException
49-
* @throws InterruptedException
48+
* @throws IOException - IO error running ping command
49+
* @throws InterruptedException - thread interupt
5050
*/
5151
public static PingResult doNativePing(InetAddress ia, int timeOutMillis) throws IOException, InterruptedException {
5252
return PingNative.ping(ia, timeOutMillis);

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 :("

0 commit comments

Comments
 (0)