From: Marcus <the...@us...> - 2004-03-22 13:37:27
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16645/plugin/scanner Modified Files: ScannerPlugin.java ScannerConfig.java Log Message: corrected typo Index: ScannerConfig.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ScannerConfig.java 21 Mar 2004 17:29:11 -0000 1.4 --- ScannerConfig.java 22 Mar 2004 13:27:08 -0000 1.5 *************** *** 2,6 **** * juNK - a file search system for smb shares * ! * Copyright 2003 by Marcus Proest (theevilflow at users dot sf dot net) * * This file is part of junk (java useful net kollektor). --- 2,8 ---- * juNK - a file search system for smb shares * ! * Copyright 2004 by ! * Marcus Proest (theevilflow at users dot sf dot net) ! * Uwe van Heesch (tyron_e at users dot sf dot net) * * This file is part of junk (java useful net kollektor). *************** *** 21,26 **** --- 23,31 ---- * */ + package junk.plugin.scanner; + import junk.util.IpSubnet; + import java.io.File; *************** *** 29,34 **** import java.util.Iterator; - import junk.util.IpSubnet; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; --- 34,37 ---- *************** *** 43,84 **** */ public class ScannerConfig { ! /** ! * plugin configuration key defining the sleep time of the scanner thread ! */ protected static final String KEY_THREAD_SLEEP = "thread-sleep"; ! /** plugin configuration key defining the scanning interval */ protected static final String KEY_SCAN_INTERVAL = "scan-interval"; ! /** plugin configuration key defining the ip range */ protected static final String KEY_IP_RANGE = "ip-range"; ! /** plugin configuration key defining the tcp timeout */ protected static final String KEY_TCP_TO = "tcp-timeout"; ! /** plugin configuration key defining the save map path */ protected static final String KEY_SAVE_MAP = "map-save-file"; ! ! /** log writer */ ! private Log log = LogFactory.getLog(ScannerPlugin.class); ! ! /** the time the scannerthread sleeps */ ! private long sleep = 10000; ! ! /** the scanning interval */ ! private long interval = 300000; ! ! /** the tcp timeout */ ! private int tcpTimeout = 100; ! ! /** the path to load and save the hostmap to */ ! private String savemappath = "data/hostmap"; ! /** the ip subnets to scan over */ private ArrayList ipSubnets = null; ! /** initial ipsubnetsString */ private String ipSubnetsString = null; ! /** Creates a new instance of ScannerConfig. * protected standard constructor to prevent instantiation outside --- 46,85 ---- */ public class ScannerConfig { ! /** plugin configuration key defining the sleep time of the scanner thread */ protected static final String KEY_THREAD_SLEEP = "thread-sleep"; ! /** plugin configuration key defining the scanning interval */ protected static final String KEY_SCAN_INTERVAL = "scan-interval"; ! /** plugin configuration key defining the ip range */ protected static final String KEY_IP_RANGE = "ip-range"; ! /** plugin configuration key defining the tcp timeout */ protected static final String KEY_TCP_TO = "tcp-timeout"; ! /** plugin configuration key defining the save map path */ protected static final String KEY_SAVE_MAP = "map-save-file"; ! /** the ip subnets to scan over */ private ArrayList ipSubnets = null; ! ! /** log writer */ ! private Log log = LogFactory.getLog(ScannerPlugin.class); ! /** initial ipsubnetsString */ private String ipSubnetsString = null; ! ! /** the path to load and save the hostmap to */ ! private String savemappath = "data/hostmap"; ! ! /** the tcp timeout */ ! private int tcpTimeout = 100; ! ! /** the scanning interval */ ! private long interval = 300000; ! ! /** the time the scannerthread sleeps */ ! private long sleep = 10000; ! /** Creates a new instance of ScannerConfig. * protected standard constructor to prevent instantiation outside *************** *** 87,91 **** protected ScannerConfig() { } ! /** Creates a new instance of ScannerConfig. * @param m ModuleConfig --- 88,99 ---- protected ScannerConfig() { } ! ! /** To provide a StandAlone config ! * @param h the standalone config ! */ ! protected ScannerConfig(HashMap h) { ! this.applyConfig(h, null); ! } ! /** Creates a new instance of ScannerConfig. * @param m ModuleConfig *************** *** 95,128 **** */ protected ScannerConfig(ActionServlet a, ModuleConfig m) ! throws IllegalArgumentException { HashMap conf = null; PlugInConfig[] pluginConfigs = m.findPlugInConfigs(); ! //get the config... there has to be another way to get it for (int x = 0; x < pluginConfigs.length; x++) { ! if (pluginConfigs[x].getClassName() ! .equals(ScannerPlugin.class.getName())) { conf = (HashMap) pluginConfigs[x].getProperties(); ! break; //leave loop if config found } } ! if (conf == null) { throw new IllegalArgumentException("plugin config not found"); } ! String path = a.getServletContext().getRealPath("/WEB-INF"); ! this.applyConfig(conf, path); } ! ! /** To provide a StandAlone config ! * @param h the standalone config */ ! protected ScannerConfig(HashMap h) { ! this.applyConfig(h, null); } ! /** Apply the config values. * @param conf configuration values --- 103,171 ---- */ protected ScannerConfig(ActionServlet a, ModuleConfig m) ! throws IllegalArgumentException { HashMap conf = null; PlugInConfig[] pluginConfigs = m.findPlugInConfigs(); ! //get the config... there has to be another way to get it for (int x = 0; x < pluginConfigs.length; x++) { ! if (pluginConfigs[x].getClassName().equals(ScannerPlugin.class ! .getName())) { conf = (HashMap) pluginConfigs[x].getProperties(); ! break; //leave loop if config found } } ! if (conf == null) { throw new IllegalArgumentException("plugin config not found"); } ! String path = a.getServletContext().getRealPath("/WEB-INF"); ! this.applyConfig(conf, path); } ! ! /** Returns the interval value. ! * @return returns the interval value */ ! public long getInterval() { ! return this.interval; } ! ! /** Returns the path to the saved hostmap. ! * @return the path to the saved hostmap ! */ ! public String getSaveMapPath() { ! return this.savemappath; ! } ! ! /** Returns the sleep value. ! * @return returns the sleep value ! */ ! public long getSleep() { ! return this.sleep; ! } ! ! /** return the initial ipSubnets String ! * @return initial ipsubnets String ! */ ! public String getSubnets() { ! return this.ipSubnetsString; ! } ! ! /** Returns the tcp timeout value. ! * @return tcp timeout ! */ ! public int getTcpTimeout() { ! return this.tcpTimeout; ! } ! ! /** Returns an iterator over the configured ip subnets. ! * @return an iterator over the configured ip subnets ! */ ! protected Iterator getIpSubnetIterator() { ! return this.ipSubnets.iterator(); ! } ! /** Apply the config values. * @param conf configuration values *************** *** 132,161 **** */ private void applyConfig(HashMap conf, String basepath) ! throws IllegalArgumentException { try { ! this.sleep = Long.parseLong( ! (String) conf.get( ! ScannerConfig.KEY_THREAD_SLEEP)); } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_THREAD_SLEEP ! + " FAILED, defaulting to " + this.sleep, e); } ! try { ! this.interval = Long.parseLong( ! (String) conf.get( ! ScannerConfig.KEY_SCAN_INTERVAL)); } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_SCAN_INTERVAL ! + "FAILED, defaulting to " + this.interval, e); } ! try { String subnetConfigs = (String) conf.get(ScannerConfig.KEY_IP_RANGE); this.ipSubnetsString = subnetConfigs; ! String[] scArray = subnetConfigs.split(","); this.ipSubnets = new ArrayList(scArray.length); ! for (int x = 0; x < scArray.length; x++) { this.ipSubnets.add(x, new IpSubnet(scArray[x])); --- 175,202 ---- */ private void applyConfig(HashMap conf, String basepath) ! throws IllegalArgumentException { try { ! this.sleep = Long.parseLong((String) conf.get( ! ScannerConfig.KEY_THREAD_SLEEP)); } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_THREAD_SLEEP ! + " FAILED, defaulting to " + this.sleep, e); } ! try { ! this.interval = Long.parseLong((String) conf.get( ! ScannerConfig.KEY_SCAN_INTERVAL)); } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_SCAN_INTERVAL ! + "FAILED, defaulting to " + this.interval, e); } ! try { String subnetConfigs = (String) conf.get(ScannerConfig.KEY_IP_RANGE); this.ipSubnetsString = subnetConfigs; ! String[] scArray = subnetConfigs.split(","); this.ipSubnets = new ArrayList(scArray.length); ! for (int x = 0; x < scArray.length; x++) { this.ipSubnets.add(x, new IpSubnet(scArray[x])); *************** *** 164,231 **** //this value cannot be defaulted, so failing ist fatal. throw new IllegalArgumentException("Loading parameter " ! + ScannerConfig.KEY_IP_RANGE ! + " FAILED. (" + e.getMessage() ! + ")"); } ! try { ! this.tcpTimeout = Integer.parseInt( ! (String) conf.get( ! ScannerConfig.KEY_TCP_TO)); } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_TCP_TO ! + " FAILED, defaulting to " + this.tcpTimeout, e); } ! try { String filename = (String) conf.get(ScannerConfig.KEY_SAVE_MAP); this.savemappath = basepath + File.separatorChar + ".." ! + File.separatorChar + filename; } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_SAVE_MAP ! + " FAILED, defaulting to " + this.savemappath, e); } } ! ! /** Returns the sleep value. ! * @return returns the sleep value ! */ ! public long getSleep() { ! return this.sleep; ! } ! ! /** Returns the interval value. ! * @return returns the interval value ! */ ! public long getInterval() { ! return this.interval; ! } ! ! /** Returns the tcp timeout value. ! * @return tcp timeout ! */ ! public int getTcpTimeout() { ! return this.tcpTimeout; ! } ! ! /** Returns an iterator over the configured ip subnets. ! * @return an iterator over the configured ip subnets ! */ ! protected Iterator getIpSubnetIterator() { ! return this.ipSubnets.iterator(); ! } ! ! /** Returns the path to the saved hostmap. ! * @return the path to the saved hostmap ! */ ! public String getSaveMapPath() { ! return this.savemappath; ! } ! ! /** return the initial ipSubnets String ! * @return initial ipsubnets String ! */ ! public String getSubnets() { ! return this.ipSubnetsString; ! } ! } \ No newline at end of file --- 205,228 ---- //this value cannot be defaulted, so failing ist fatal. throw new IllegalArgumentException("Loading parameter " ! + ScannerConfig.KEY_IP_RANGE + " FAILED. (" + e.getMessage() ! + ")"); } ! try { ! this.tcpTimeout = Integer.parseInt((String) conf.get( ! ScannerConfig.KEY_TCP_TO)); } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_TCP_TO ! + " FAILED, defaulting to " + this.tcpTimeout, e); } ! try { String filename = (String) conf.get(ScannerConfig.KEY_SAVE_MAP); this.savemappath = basepath + File.separatorChar + ".." ! + File.separatorChar + filename; } catch (Exception e) { log.warn("Loading parameter " + ScannerConfig.KEY_SAVE_MAP ! + " FAILED, defaulting to " + this.savemappath, e); } } ! } Index: ScannerPlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerPlugin.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScannerPlugin.java 18 Dec 2003 19:17:54 -0000 1.6 --- ScannerPlugin.java 22 Mar 2004 13:27:08 -0000 1.7 *************** *** 2,6 **** * juNK - a file search system for smb shares * ! * Copyright 2003 by Marcus Proest (theevilflow at users dot sf dot net) * * This file is part of junk (java useful net kollektor). --- 2,8 ---- * juNK - a file search system for smb shares * ! * Copyright 2004 by ! * Marcus Proest (theevilflow at users dot sf dot net) ! * Uwe van Heesch (tyron_e at users dot sf dot net) * * This file is part of junk (java useful net kollektor). *************** *** 21,26 **** --- 23,35 ---- * */ + package junk.plugin.scanner; + import jcifs.netbios.NbtAddress; + + import junk.util.HostMap; + import junk.util.IpSubnet; + import junk.util.NameOnline; + import java.io.FileInputStream; import java.io.FileOutputStream; *************** *** 36,45 **** import javax.servlet.ServletException; - import jcifs.netbios.NbtAddress; - - import junk.util.HostMap; - import junk.util.IpSubnet; - import junk.util.NameOnline; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; --- 45,48 ---- *************** *** 53,65 **** * The main plugin class, wich provides a thread to scan the network. * The collected data is saved in the ActionServlets Servlet Context under the ! * key HOSTS_MAP_KEY. * * @author Marcus Proest (theevilflow at users dot sf dot net) */ public class ScannerPlugin implements PlugIn, Runnable { ! /** the key under which the map is stored in the servlet context ! * @deprecated use KEY_HOSTS_MAP ! * @see ScannerPlugin#KEY_HOSTS_MAP ! */ public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; --- 56,65 ---- * The main plugin class, wich provides a thread to scan the network. * The collected data is saved in the ActionServlets Servlet Context under the ! * key KEY_HOSTS_MAP. * * @author Marcus Proest (theevilflow at users dot sf dot net) */ public class ScannerPlugin implements PlugIn, Runnable { ! /** @deprecated use KEY_HOSTS_MAP */ public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; *************** *** 76,112 **** private static final int SMB_PORT = 139; ! /** semaphore */ ! private boolean isScanning = false; ! ! /** wether the thread is running. ! * has to be maintained by the thread itself ! */ ! private boolean isRunning = false; ! /** the scanner configuration options */ ! private ScannerConfig conf = null; /** log writer */ private Log log = LogFactory.getLog(ScannerPlugin.class); /** the scanner thread */ private Thread scanThread = null; ! /** the actionservlet of the struts application */ ! private ActionServlet actionServlet = null; ! /** the hostmap */ ! private HostMap hosts = null; ! /** standalone constructor ! * @param sc scannerconfiguration ! */ ! protected ScannerPlugin(ScannerConfig sc) { ! this.conf = sc; } ! /** empty standard constructor ! */ ! public ScannerPlugin() { } --- 76,124 ---- private static final int SMB_PORT = 139; ! /** the actionservlet of the struts application */ ! private ActionServlet actionServlet = null; ! /** the hostmap */ ! private HostMap hosts = null; /** log writer */ private Log log = LogFactory.getLog(ScannerPlugin.class); + /** the scanner configuration options */ + private ScannerConfig conf = null; + /** the scanner thread */ private Thread scanThread = null; ! /** whether the thread is running. ! * has to be maintained by the thread itself ! */ ! private boolean isRunning = false; ! /** semaphore */ ! private boolean isScanning = false; ! /** empty standard constructor */ ! public ScannerPlugin() { } ! /** destroys the plugin. */ ! public void destroy() { ! this.scanThread = null; //the thread will now terminate ! ! /* the server will continue to shutdown as we leave the destroy ! * method. To ensure that we leave our run method in time, we ! * have to wait until isRunning is false. ! * <br /> ! * I know is is not very stylish, but for now i have no better idea ! */ ! while (this.isRunning) { ! ; ! } ! ! this.saveMap(this.hosts); ! ! log.debug("juNK scanner plugin (" + ScannerPlugin.VERSION ! + ") thread terminated"); } *************** *** 117,121 **** */ public void init(ActionServlet a, ModuleConfig m) ! throws ServletException { this.actionServlet = a; --- 129,133 ---- */ public void init(ActionServlet a, ModuleConfig m) ! throws ServletException { this.actionServlet = a; *************** *** 128,138 **** } ! this.actionServlet.getServletContext() ! .setAttribute(ScannerPlugin.KEY_SCANNER_CONFIG, this.conf); ! //load the persistent map and save it in the context ! this.actionServlet.getServletContext() ! .setAttribute(ScannerPlugin.KEY_HOSTS_MAP, this.loadMap()); //start the real thread --- 140,149 ---- } ! this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_CONFIG, ! this.conf); //load the persistent map and save it in the context ! this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_HOSTS_MAP, ! this.loadMap()); //start the real thread *************** *** 143,167 **** log.info("juNK scanner plugin (" + ScannerPlugin.VERSION ! + ") thread started"); ! } ! ! /** destroys the plugin. */ ! public void destroy() { ! this.scanThread = null; //the thread will now terminate ! ! /* the server will continue to shutdown as we leave the destroy ! * method. To ensure that we leave our run method in time, we ! * have to wait until isRunning is false. ! * <br /> ! * I know is is not very stylish, but for now i have no better idea ! */ ! while (this.isRunning) { ! ; ! } ! ! this.saveMap(this.hosts); ! ! log.debug("juNK scanner plugin (" + ScannerPlugin.VERSION ! + ") thread terminated"); } --- 154,158 ---- log.info("juNK scanner plugin (" + ScannerPlugin.VERSION ! + ") thread started"); } *************** *** 182,186 **** //every 'interval' milliseconds ! if ((System.currentTimeMillis() % (this.conf.getInterval())) <= this.conf.getSleep()) { this.scan(); } --- 173,178 ---- //every 'interval' milliseconds ! if ((System.currentTimeMillis() % (this.conf.getInterval())) <= this.conf ! .getSleep()) { this.scan(); } *************** *** 190,277 **** } ! /** standalone wrapper method ! * @return HostMap containing NameOnline values ! */ ! protected HostMap performScan() { ! this.scan(true); ! ! return this.hosts; ! } ! ! /** same as scan(true) ! * @return see scan(boolean) ! * @see ScannerPlugin#scan(boolean) ! */ ! private synchronized boolean scan() { ! return this.scan(false); ! } ! ! /** scans the net. ! * @return <CODE>true</CODE> if the scan was performed. ! * @param standalone true, if the method is started standalone ! * (out of struts) ! */ ! private synchronized boolean scan(boolean standalone) { ! if (this.isScanning) { ! return false; //semaphore, to be sure ! } ! ! this.isScanning = true; //set the semaphore ! ! //get the old hostmap ! if (!standalone) { //if not standalone get it from struts ! this.hosts = (HostMap) this.actionServlet.getServletContext() ! .getAttribute(ScannerPlugin.HOSTS_MAP_KEY); ! } else { //or, if standalone, apply an empty one ! this.hosts = this.populateMap(); ! } ! ! //get subnet iterator ! Iterator iterator = this.conf.getIpSubnetIterator(); ! ! //iterate over the subnet ! while (iterator.hasNext()) { ! //get an IpSubnet clone ! IpSubnet i = (IpSubnet) ((IpSubnet) iterator.next()).clone(); ! ! long start = System.currentTimeMillis(); //to get a scanningtime ! ! while (i.hasNext()) { ! String ip = (String) i.next(); //get next IP ! ! if (this.isSmb(ip)) { //the host is handled as 'online' ! this.hosts.put(ip, ! new NameOnline(this.getNetBiosName(ip), ! Boolean.TRUE)); ! } else { //the host is handled as 'offline' ! ! //get the old values to preserve the name ! NameOnline no = (NameOnline) hosts.get(ip); ! ! no.setOnline(Boolean.FALSE); //set it offline ! ! this.hosts.put(ip, no); //save it ! ! //maybe the thread wants to terminate while we are in here ! if ((this.scanThread == null) && !standalone) { ! return false; ! } ! } ! } ! ! //calculate scanning time ! long time = System.currentTimeMillis() - start; ! log.info(i.toString() + " scan completed in " + time + " ms"); ! } ! ! //store the results in the context ! if (!standalone) { ! this.actionServlet.getServletContext() ! .setAttribute(ScannerPlugin.HOSTS_MAP_KEY, hosts); ! } ! ! this.isScanning = false; ! ! return true; } --- 182,187 ---- } ! protected void setConf(ScannerConfig conf) { ! this.conf = conf; } *************** *** 310,316 **** try { //try to connect to the smb port ! sock.connect(new InetSocketAddress(ip, ScannerPlugin.SMB_PORT), ! this.conf.getTcpTimeout()); ! //if it worked, close it again --- 220,225 ---- try { //try to connect to the smb port ! sock.connect(new InetSocketAddress(ip, ScannerPlugin.SMB_PORT), ! this.conf.getTcpTimeout()); //if it worked, close it again *************** *** 325,346 **** } - /** serialize the hostmap and save it. - * @param h hostmap to save - */ - private void saveMap(HostMap h) { - String path = this.conf.getSaveMapPath(); - - try { - FileOutputStream f = new FileOutputStream(path); - ObjectOutputStream o = new ObjectOutputStream(f); - o.writeObject(h); - o.close(); - f.close(); - log.info("Hostmap saved (" + path + ")"); - } catch (Exception e) { - log.warn("Could not save hostmap", e); - } - } - /** load an deserialize the hostmap. * @return loaded map --- 234,237 ---- *************** *** 358,362 **** log.info("Loaded persistent data map (" + path + ")"); } catch (Exception e) { ! h = populateMap(); //if there is no data, populate map log.warn("No persistent data map found", e); } --- 249,253 ---- log.info("Loaded persistent data map (" + path + ")"); } catch (Exception e) { ! h = populateMap(); //if there is no data, populate map log.warn("No persistent data map found", e); } *************** *** 366,370 **** /** populates a HostMap with inital NameOnline values. ! * @return a HostMap with inital NameOnlien values */ private HostMap populateMap() { --- 257,261 ---- /** populates a HostMap with inital NameOnline values. ! * @return a HostMap with inital NameOnline values */ private HostMap populateMap() { *************** *** 384,389 **** } ! protected void setConf(ScannerConfig conf) { ! this.conf = conf; } ! } \ No newline at end of file --- 275,356 ---- } ! /** serialize the hostmap and save it. ! * @param h hostmap to save ! */ ! private void saveMap(HostMap h) { ! String path = this.conf.getSaveMapPath(); ! ! try { ! FileOutputStream f = new FileOutputStream(path); ! ObjectOutputStream o = new ObjectOutputStream(f); ! o.writeObject(h); ! o.close(); ! f.close(); ! log.info("Hostmap saved (" + path + ")"); ! } catch (Exception e) { ! log.warn("Could not save hostmap", e); ! } } ! ! /** scans the net. ! * @return <CODE>true</CODE> if the scan was performed. ! * @param standalone true, if the method is started standalone ! * (out of struts) ! */ ! private synchronized boolean scan() { ! if (this.isScanning) { ! return false; //semaphore, to be sure ! } ! ! this.isScanning = true; //set the semaphore ! ! //get the old hostmap ! this.hosts = (HostMap) this.actionServlet.getServletContext() ! .getAttribute(ScannerPlugin.KEY_HOSTS_MAP); ! ! //get subnet iterator ! Iterator iterator = this.conf.getIpSubnetIterator(); ! ! //iterate over the subnet ! while (iterator.hasNext()) { ! //get an IpSubnet clone ! IpSubnet i = (IpSubnet) ((IpSubnet) iterator.next()).clone(); ! ! long start = System.currentTimeMillis(); //to get a scanningtime ! ! while (i.hasNext()) { ! String ip = (String) i.next(); //get next IP ! ! if (this.isSmb(ip)) { //the host is handled as 'online' ! this.hosts.put(ip, ! new NameOnline(this.getNetBiosName(ip), Boolean.TRUE)); ! } else { //the host is handled as 'offline' ! ! //get the old values to preserve the name ! NameOnline no = (NameOnline) hosts.get(ip); ! ! no.setOnline(Boolean.FALSE); //set it offline ! ! this.hosts.put(ip, no); //save it ! ! //maybe the thread wants to terminate while we are in here ! if ((this.scanThread == null)) { ! return false; ! } ! } ! } ! ! //calculate scanning time ! long time = System.currentTimeMillis() - start; ! log.info(i.toString() + " scan completed in " + time + " ms"); ! } ! ! //store the results in the context ! this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_HOSTS_MAP, ! hosts); ! ! this.isScanning = false; ! ! return true; ! } ! } |