2121import com .stealthcopter .networktools .WakeOnLan ;
2222import com .stealthcopter .networktools .ping .PingResult ;
2323import com .stealthcopter .networktools .ping .PingStats ;
24- import com .stealthcopter .networktools .subnet .SubnetDevice ;
24+ import com .stealthcopter .networktools .subnet .Device ;
2525
2626import java .io .IOException ;
2727import java .net .InetAddress ;
@@ -44,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
4444
4545 InetAddress ipAddress = IPTools .getLocalIPv4Address ();
4646 if (ipAddress != null ){
47- editIpAddress .setText (ipAddress .toString ());
47+ editIpAddress .setText (ipAddress .getHostAddress ());
4848 }
4949
5050 findViewById (R .id .pingButton ).setOnClickListener (new View .OnClickListener () {
@@ -198,8 +198,10 @@ private void doPortScan() throws Exception {
198198 appendResultsText ("PortScanning IP: " + ipAddress );
199199 ArrayList <Integer > openPorts = PortScan .onAddress (ipAddress ).setPort (21 ).doScan ();
200200
201+ final long startTimeMillis = System .currentTimeMillis ();
202+
201203 // Perform an asynchronous port scan
202- PortScan .onAddress (ipAddress ).setTimeOutMillis ( 1000 ). setPortsAll ().doScan (new PortScan .PortListener () {
204+ PortScan .onAddress (ipAddress ).setPortsAll ().doScan (new PortScan .PortListener () {
203205 @ Override
204206 public void onResult (int portNo , boolean open ) {
205207 if (open ) appendResultsText ("Open: " + portNo );
@@ -208,6 +210,7 @@ public void onResult(int portNo, boolean open) {
208210 @ Override
209211 public void onFinished (ArrayList <Integer > openPorts ) {
210212 appendResultsText ("Open Ports: " + openPorts .size ());
213+ appendResultsText ("Time Taken: " + ((System .currentTimeMillis () - startTimeMillis )/1000.0f ));
211214 }
212215 });
213216
@@ -218,17 +221,16 @@ private void findSubnetDevices() {
218221
219222 final long startTimeMillis = System .currentTimeMillis ();
220223
221- String partialIpAddress = editIpAddress .getText ().toString ();
222-
223224 SubnetDevices .fromLocalAddress ().findDevices (new SubnetDevices .OnSubnetDeviceFound () {
224225 @ Override
225- public void onDeviceFound (SubnetDevice subnetDevice ) {
226- appendResultsText ("Device: " + subnetDevice .ip +" " + subnetDevice .hostname );
226+ public void onDeviceFound (Device device ) {
227+ appendResultsText ("Device: " + device .ip +" " + device .hostname );
227228 }
228229
229230 @ Override
230- public void onFinished (ArrayList <SubnetDevice > devicesFound ) {
231+ public void onFinished (ArrayList <Device > devicesFound ) {
231232 float timeTaken = (System .currentTimeMillis () - startTimeMillis )/1000.0f ;
233+ appendResultsText ("Devices Found: " + devicesFound .size ());
232234 appendResultsText ("Finished " +timeTaken +" s" );
233235 }
234236 });
0 commit comments