You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(25) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
(1) |
Mar
(61) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Marcus <the...@us...> - 2004-03-31 08:45:02
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/controller In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13778 Modified Files: ConfigurationAction.java Log Message: deactivated temporary for security reasons Index: ConfigurationAction.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/controller/ConfigurationAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConfigurationAction.java 26 Mar 2004 19:01:51 -0000 1.1 --- ConfigurationAction.java 31 Mar 2004 08:33:16 -0000 1.2 *************** *** 71,74 **** --- 71,75 ---- /** * Action to handle the configuration dialog + *@todo replace the crimson part by Xerces/Xalan */ public class ConfigurationAction extends Action { *************** *** 133,136 **** --- 134,142 ---- throws Exception { + if (true) { + throw new javax.servlet.ServletException( + "There is no access control mechanism yet, so this is deactivated"); + } + //- String plugin = hsrq.getParameter("plugin"); *************** *** 155,163 **** if (reset.equals("true")) { ! //if we clicked a link, reset the form ! //values by ref with loaded data resetForm(plugins, plugin, cf); ! } else { //if we klicked the button ! //apply changed config from cf to treeset plugins = applyConfig(plugins, plugin, cf); --- 161,169 ---- if (reset.equals("true")) { ! //if we clicked a link, ! //reset the form values by ref with loaded data resetForm(plugins, plugin, cf); ! } else { ! //if we klicked the button, //apply changed config from cf to treeset plugins = applyConfig(plugins, plugin, cf); |
From: Marcus <the...@us...> - 2004-03-30 14:44:40
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6571 Modified Files: ScanThread.java ScannerPlugin.java Added Files: ControlThread.java Scanner.java ScannerConfig.java ScannerPluginConfig.java StandaloneScanner.java StandaloneScannerConfig.java Log Message: lots of stuff for standalone --- NEW FILE: Scanner.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * Scanner.java * * Created on 30. März 2004, 14:32 */ package junk.plugin.scanner; import junk.util.HostMap; import java.util.HashMap; /** * * @author flow */ public interface Scanner { public static final int SMB_PORT = 139; /** * deprecated * @deprecated use KEY_HOSTS_MAP */ public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; /** the key under which the map is stored in the servlet context */ public static final String KEY_HOSTS_MAP = "scanner-host-map"; /** the key under which the scanning status * is saved in the servlet context */ public static final String KEY_SCANNER_RUNNING = "scanner-running"; public ScannerConfig getConf(); public HostMap getHosts(); public boolean isRunning(); public void setScanning(boolean isScanning); public boolean isScanning(); public void reportDone(long time); public void saveHosts(); } --- NEW FILE: ScannerPluginConfig.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package junk.plugin.scanner; import junk.util.IpSubnet; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionServlet; import org.apache.struts.config.ModuleConfig; /** handles the config of the scanner plugin. * @author Marcus Proest (theevilflow at users dot sf dot net) */ public class ScannerPluginConfig implements ScannerConfig { /** plugin configuration key defining the sleep time of the scanner thread */ protected static final String KEY_THREAD_SLEEP = "thread-sleep"; /** * number of concurrent threads */ protected static final String KEY_NUM_OF_THREADS = "thread-num"; /** 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(this.getClass()); /** initial ipsubnetsString */ private String ipSubnetsString = null; /** the path to load and save the hostmap to */ private String savemappath = "data/hostmap"; /** * number of concurrent threads */ private int numOfThreads = 3; /** 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 * the package. */ protected ScannerPluginConfig() { } /** Creates a new instance of ScannerConfig. * @param m ModuleConfig * @param a ActionServlet * @throws IllegalArgumentException * thrown if reading the configuration failed */ protected ScannerPluginConfig(ActionServlet a, ModuleConfig m) throws IllegalArgumentException { HashMap conf = junk.plugin.PluginTools.getPluginConfig(ScannerPlugin.class, m); 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 an iterator over the configured ip subnets. * @return an iterator over the configured ip subnets */ public Iterator getIpSubnetIterator() { return this.ipSubnets.iterator(); } /** * returns the number of concurrent threads * @return the number of concurrent threads */ public int getNumOfThreads() { return this.numOfThreads; } /** 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; } /** Apply the config values. * @param conf configuration values * @throws IllegalArgumentException * thrown if reading the configuration failed * @param basepath global path to the web-inf directory */ private void applyConfig(HashMap conf, String basepath) throws IllegalArgumentException { try { this.sleep = Long.parseLong((String) conf.get(KEY_THREAD_SLEEP)); } catch (Exception e) { log.warn("Loading parameter " + KEY_THREAD_SLEEP + " FAILED, defaulting to " + this.sleep, e); } try { this.interval = Long.parseLong((String) conf.get(KEY_SCAN_INTERVAL)); } catch (Exception e) { log.warn("Loading parameter " + KEY_SCAN_INTERVAL + "FAILED, defaulting to " + this.interval, e); } try { String subnetConfigs = (String) conf.get(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])); } } catch (Exception e) { //this value cannot be defaulted, so failing ist fatal. throw new IllegalArgumentException("Loading parameter " + KEY_IP_RANGE + " FAILED. (" + e.getMessage() + ")"); } try { this.tcpTimeout = Integer.parseInt((String) conf.get(KEY_TCP_TO)); } catch (Exception e) { log.warn("Loading parameter " + KEY_TCP_TO + " FAILED, defaulting to " + this.tcpTimeout, e); } try { this.numOfThreads = Integer.parseInt((String) conf.get( KEY_NUM_OF_THREADS)); } catch (Exception e) { log.warn("Loading parameter " + KEY_NUM_OF_THREADS + " FAILED, defaulting to " + this.numOfThreads, e); } try { String filename = (String) conf.get(KEY_SAVE_MAP); this.savemappath = basepath + File.separatorChar + ".." + File.separatorChar + filename; } catch (Exception e) { log.warn("Loading parameter " + 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.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ScannerPlugin.java 30 Mar 2004 05:32:49 -0000 1.11 --- ScannerPlugin.java 30 Mar 2004 14:33:01 -0000 1.12 *************** *** 40,43 **** --- 40,44 ---- import java.util.HashMap; import java.util.Iterator; + import java.util.NoSuchElementException; import javax.servlet.ServletException; *************** *** 57,90 **** * * @author Marcus Proest (theevilflow at users dot sf dot net) ! *@todo there are some issues regarding multiple ip subnets... */ ! public class ScannerPlugin implements PlugIn, Runnable { ! /** ! * deprecated ! * @deprecated use KEY_HOSTS_MAP ! */ ! public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; ! ! /** the key under which the map is stored in the servlet context */ ! public static final String KEY_HOSTS_MAP = "scanner-host-map"; ! ! /** the key under which the scann config is stored in the servlet context */ ! ! //i dont know why to save this.... ! //public static final String KEY_SCANNER_CONFIG = "scanner-config"; ! ! /** the key under which the scanning status ! * is saved in the servlet context ! */ ! public static final String KEY_SCANNER_RUNNING = "scanner-running"; ! /** version */ private static final String VERSION = "v0.1"; - /** smb scanport */ - protected static final int SMB_PORT = 139; - /** the actionservlet of the struts application */ private ActionServlet actionServlet = null; /** the hostmap */ --- 58,70 ---- * * @author Marcus Proest (theevilflow at users dot sf dot net) ! * */ ! public class ScannerPlugin implements PlugIn, Scanner { /** version */ private static final String VERSION = "v0.1"; /** the actionservlet of the struts application */ private ActionServlet actionServlet = null; + private ControlThread ct = null; /** the hostmap */ *************** *** 97,120 **** 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 * also used to tell the spider whether the scanner scans right now */ private boolean isScanning = false; ! /** ! * yet finished threads ! */ private int doneThreads = 0; /** 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 --- 77,121 ---- private ScannerConfig conf = null; /** semaphore * also used to tell the spider whether the scanner scans right now */ private boolean isScanning = false; ! ! /** yet finished threads */ private int doneThreads = 0; + /** + * returns the scanner configuration + * @return the scanner configuration + */ + public ScannerConfig getConf() { + return this.conf; + } + + /** + * returns the hostmap + * @return the hostmap + */ + public HostMap getHosts() { + return this.hosts; + } + + public boolean isRunning() { + return this.ct.isRunning(); + } + + public void setScanning(boolean isScanning) { + this.isScanning = isScanning; + this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, + new Boolean(this.isScanning)); + } + + public boolean isScanning() { + return this.isScanning; + } + /** destroys the plugin. */ public void destroy() { ! //terminate the thread! /* the server will continue to shutdown as we leave the destroy *************** *** 124,131 **** * I know is is not very stylish, but for now i have no better idea */ - while (this.isRunning) { - ; - } - this.saveMap(this.hosts); --- 125,128 ---- *************** *** 144,148 **** try { ! this.conf = new ScannerConfig(a, m); } catch (IllegalArgumentException e) { log.fatal("Loading config FAILED. This is FATAL. " --- 141,145 ---- try { ! this.conf = new ScannerPluginConfig(a, m); } catch (IllegalArgumentException e) { log.fatal("Loading config FAILED. This is FATAL. " *************** *** 152,222 **** } - //forgot why to do this - // this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_CONFIG, - // this.conf); //load the persistent map and save it in the context this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, ! this.loadMap()); ! ! //start the real thread ! if (this.scanThread == null) { ! this.scanThread = new Thread(this); ! this.scanThread.start(); ! } else { ! log.fatal("Scanner thread could not be started. " ! + "It seems it is already running."); ! ! return; ! } log.info("juNK scanner plugin (" + VERSION + ") thread started"); } - /** the thread run method. */ - public void run() { - this.isRunning = true; - - this.scan(); //scan at startup to provide values as fast as possible - - Thread runningThread = Thread.currentThread(); - - while (scanThread == runningThread) { - try { - Thread.sleep(this.conf.getSleep()); - } catch (InterruptedException e) { - ; //wake up, neo - } - - //every 'interval' milliseconds - if ((System.currentTimeMillis() % (this.conf.getInterval())) <= this.conf - .getSleep()) { - this.scan(); - } - } - - this.isRunning = false; - } - - /** - * returns the scanner configuration - * @return the scanner configuration - */ - protected ScannerConfig getConf() { - return this.conf; - } - - /** - * returns the hostmap - * @return the hostmap - */ - protected HostMap getHosts() { - return this.hosts; - } - /** * the scanner threads call this to maintain the isScanning property * @param time the time the thread took to finish ! */ ! protected synchronized void reportDone(long time) { this.doneThreads++; --- 149,166 ---- } //load the persistent map and save it in the context + this.hosts = this.loadMap(); this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, ! this.hosts); ! this.ct = new ControlThread(this); log.info("juNK scanner plugin (" + VERSION + ") thread started"); } /** * the scanner threads call this to maintain the isScanning property * @param time the time the thread took to finish ! */ ! public synchronized void reportDone(long time) { this.doneThreads++; *************** *** 231,234 **** --- 175,183 ---- } + public void saveHosts() { + this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, + this.hosts); + } + /** load and deserialize the hostmap. * @return loaded map *************** *** 236,240 **** private HostMap loadMap() { String path = this.conf.getSaveMapPath(); ! HostMap h = null; FileInputStream f = null; ObjectInputStream o = null; --- 185,190 ---- private HostMap loadMap() { String path = this.conf.getSaveMapPath(); ! HostMap h = this.populateMap(); ! int hp = h.size(); FileInputStream f = null; ObjectInputStream o = null; *************** *** 243,247 **** f = new FileInputStream(path); o = new ObjectInputStream(f); ! h = (HostMap) o.readObject(); log.info("Persistent data map loaded (" + path + ")"); } catch (IOException e1) { --- 193,198 ---- f = new FileInputStream(path); o = new ObjectInputStream(f); ! h.putAll((HostMap) o.readObject()); ! log.info("Persistent data map loaded (" + path + ")"); } catch (IOException e1) { *************** *** 252,259 **** + "This is not critical, but should not happen.", ex); } finally { - if (h == null) { - h = populateMap(); //if there is no data, populate map - } - try { //cleanup. don't care if this fails. --- 203,206 ---- *************** *** 286,289 **** --- 233,237 ---- String ip = (String) i.next(); h.put(ip, new NameOnline(ip, Boolean.FALSE)); + log.info(ip); } } *************** *** 324,369 **** } } - - /** - * scans the net. - * @return <CODE>true</CODE> if the scan was performed. - */ - private synchronized boolean scan() { - if (this.isScanning) { - return false; //semaphore, to be sure - } - - this.isScanning = true; //set the semaphore - this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, - new Boolean(this.isScanning)); - - //get the old hostmap - this.hosts = (HostMap) this.actionServlet.getServletContext() - .getAttribute(KEY_HOSTS_MAP); - - //get subnet iterator - Iterator iterator = this.conf.getIpSubnetIterator(); - - //iterate over the subnet - //this iterates over the configured subnets, not over ip's! - while (iterator.hasNext()) { - //get an IpSubnet clone - IpSubnet i = (IpSubnet) ((IpSubnet) iterator.next()).clone(); - - for (int x = 0; x < this.conf.getNumOfThreads(); x++) { - new ScanThread(this, i, x); - } - } - - //store the results in the context - this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, hosts); - - //this is now maintained by the threads - - /* this.isScanning = false; - this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, - new Boolean(this.isScanning)); - */ - return true; - } } --- 272,274 ---- --- NEW FILE: StandaloneScanner.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * DUMMY, yet */ package junk.plugin.scanner; /** * * @author flow */ public class StandaloneScanner implements Scanner { /** Creates a new instance of StandaloneScanner */ public StandaloneScanner() { } public ScannerConfig getConf() { return null; } public junk.util.HostMap getHosts() { return null; } /** should return isRunning method of controlthread*/ public boolean isRunning() { return false; } public void setScanning(boolean isScanning) { } public boolean isScanning() { return false; } public void reportDone(long time) { } public void saveHosts() { } } Index: ScanThread.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScanThread.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ScanThread.java 30 Mar 2004 05:32:23 -0000 1.1 --- ScanThread.java 30 Mar 2004 14:33:01 -0000 1.2 *************** *** 41,65 **** /** ! * thread to scann ip's */ class ScanThread implements Runnable { ! /** ! * ip iterator ! */ private Iterator i; /** log writer */ private Log log = LogFactory.getLog(ScanThread.class); ! /** ! * parent plugin ! */ ! private ScannerPlugin parent; ! /** ! * thread ! */ private Thread me = null; ! /** ! * id of the thread ! */ private int t; --- 41,61 ---- /** ! * thread to scan ip's ! * @todo perform REAL check for iterator syncronization */ class ScanThread implements Runnable { ! /** ip iterator */ private Iterator i; /** log writer */ private Log log = LogFactory.getLog(ScanThread.class); ! ! /** parent plugin */ ! private Scanner parent; ! ! /** thread */ private Thread me = null; ! ! /** id of the thread */ private int t; *************** *** 67,74 **** * constructor * @param sp calling plugin ! * @param i ip iterator ! * @param t thread id ! */ ! protected ScanThread(ScannerPlugin sp, Iterator i, int t) { this.parent = sp; this.i = i; --- 63,70 ---- * constructor * @param sp calling plugin ! * @param i ip iterator over ALL ip's to scan ! * @param t thread id (no real purpose, just for logging) ! */ ! protected ScanThread(Scanner sp, Iterator i, int t) { this.parent = sp; this.i = i; *************** *** 82,88 **** } /** * run method of the thread ! */ public void run() { log.info("Starting Thread " + t); --- 78,88 ---- } + /** empty standard constructor **/ + private ScanThread() { + } + /** * run method of the thread ! */ public void run() { log.info("Starting Thread " + t); *************** *** 90,97 **** long start = System.currentTimeMillis(); //to get a scanningtime ! int c = 0; ! while (i.hasNext()) { ! c++; String ip = (String) i.next(); //get next IP --- 90,97 ---- long start = System.currentTimeMillis(); //to get a scanningtime ! int c = 0; //count scanned ip's ! while (i.hasNext() && this.parent.isRunning()) { ! c++; //increase ip counter String ip = (String) i.next(); //get next IP *************** *** 102,106 **** } else { //the host is handled as 'offline' ! //et the old values to preserve the name NameOnline no = (NameOnline) this.parent.getHosts().get(ip); no.setOnline(Boolean.FALSE); //set it offline --- 102,106 ---- } else { //the host is handled as 'offline' ! //get the old values to preserve the name NameOnline no = (NameOnline) this.parent.getHosts().get(ip); no.setOnline(Boolean.FALSE); //set it offline --- NEW FILE: ScannerConfig.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * ScannerConfig.java * * Created on 30. März 2004, 16:34 */ package junk.plugin.scanner; import java.util.Iterator; /** * * @author flow */ public interface ScannerConfig { public long getInterval(); public Iterator getIpSubnetIterator(); public int getNumOfThreads(); public String getSaveMapPath(); public long getSleep(); public int getTcpTimeout(); } --- NEW FILE: ControlThread.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * ControlThread.java * * Created on 30. März 2004, 12:11 */ package junk.plugin.scanner; import junk.util.IpSubnet; import java.util.Iterator; import java.util.NoSuchElementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * * @author flow */ public class ControlThread implements Runnable { /** log writer */ private Log log = LogFactory.getLog(ScannerPlugin.class); private Scanner parent; /** the scanner thread */ private Thread controlThread = null; /** whether the thread is running. * has to be maintained by the thread itself */ private boolean isRunning = false; /** Creates a new instance of ControlThread */ public ControlThread(Scanner parent) { this.parent = parent; //start the real thread if (this.controlThread == null) { this.controlThread = new Thread(this); this.controlThread.start(); } else { log.fatal("Scanner thread could not be started. " + "It seems it is already running."); return; } } /** the thread run method. */ public void run() { this.isRunning = true; this.scan(); //scan at startup to provide values as fast as possible Thread runningThread = Thread.currentThread(); while (controlThread == runningThread) { try { Thread.sleep(this.parent.getConf().getSleep()); } catch (InterruptedException e) { ; //wake up, neo } //every 'interval' milliseconds if ((System.currentTimeMillis() % (this.parent.getConf() .getInterval())) <= this.parent.getConf() .getSleep()) { this.scan(); } } this.isRunning = false; } protected boolean isRunning() { return this.isRunning; } protected void destroy() { this.controlThread = null; } /** * scans the net. * @return <CODE>true</CODE> if the scan was performed. */ private synchronized boolean scan() { if (this.parent.isScanning()) { return false; //semaphore, to be sure } this.parent.setScanning(true); //set the semaphore Iterator iterator = this.parent.getConf().getIpSubnetIterator(); //special iterator to iterate over ALL ip addresses Iterator i = new IpIterator(iterator); for (int x = 0; x < this.parent.getConf().getNumOfThreads(); x++) { new ScanThread(this.parent, i, x); } //store the results in the context /* this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, this.hosts); */ this.parent.saveHosts(); //this is now maintained by the threads /* this.isScanning = false; this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, new Boolean(this.isScanning)); */ return true; } class IpIterator implements Iterator { private Iterator currentIterator = null; private Iterator subnets; protected IpIterator(Iterator subnets) { this.subnets = subnets; if (this.subnets.hasNext()) { this.currentIterator = (Iterator) ((IpSubnet) subnets.next()) .clone(); } } public boolean hasNext() { while (!this.currentIterator.hasNext()) { if (this.subnets.hasNext()) { this.currentIterator = (Iterator) this.subnets.next(); } else { return false; } } return true; } public Object next() { if (this.hasNext()) { return this.currentIterator.next(); } else { throw new NoSuchElementException(); } } /* * @see java.util.Iterator#remove * @throws UnsupportedOperationException this operation is not supported */ public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } } } --- NEW FILE: StandaloneScannerConfig.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * DUMMY, yet */ package junk.plugin.scanner; /** * * @author flow */ public class StandaloneScannerConfig { /** Creates a new instance of StandaloneScannerConfig */ public StandaloneScannerConfig() { } } |
From: Marcus <the...@us...> - 2004-03-30 14:34:32
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661 Removed Files: ScannerConfig.java Log Message: standalone support --- ScannerConfig.java DELETED --- |
From: Marcus <the...@us...> - 2004-03-30 05:44:23
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12196/junk/WEB-INF/classes/junk/plugin/scanner Modified Files: ScannerPlugin.java Log Message: multithreading Index: ScannerPlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerPlugin.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ScannerPlugin.java 27 Mar 2004 20:14:18 -0000 1.10 --- ScannerPlugin.java 30 Mar 2004 05:32:49 -0000 1.11 *************** *** 26,31 **** package junk.plugin.scanner; - import jcifs.netbios.NbtAddress; - import junk.util.HostMap; import junk.util.IpSubnet; --- 26,29 ---- *************** *** 39,46 **** import java.io.ObjectOutputStream; - import java.net.InetSocketAddress; - import java.net.Socket; - import java.net.UnknownHostException; - import java.util.ArrayList; import java.util.HashMap; --- 37,40 ---- *************** *** 63,66 **** --- 57,61 ---- * * @author Marcus Proest (theevilflow at users dot sf dot net) + *@todo there are some issues regarding multiple ip subnets... */ public class ScannerPlugin implements PlugIn, Runnable { *************** *** 75,79 **** /** the key under which the scann config is stored in the servlet context */ ! public static final String KEY_SCANNER_CONFIG = "scanner-config"; /** the key under which the scanning status --- 70,76 ---- /** the key under which the scann config is stored in the servlet context */ ! ! //i dont know why to save this.... ! //public static final String KEY_SCANNER_CONFIG = "scanner-config"; /** the key under which the scanning status *************** *** 86,90 **** /** smb scanport */ ! private static final int SMB_PORT = 139; /** the actionservlet of the struts application */ --- 83,87 ---- /** smb scanport */ ! protected static final int SMB_PORT = 139; /** the actionservlet of the struts application */ *************** *** 112,115 **** --- 109,116 ---- */ private boolean isScanning = false; + /** + * yet finished threads + */ + private int doneThreads = 0; /** destroys the plugin. */ *************** *** 151,154 **** --- 152,156 ---- } + //forgot why to do this // this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_CONFIG, // this.conf); *************** *** 162,167 **** this.scanThread.start(); } else { ! log.fatal( ! "Scanner thread could not be started. It seems it is already running."); return; --- 164,169 ---- this.scanThread.start(); } else { ! log.fatal("Scanner thread could not be started. " ! + "It seems it is already running."); return; *************** *** 197,253 **** /** ! * not sure if i need this anyway... ! * @param conf fnoc ! */ ! protected void setConf(ScannerConfig conf) { ! this.conf = conf; } ! /** retrieve net bios name via jcifs. ! * @return the net bios name of the host, or the ip of the host if no ! * net bios name could be determined. ! * @param ip the ip of the host wich name should be determined ! */ ! private String getNetBiosName(String ip) { ! String name = null; ! ! try { ! name = NbtAddress.getByName(ip).getHostName(); ! } catch (UnknownHostException e) { ! name = ip; //to make it easy for the caller ! } ! ! return name; } ! /** determine if smb is running on host <code>ip</code><br/>. ! * ! * This function serves some speed considerations. ! * Querying via jcifs will take a long time, so we ! * just make a quick check here, ! * and afterwards query only the online hosts. ! * ! * @param ip the ip address of the host to check ! * @return <code>true</code> if the smb port is reachable. ! * <CODE>false</CODE> if any error occurs ! */ ! private boolean isSmb(String ip) { ! Socket sock = new Socket(); ! boolean ret; ! ! try { ! //try to connect to the smb port ! sock.connect(new InetSocketAddress(ip, SMB_PORT), ! this.conf.getTcpTimeout()); ! //if it worked, close it again ! sock.close(); ! ret = true; ! } catch (Exception e) { ! //any exception will result in false ! ret = false; } ! return ret; } --- 199,232 ---- /** ! * returns the scanner configuration ! * @return the scanner configuration ! */ ! protected ScannerConfig getConf() { ! return this.conf; } ! /** ! * returns the hostmap ! * @return the hostmap ! */ ! protected HostMap getHosts() { ! return this.hosts; } ! /** ! * the scanner threads call this to maintain the isScanning property ! * @param time the time the thread took to finish ! */ ! protected synchronized void reportDone(long time) { ! this.doneThreads++; ! if (this.doneThreads >= this.conf.getNumOfThreads()) { ! this.isScanning = false; ! this.doneThreads = 0; ! log.info("Last Thread done! Time: " + time); } ! this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, ! new Boolean(this.isScanning)); } *************** *** 318,325 **** 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(); --- 297,306 ---- private void saveMap(HostMap h) { String path = this.conf.getSaveMapPath(); + FileOutputStream f = null; + ObjectOutputStream o = null; try { ! f = new FileOutputStream(path); ! o = new ObjectOutputStream(f); o.writeObject(h); o.close(); *************** *** 328,331 **** --- 309,325 ---- } catch (Exception e) { log.warn("Could not save hostmap (" + path + ")", e); + } finally { + try { //cleanup. don't care if this fails. + + if (o != null) { + o.close(); + } + + if (f != null) { + f.close(); + } + } catch (IOException e11) { + ; + } } } *************** *** 352,386 **** //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 ! log.debug(no.toString()); ! 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.debug(i.toString() + " scan completed in " + time + " ms"); } --- 346,357 ---- //iterate over the subnet + //this iterates over the configured subnets, not over ip's! while (iterator.hasNext()) { //get an IpSubnet clone IpSubnet i = (IpSubnet) ((IpSubnet) iterator.next()).clone(); ! for (int x = 0; x < this.conf.getNumOfThreads(); x++) { ! new ScanThread(this, i, x); } } *************** *** 388,563 **** this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, hosts); ! this.isScanning = false; ! this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, ! new Boolean(this.isScanning)); ! ! return true; ! } ! ! /** handles the config of the scanner plugin. ! * @author Marcus Proest (theevilflow at users dot sf dot net) ! */ ! 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 ! * the package. ! */ ! protected ScannerConfig() { ! } ! ! /** Creates a new instance of ScannerConfig. ! * @param m ModuleConfig ! * @param a ActionServlet ! * @throws IllegalArgumentException ! * thrown if reading the configuration failed ! */ ! protected ScannerConfig(ActionServlet a, ModuleConfig m) ! throws IllegalArgumentException ! { ! HashMap conf = junk.plugin.PluginTools.getPluginConfig(ScannerPlugin.class, ! m); ! ! 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 ! * @throws IllegalArgumentException ! * thrown if reading the configuration failed ! * @param basepath global path to the web-inf directory */ ! 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])); ! } ! } catch (Exception e) { ! //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); ! } ! } } } --- 359,369 ---- this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, hosts); ! //this is now maintained by the threads ! /* this.isScanning = false; ! this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, ! new Boolean(this.isScanning)); */ ! return true; } } |
From: Marcus <the...@us...> - 2004-03-30 05:43:57
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12147/junk/WEB-INF/classes/junk/plugin/scanner Added Files: ScanThread.java Log Message: initial release --- NEW FILE: ScanThread.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package junk.plugin.scanner; import jcifs.netbios.NbtAddress; import junk.util.NameOnline; import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * thread to scann ip's */ class ScanThread implements Runnable { /** * ip iterator */ private Iterator i; /** log writer */ private Log log = LogFactory.getLog(ScanThread.class); /** * parent plugin */ private ScannerPlugin parent; /** * thread */ private Thread me = null; /** * id of the thread */ private int t; /** * constructor * @param sp calling plugin * @param i ip iterator * @param t thread id */ protected ScanThread(ScannerPlugin sp, Iterator i, int t) { this.parent = sp; this.i = i; this.t = t; //start the real thread if (this.me == null) { this.me = new Thread(this); this.me.start(); } } /** * run method of the thread */ public void run() { log.info("Starting Thread " + t); long start = System.currentTimeMillis(); //to get a scanningtime int c = 0; while (i.hasNext()) { c++; String ip = (String) i.next(); //get next IP if (this.isSmb(ip)) { //the host is handled as 'online' this.parent.getHosts().put(ip, new NameOnline(this.getNetBiosName(ip), Boolean.TRUE)); } else { //the host is handled as 'offline' //et the old values to preserve the name NameOnline no = (NameOnline) this.parent.getHosts().get(ip); no.setOnline(Boolean.FALSE); //set it offline this.parent.getHosts().put(ip, no); //save it } } log.info("Ended Thread " + t + " I scanned " + c + " ip's"); long time = System.currentTimeMillis() - start; this.parent.reportDone(time); } /** retrieve net bios name via jcifs. * @return the net bios name of the host, or the ip of the host if no * net bios name could be determined. * @param ip the ip of the host wich name should be determined */ private String getNetBiosName(String ip) { String name = null; try { name = NbtAddress.getByName(ip).getHostName(); } catch (UnknownHostException e) { name = ip; //to make it easy for the caller } return name; } /** determine if smb is running on host <code>ip</code><br/>. * * This function serves some speed considerations. * Querying via jcifs will take a long time, so we * just make a quick check here, * and afterwards query only the online hosts. * * @param ip the ip address of the host to check * @return <code>true</code> if the smb port is reachable. * <CODE>false</CODE> if any error occurs */ private boolean isSmb(String ip) { Socket sock = new Socket(); boolean ret; try { //try to connect to the smb port sock.connect(new InetSocketAddress(ip, parent.SMB_PORT), this.parent.getConf().getTcpTimeout()); //if it worked, close it again sock.close(); ret = true; } catch (Exception e) { //any exception will result in false ret = false; } return ret; } } |
From: Marcus <the...@us...> - 2004-03-30 05:43:06
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12039/junk/WEB-INF/classes/junk/plugin/scanner Added Files: ScannerConfig.java Log Message: moved back to extra class --- NEW FILE: ScannerConfig.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package junk.plugin.scanner; import junk.util.IpSubnet; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionServlet; import org.apache.struts.config.ModuleConfig; /** handles the config of the scanner plugin. * @author Marcus Proest (theevilflow at users dot sf dot net) */ public class ScannerConfig { /** plugin configuration key defining the sleep time of the scanner thread */ protected static final String KEY_THREAD_SLEEP = "thread-sleep"; /** * number of concurrent threads */ protected static final String KEY_NUM_OF_THREADS = "thread-num"; /** 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(ScannerConfig.class); /** initial ipsubnetsString */ private String ipSubnetsString = null; /** the path to load and save the hostmap to */ private String savemappath = "data/hostmap"; /** * number of concurrent threads */ private int numOfThreads = 3; /** 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 * the package. */ protected ScannerConfig() { } /** Creates a new instance of ScannerConfig. * @param m ModuleConfig * @param a ActionServlet * @throws IllegalArgumentException * thrown if reading the configuration failed */ protected ScannerConfig(ActionServlet a, ModuleConfig m) throws IllegalArgumentException { HashMap conf = junk.plugin.PluginTools.getPluginConfig(ScannerPlugin.class, m); 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 number of concurrent threads * @return the number of concurrent threads */ public int getNumOfThreads() { return this.numOfThreads; } /** 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 * @throws IllegalArgumentException * thrown if reading the configuration failed * @param basepath global path to the web-inf directory */ private void applyConfig(HashMap conf, String basepath) throws IllegalArgumentException { try { this.sleep = Long.parseLong((String) conf.get(KEY_THREAD_SLEEP)); } catch (Exception e) { log.warn("Loading parameter " + KEY_THREAD_SLEEP + " FAILED, defaulting to " + this.sleep, e); } try { this.interval = Long.parseLong((String) conf.get(KEY_SCAN_INTERVAL)); } catch (Exception e) { log.warn("Loading parameter " + KEY_SCAN_INTERVAL + "FAILED, defaulting to " + this.interval, e); } try { String subnetConfigs = (String) conf.get(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])); } } catch (Exception e) { //this value cannot be defaulted, so failing ist fatal. throw new IllegalArgumentException("Loading parameter " + KEY_IP_RANGE + " FAILED. (" + e.getMessage() + ")"); } try { this.tcpTimeout = Integer.parseInt((String) conf.get(KEY_TCP_TO)); } catch (Exception e) { log.warn("Loading parameter " + KEY_TCP_TO + " FAILED, defaulting to " + this.tcpTimeout, e); } try { this.numOfThreads = Integer.parseInt((String) conf.get( KEY_NUM_OF_THREADS)); } catch (Exception e) { log.warn("Loading parameter " + KEY_NUM_OF_THREADS + " FAILED, defaulting to " + this.numOfThreads, e); } try { String filename = (String) conf.get(KEY_SAVE_MAP); this.savemappath = basepath + File.separatorChar + ".." + File.separatorChar + filename; } catch (Exception e) { log.warn("Loading parameter " + KEY_SAVE_MAP + " FAILED, defaulting to " + this.savemappath, e); } } } |
From: Marcus <the...@us...> - 2004-03-27 20:46:27
|
Update of /cvsroot/junk/junk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6906 Modified Files: build.xml Log Message: added doclink to webservices documentation Index: build.xml =================================================================== RCS file: /cvsroot/junk/junk/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** build.xml 22 Mar 2004 15:16:44 -0000 1.1 --- build.xml 27 Mar 2004 20:35:16 -0000 1.2 *************** *** 71,74 **** --- 71,75 ---- <link href="http://jakarta.apache.org/struts/api/" /> <link href="http://jakarta.apache.org/commons/logging/api/" /> + <link href="http://java.sun.com/webservices/docs/1.3/api/" /> <sourcepath> <pathelement location="."/> |
From: Marcus <the...@us...> - 2004-03-27 20:45:37
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6753 Modified Files: ConnectionProvider.java DatabasePlugin.java Log Message: minor changes Index: ConnectionProvider.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/database/ConnectionProvider.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConnectionProvider.java 24 Mar 2004 15:56:41 -0000 1.1 --- ConnectionProvider.java 27 Mar 2004 20:34:26 -0000 1.2 *************** *** 31,44 **** /** ! * interface to retrieve a database connection ! * @author flow */ public interface ConnectionProvider { /** ! * should return a connection to the configured database ! * the remarkable feature of this file is, that the comments are way larger ! * than the code itself. I love such stuff. ! * @throws SQLException might be thrown if the instatiaton of the connection ! * fails * @return a connection to the configured database */ --- 31,40 ---- /** ! * interface to retrieve a database connection. */ public interface ConnectionProvider { /** ! * should return a connection to the configured database. ! * @throws SQLException * @return a connection to the configured database */ Index: DatabasePlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/database/DatabasePlugin.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DatabasePlugin.java 24 Mar 2004 15:57:14 -0000 1.1 --- DatabasePlugin.java 27 Mar 2004 20:34:26 -0000 1.2 *************** *** 59,65 **** public static final String KEY_DATABASE_CON = "database-provider"; - /** the actionservlet of the struts application */ - private ActionServlet actionServlet = null; - /** * plugin configuration --- 59,62 ---- *************** *** 112,121 **** */ public void init(ActionServlet a, ModuleConfig m) ! throws ServletException { ! this.actionServlet = a; this.conf = PluginTools.getPluginConfig(DatabasePlugin.class, m); if (this.conf == null) { log.fatal("No database configuration found."); } --- 109,120 ---- */ public void init(ActionServlet a, ModuleConfig m) ! throws ServletException ! { this.conf = PluginTools.getPluginConfig(DatabasePlugin.class, m); if (this.conf == null) { log.fatal("No database configuration found."); + + return; } *************** *** 137,140 **** --- 136,145 ---- Connection con = DriverManager.getConnection(url, user, pass); con.close(); + a.getServletContext().setAttribute(KEY_DATABASE_CON, + (ConnectionProvider) this); + log.info("DatabasePlugin loaded ( [" + driver + "][" + url + "][" + + user + "] )"); + + return; } catch (SQLException e1) { log.fatal("Error while connecting to data source.", e1); *************** *** 146,154 **** log.fatal("Illegal access while instatiating JDBC driver.", e4); } - - this.actionServlet.getServletContext().setAttribute(DatabasePlugin.KEY_DATABASE_CON, - (ConnectionProvider) this); - log.info("DatabasePlugin loaded ( [" + driver + "][" + url + "][" - + user + "] )"); } } --- 151,154 ---- |
From: Marcus <the...@us...> - 2004-03-27 20:25:30
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2846 Modified Files: ScannerPlugin.java Log Message: moved config class inside this class; minor improvements Index: ScannerPlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerPlugin.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ScannerPlugin.java 25 Mar 2004 15:25:34 -0000 1.9 --- ScannerPlugin.java 27 Mar 2004 20:14:18 -0000 1.10 *************** *** 43,46 **** --- 43,48 ---- import java.net.UnknownHostException; + import java.util.ArrayList; + import java.util.HashMap; import java.util.Iterator; *************** *** 75,79 **** public static final String KEY_SCANNER_CONFIG = "scanner-config"; ! /** the key under which the scanning status is saved in the servlet context */ public static final String KEY_SCANNER_RUNNING = "scanner-running"; --- 77,83 ---- public static final String KEY_SCANNER_CONFIG = "scanner-config"; ! /** the key under which the scanning status ! * is saved in the servlet context ! */ public static final String KEY_SCANNER_RUNNING = "scanner-running"; *************** *** 104,114 **** private boolean isRunning = false; ! /** semaphore */ private boolean isScanning = false; - /** empty standard constructor */ - public ScannerPlugin() { - } - /** destroys the plugin. */ public void destroy() { --- 108,116 ---- private boolean isRunning = false; ! /** semaphore ! * also used to tell the spider whether the scanner scans right now ! */ private boolean isScanning = false; /** destroys the plugin. */ public void destroy() { *************** *** 127,132 **** this.saveMap(this.hosts); ! log.debug("juNK scanner plugin (" + ScannerPlugin.VERSION ! + ") thread terminated"); } --- 129,133 ---- this.saveMap(this.hosts); ! log.info("juNK scanner plugin (" + VERSION + ") thread terminated"); } *************** *** 137,141 **** */ public void init(ActionServlet a, ModuleConfig m) ! throws ServletException { this.actionServlet = a; --- 138,143 ---- */ public void init(ActionServlet a, ModuleConfig m) ! throws ServletException ! { this.actionServlet = a; *************** *** 143,156 **** this.conf = new ScannerConfig(a, m); } catch (IllegalArgumentException e) { ! log.fatal("Loading config FAILED. This is FATAL.", e); return; // if some argument was illegal we are out of here } ! 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()); --- 145,158 ---- this.conf = new ScannerConfig(a, m); } catch (IllegalArgumentException e) { ! log.fatal("Loading config FAILED. This is FATAL. " ! + "The scanner will exit NOW.", e); return; // if some argument was illegal we are out of here } ! // this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_CONFIG, ! // this.conf); //load the persistent map and save it in the context ! this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, this.loadMap()); *************** *** 159,166 **** this.scanThread = new Thread(this); this.scanThread.start(); } ! log.info("juNK scanner plugin (" + ScannerPlugin.VERSION ! + ") thread started"); } --- 161,172 ---- this.scanThread = new Thread(this); this.scanThread.start(); + } else { + log.fatal( + "Scanner thread could not be started. It seems it is already running."); + + return; } ! log.info("juNK scanner plugin (" + VERSION + ") thread started"); } *************** *** 232,236 **** try { //try to connect to the smb port ! sock.connect(new InetSocketAddress(ip, ScannerPlugin.SMB_PORT), this.conf.getTcpTimeout()); --- 238,242 ---- try { //try to connect to the smb port ! sock.connect(new InetSocketAddress(ip, SMB_PORT), this.conf.getTcpTimeout()); *************** *** 335,344 **** this.isScanning = true; //set the semaphore ! this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_RUNNING, new Boolean(this.isScanning)); //get the old hostmap this.hosts = (HostMap) this.actionServlet.getServletContext() ! .getAttribute(ScannerPlugin.KEY_HOSTS_MAP); //get subnet iterator --- 341,350 ---- this.isScanning = true; //set the semaphore ! this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, new Boolean(this.isScanning)); //get the old hostmap this.hosts = (HostMap) this.actionServlet.getServletContext() ! .getAttribute(KEY_HOSTS_MAP); //get subnet iterator *************** *** 364,368 **** no.setOnline(Boolean.FALSE); //set it offline ! this.hosts.put(ip, no); //save it --- 370,374 ---- no.setOnline(Boolean.FALSE); //set it offline ! log.debug(no.toString()); this.hosts.put(ip, no); //save it *************** *** 376,391 **** //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; ! this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_RUNNING, new Boolean(this.isScanning)); return true; } } --- 382,563 ---- //calculate scanning time long time = System.currentTimeMillis() - start; ! log.debug(i.toString() + " scan completed in " + time + " ms"); } //store the results in the context ! this.actionServlet.getServletContext().setAttribute(KEY_HOSTS_MAP, hosts); this.isScanning = false; ! this.actionServlet.getServletContext().setAttribute(KEY_SCANNER_RUNNING, new Boolean(this.isScanning)); return true; } + + /** handles the config of the scanner plugin. + * @author Marcus Proest (theevilflow at users dot sf dot net) + */ + 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 + * the package. + */ + protected ScannerConfig() { + } + + /** Creates a new instance of ScannerConfig. + * @param m ModuleConfig + * @param a ActionServlet + * @throws IllegalArgumentException + * thrown if reading the configuration failed + */ + protected ScannerConfig(ActionServlet a, ModuleConfig m) + throws IllegalArgumentException + { + HashMap conf = junk.plugin.PluginTools.getPluginConfig(ScannerPlugin.class, + m); + + 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 + * @throws IllegalArgumentException + * thrown if reading the configuration failed + * @param basepath global path to the web-inf directory + */ + 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])); + } + } catch (Exception e) { + //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); + } + } + } } |
From: Marcus <the...@us...> - 2004-03-27 20:24:15
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2461 Removed Files: ScannerConfig.java Log Message: moved inside ScannerPlugin --- ScannerConfig.java DELETED --- |
From: Marcus <the...@us...> - 2004-03-26 19:16:01
|
Update of /cvsroot/junk/junk/pages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2134 Modified Files: style.css Log Message: config values added Index: style.css =================================================================== RCS file: /cvsroot/junk/junk/pages/style.css,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** style.css 22 Mar 2004 15:21:43 -0000 1.5 --- style.css 26 Mar 2004 19:05:00 -0000 1.6 *************** *** 1,102 **** ! body { ! font-family: Verdana, Helvetica, sans-serif; ! font-weight: normal; ! font-size: 12pt; ! } ! ! table.navigation{ ! border: 2px solid black; ! border-spacing: 2px; ! padding: 0px 0px; ! background-color: #1F54B5; ! color: #ffffff; ! } ! td.navigation{ ! border-right: 1px dotted white; ! } ! ! ! td.error{ ! color: white; ! border: 1px dotted white; ! } ! ! table.online{ ! border: 1px solid black; ! border-spacing: 0px; ! padding: 3px 3px; ! background-color: #D7D7D7; ! color: black; ! } ! ! tr.online{ ! background-color: #D7D7D7; ! } ! ! td.online{ ! background-color: #D7D7D7; ! white-space: nowrap; ! border-top: 1px dotted white; ! color: black; ! } ! ! table.offline{ ! border: 1px dashed black; ! border-spacing: 0px; ! padding: 3px 3px; ! background-color: #e8e8e8; ! color: #666666; ! } ! ! tr.offline{ ! border: 1px solid black; ! background-color: #e8e8e8; ! } ! ! td.offline{ ! white-space: nowrap; ! border-top: 1px dotted white; ! background-color: #e8e8e8; ! } ! ! table.message{ ! border: 2px solid black; ! border-spacing: 2px; ! padding: 0px 0px; ! background-color: #1F54B5; ! color: #ffffff; ! } ! td.message{ ! border-right: 1px dotted white; ! } ! ! ! a.offline{ ! color: #666666; ! } ! ! a:hover { ! color: #1F54B5; ! } ! ! a{ ! text-decoration: none; ! font-weight: normal; ! color: black; ! ! } ! ! td.wio { ! border-bottom: 1px dotted black; ! padding-left: 15px; ! padding-right: 15px; ! padding-top: 2px; ! padding-bottom: 0px; ! text-align: center; ! white-space: nowrap; ! } ! ! h1.wio { ! font-size: 22px; ! color: #000033; ! } \ No newline at end of file --- 1 ---- ! body { font-family: Verdana, Helvetica, sans-serif; font-weight: normal; font-size: 12pt; } table.navigation{ border: 2px solid black; border-spacing: 2px; padding: 0px 0px; background-color: #1F54B5; color: #ffffff; } td.navigation{ border-right: 1px dotted white; } td.error{ color: white; border: 1px dotted white; } table.online{ border: 1px solid black; border-spacing: 0px; padding: 3px 3px; background-color: #D7D7D7; color: black; } tr.online{ background-color: #D7D7D7; } td.online{ background-color: #D7D7D7; white-space: nowrap; border-top: 1px dotted white; color: black; } table.offline{ border: 1px dashed black; border-spacing: 0px; padding: 3px 3px; background-color: #e8e8e8; color: #666666; } tr.offline{ border: 1px solid black; background-color: #e8e8e8; } td.offline{ white-space: nowrap; border-top: 1px dotted white; background-color: #e8e8e8; } table.message{ border: 2px solid black; border-spacing: 2px; padding: 0px 0px; background-color: #1F54B5; color: #ffffff; } td.message{ border-right: 1px dotted white; } a.offline{ color: #666666; } a:hover { color: #1F54B5; } a{ text-decoration: none; font-weight: normal; color: black; } td.wio { border-bottom: 1px dotted black; padding-left: 15px; padding-right: 15px; padding-top: 2px; padding-bottom: 0px; text-align: center; white-space: nowrap; } h1 { font-size: 22px; color: #000033; } a.config-plugin { font-size: 18px; } div.config-props { font-family: Courier, Courier New; } input.config-text { font-family: Courier, Courier New; } \ No newline at end of file |
From: Marcus <the...@us...> - 2004-03-26 19:15:12
|
Update of /cvsroot/junk/junk/pages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1988 Added Files: Config.jsp Log Message: initial import --- NEW FILE: Config.jsp --- <%@page contentType="text/html"%><?xml version="1.0" encoding="iso-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <% /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ %> <%@ taglib uri="/tags/struts-bean" prefix="bean" %> <%@ taglib uri="/tags/struts-html" prefix="html" %> <%@ taglib uri="/tags/struts-logic" prefix="logic" %> <html:html locale="true"> <head> <title><bean:message key="search.title"/></title> <link href="pages/style.css" rel="stylesheet" type="text/css" /> <script language="JavaScript" src="functions.js" type="text/javascript"></script> </head> <body bgcolor="white"> <logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application"> <font color="red"> Fatal Error: Ressources could not be loaded. </font> </logic:notPresent> <h1><bean:message key="config.header" /></h1> <br /> <br /> <logic:iterate id="pluginwrapper" name="config-plugin-list" scope="request"> <html:link href="/junk/Config.do?reset=true" styleClass="config-plugin" paramId="plugin" paramName="pluginwrapper" paramProperty="name"> <bean:write scope="page" name="pluginwrapper" property="description" /> </html:link> (<bean:write scope="page" name="pluginwrapper" property="name" />) <br /> <logic:present name="pluginwrapper" property="properties"> <div class="config-props"> <logic:equal name="pluginwrapper" property="show" value="true"> <html:form action="Config"> <table> <logic:iterate id="props" name="pluginwrapper" property="properties"> <tr> <td> <bean:write scope="page" name="props" property="key"/> </td> <td> <!-- value(key) means that the setValue method of the Form is called --> <bean:define id="key" name="props" property="key" /> <html:text property="<%=("value("+key+")")%>" styleClass="config-text" size="100"/> </td> </tr> </logic:iterate> </table> <input type="hidden" name="plugin" value="<bean:write scope="request" name="config-chosen-plugin" />"/> <html:submit><bean:message key="config.applybutton"/></html:submit> <bean:message key="config.applyhint"/><br /> <div align="right"><html:reset/></div> </html:form> </logic:equal> </div> </logic:present> </logic:iterate> <center><html:submit value="Restart Server" onclick="javascript:alert('You have no authorisation to restart the server!')"/></center> <hr noshade="noshade"> <center> <bean:message key="search.disclaimer" /> </center> </body> </html:html> |
From: Marcus <the...@us...> - 2004-03-26 19:13:34
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1651 Modified Files: application.properties application_de.properties application_nl.properties Log Message: config texts added Index: application.properties =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/resources/application.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** application.properties 23 Mar 2004 15:18:19 -0000 1.3 --- application.properties 26 Mar 2004 19:02:35 -0000 1.4 *************** *** 60,61 **** --- 60,67 ---- message.email=Your Email message.icq=Your ICQ-No + + config.header=juNK Plugin Configuration + + config.applyhint=Apply changes before choosing another Plugin\! + + config.applybutton=Apply Index: application_de.properties =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/resources/application_de.properties,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** application_de.properties 23 Mar 2004 15:18:19 -0000 1.4 --- application_de.properties 26 Mar 2004 19:02:35 -0000 1.5 *************** *** 60,61 **** --- 60,67 ---- message.email=Abs. Email message.icq=Abs.ICQ-Nr + + config.header=juNK Plugin Konfiguration + + config.applyhint=Die \u00C4nderungen m\u00FCssen \u00FCbernommen werden, bevor ein anderes Plugin gew\u00E4hlt wird\! + + config.applybutton=\u00DCbernehmen Index: application_nl.properties =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/resources/application_nl.properties,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** application_nl.properties 23 Mar 2004 15:18:19 -0000 1.4 --- application_nl.properties 26 Mar 2004 19:02:35 -0000 1.5 *************** *** 60,61 **** --- 60,62 ---- message.email=Afz. Email message.icq=Afz.ICQ-Nr + |
From: Marcus <the...@us...> - 2004-03-26 19:13:06
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1533 Added Files: ConfigurationForm.java Log Message: initial import --- NEW FILE: ConfigurationForm.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package junk.util; import java.util.HashMap; import java.util.Set; import org.apache.struts.action.ActionForm; /** * Form to dynamically handle the configuration data * @author flow */ public class ConfigurationForm extends ActionForm { private final HashMap values = new HashMap(); /** * save a value specified by key * @param key the key identifying the value * @param value the value to be saved */ public void setValue(String key, Object value) { values.put(key, value); } /** * return the data identified by key * @param key identifier * @return the data identified by key */ public Object getValue(String key) { return values.get(key); } /** * returns a set of keys * @return a set of keys */ public Set keySet() { return values.keySet(); } /** * clear all data */ public void reset() { values.clear(); } } |
From: Marcus <the...@us...> - 2004-03-26 19:12:52
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/controller In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1494 Added Files: ConfigurationAction.java Log Message: initial import --- NEW FILE: ConfigurationAction.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * ConfigurationAction.java * * Created on 24. März 2004, 19:41 */ package junk.controller; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import junk.util.ConfigurationForm; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Iterator; import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.crimson.tree.XmlDocument; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; /** * Action to handle the configuration dialog */ public class ConfigurationAction extends Action { /** * savekey for current plugin */ public static final String KEY_CHOSEN_PLUGIN = "config-chosen-plugin"; /** * savekey for complete configuration */ public static final String KEY_PLUGIN_LIST = "config-plugin-list"; /** * struts-config.xml root element */ private static final String ROOT = "struts-config"; /** * struts-config.xml plug-in element */ private static final String PLUGIN = "plug-in"; /** * struts-config.xml className element */ private static final String NAME = "className"; /** * struts-config.xml set-property element */ private static final String SET_PROP = "set-property"; /** * struts-config.xml property element */ private static final String PROP = "property"; /** * struts-config.xml value element */ private static final String VAL = "value"; /** * struts-config.xml description property id */ private static final String DESC = "description"; /** log writer */ private Log log = LogFactory.getLog(ConfigurationAction.class); /** execute method of the action * @param am actionMapping * @param af actionForm * @param hsrq httpServletRequest * @param hsrp httpServletRespone * @return actionforward * @throws Exception Exception */ public ActionForward execute(ActionMapping am, ActionForm af, HttpServletRequest hsrq, HttpServletResponse hsrp) throws Exception { //- String plugin = hsrq.getParameter("plugin"); String reset = hsrq.getParameter("reset"); String path = this.getServlet().getServletContext().getRealPath("/WEB-INF") + "/junk-config.xml"; if (plugin == null) { //prevent nullpointers plugin = ""; } if (reset == null) { //prevent nullpointers reset = ""; } ConfigurationForm cf = (ConfigurationForm) af; //cast the form TreeSet plugins = this.loadConfig(path, plugin); //load the saved data if (!plugin.equals("")) { //if a plugin is selected... if (reset.equals("true")) { //if we clicked a link, reset the form //values by ref with loaded data resetForm(plugins, plugin, cf); } else { //if we klicked the button //apply changed config from cf to treeset plugins = applyConfig(plugins, plugin, cf); //save the applied stuff this.saveConfig(path, plugins); } } //this might become superfluos... check from time to time hsrq.setAttribute(KEY_CHOSEN_PLUGIN, plugin); hsrq.setAttribute(KEY_PLUGIN_LIST, plugins.iterator()); return am.findForward("config"); } /** * apply changed config values from the form to the treeset * @param plugins plugin configuration TreeSet * @param plugin chosen plugin * @param cf ConfigurationForm * @return the plugin configuration TreeSet, with modified values from the ConfigurationForm */ private TreeSet applyConfig(TreeSet plugins, String plugin, ConfigurationForm cf) { TreeSet retval = new TreeSet(); Iterator i = plugins.iterator(); while (i.hasNext()) { //cycle through plugins PluginWrapper plw = (PluginWrapper) i.next(); if (plw.getName().equals(plugin)) { //change values for chosen plugin Iterator j = cf.keySet().iterator(); TreeSet props = new TreeSet(); String desc = plw.getDescription(); while (j.hasNext()) { String key = (String) j.next(); String value = (String) cf.getValue(key); props.add(new PropertyWrapper(key, value)); if (key.equals(DESC)) { desc = value; //apply description for header display } } //create new wrapper plw = new PluginWrapper(plw.getName(), desc, props, true); //add it to return value retval.add(plw); } else { //save values for unchanged plugin retval.add(plw); } } return retval; } /** * load the config from the xml file * @param path path to junk-config.xml * @param chosenPlugin chosen plugin * @return the plugin configuration as defined in junk-config.xml * @throws ParserConfigurationException ParserConfigurationException * @throws SAXException SAXException * @throws IOException IOException */ private TreeSet loadConfig(String path, String chosenPlugin) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, IOException { TreeSet plugins = new TreeSet(); DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse(new File(path)); // normalize text representation doc.getDocumentElement().normalize(); NodeList listOfPlugins = doc.getElementsByTagName(PLUGIN); //cycle through plugins for (int x = 0; x < listOfPlugins.getLength(); x++) { Node plugin = listOfPlugins.item(x); String name = plugin.getAttributes().getNamedItem(NAME) .getNodeValue(); //className //apply name to description in case there is no real description String desc = name; boolean show = name.equals(chosenPlugin); //disply THIS plugin NodeList listOfProps = plugin.getChildNodes(); //list properties TreeSet props = new TreeSet(); //cycle through properties for (int y = 0; y < listOfProps.getLength(); y++) { Node property = listOfProps.item(y); //the dom parser treats spaces, linewraps and tabs as #text node. //we only want to edit #element nodes if (property.getNodeType() == property.ELEMENT_NODE) { //get the key/ value pair and wrap it NamedNodeMap setProp = property.getAttributes(); String prop = setProp.getNamedItem(PROP).getNodeValue(); String val = setProp.getNamedItem(VAL).getNodeValue(); props.add(new PropertyWrapper(prop, val)); if (prop.equals(DESC)) { //apply description desc = val; } } } //wrap the plugin PluginWrapper plw = new PluginWrapper(name, desc, props, show); plugins.add(plw); } return plugins; } /** * reset the form and populate it with values from the xml file. * every operation on cf needs to be byref, * so it is never allowd to assign cf * @param plugins plugin configuration TreeSet * @param plugin chosen plugin * @param cf ConfigurationForm */ private void resetForm(TreeSet plugins, String plugin, ConfigurationForm cf) { //clear the data, because it might still contain data from another plugin cf.reset(); Iterator i = plugins.iterator(); while (i.hasNext()) { PluginWrapper plw = (PluginWrapper) i.next(); //find the correct plugin if (plw.getName().equals(plugin)) { Iterator j = ((TreeSet) plw.getProperties()).iterator(); //copy the values while (j.hasNext()) { PropertyWrapper prw = (PropertyWrapper) j.next(); cf.setValue(prw.getKey(), prw.getValue()); } break; } } } /** * save the config to the xml file * @param path path to junk-config.xml * @param plugins plugin configuration TreeSet * @throws FactoryConfigurationError FactoryConfigurationError * @throws ParserConfigurationException ParserConfigurationException * @throws IOException IOException */ private void saveConfig(String path, TreeSet plugins) throws FactoryConfigurationError, ParserConfigurationException, IOException { String PUBLIC_ID = "-//Apache Software Foundation//" + "DTD Struts Configuration 1.1//EN"; String SYSTEM_ID = "http://jakarta.apache.org/struts/" + "dtds/struts-config_1_1.dtd"; String I_SUBSET = ""; //- DocumentBuilderFactory domFactory = null; DocumentBuilder domBuilder = null; domFactory = DocumentBuilderFactory.newInstance(); domBuilder = domFactory.newDocumentBuilder(); Document doc = domBuilder.newDocument(); //create and append root element Element root = doc.createElement(ROOT); doc.appendChild(root); Iterator i = plugins.iterator(); //cycle over plugins while (i.hasNext()) { //create plugin tags with className attribute PluginWrapper plw = (PluginWrapper) i.next(); Element plugin = doc.createElement(PLUGIN); plugin.setAttribute(NAME, plw.getName()); root.appendChild(plugin); Iterator j = plw.getProperties().iterator(); while (j.hasNext()) { //create set-property with attributes PropertyWrapper prw = (PropertyWrapper) j.next(); Element prop = doc.createElement(SET_PROP); prop.setAttribute(PROP, prw.getKey()); prop.setAttribute(VAL, prw.getValue()); plugin.appendChild(prop); } } //save that doc! BufferedWriter bufferWriter = new BufferedWriter(new FileWriter(path)); XmlDocument xDoc = (XmlDocument) doc; xDoc.setDoctype(PUBLIC_ID, SYSTEM_ID, I_SUBSET); xDoc.write(bufferWriter); bufferWriter.close(); } /** * wrapper for plugins */ public class PluginWrapper implements Comparable { /** * description of the pluggins, should always be the same as the value * of the "description" property */ private String desc; /** * className attribute value */ private String name; /** * set-property values */ private TreeSet props; /** * whether to show it or not... this needs some investigation, * i dont know if this is still used */ private boolean show; /** * constructor * @param name className * @param desc description * @param props properties * @param show display? */ public PluginWrapper(String name, String desc, TreeSet props, boolean show) { this.name = name; this.desc = desc; this.props = props; this.show = show; } /** * return description * @return description */ public String getDescription() { return this.desc; } /** * return classname * @return name */ public String getName() { return this.name; } /** * return properties * @return properties */ public TreeSet getProperties() { return this.props; } /** * return show (it must go on!) * @return display? */ public boolean getShow() { return this.show; } /** * implemented to achieve automatic sorting within treesets * @return compare value * @param obj object to compare to */ public int compareTo(Object obj) { return -((PluginWrapper) obj).name.compareTo(this.name); } } /** * wrapper for pluginproperties */ public class PropertyWrapper implements Comparable { /** * key */ private String key; /** * vvalue */ private String value; /** * constructor * @param key key * @param value value */ public PropertyWrapper(String key, String value) { this.key = key; this.value = value; } /** * return key * @return key */ public String getKey() { return this.key; } /** * return value * @return value */ public String getValue() { return this.value; } /** * implemented to achieve automatic sorting within treesets * @return compare value * @param obj object to compare to */ public int compareTo(Object obj) { return -((PropertyWrapper) obj).key.compareTo(this.key); } } } |
From: Marcus <the...@us...> - 2004-03-26 07:19:22
|
Update of /cvsroot/junk/junk/WEB-INF/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16200 Added Files: xalan.jar crimson.jar Log Message: initial import --- NEW FILE: crimson.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: xalan.jar --- (This appears to be a binary file; contents omitted.) |
From: Tyron E. <ty...@us...> - 2004-03-25 15:45:41
|
Update of /cvsroot/junk/junk/WEB-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26939 Modified Files: junk-config.xml Log Message: Index: junk-config.xml =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/junk-config.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** junk-config.xml 25 Mar 2004 15:06:30 -0000 1.6 --- junk-config.xml 25 Mar 2004 15:34:51 -0000 1.7 *************** *** 19,23 **** </plug-in> <plug-in className="junk.plugin.spider.SpiderPlugin"> ! <set-property property="configarable" value="true" /> <set-property property="scan-interval" value="10000" /> <set-property property="description" value="Spider Plugin" /> --- 19,23 ---- </plug-in> <plug-in className="junk.plugin.spider.SpiderPlugin"> ! <set-property property="configurable" value="true" /> <set-property property="scan-interval" value="10000" /> <set-property property="description" value="Spider Plugin" /> |
From: Marcus <the...@us...> - 2004-03-25 15:38:11
|
Update of /cvsroot/junk/junk/WEB-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25567 Modified Files: struts-config.xml Log Message: config form Index: struts-config.xml =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/struts-config.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** struts-config.xml 23 Mar 2004 15:03:21 -0000 1.6 --- struts-config.xml 25 Mar 2004 15:27:22 -0000 1.7 *************** *** 29,41 **** <form-property name="message" type="java.lang.String" /> </form-bean> ! ! <form-bean name="configForm" type="org.apache.struts.action.DynaActionForm"> ! <form-property name="scanInterval" type="java.lang.Long"/> ! <form-property name="threadSleep" type="java.lang.Long"/> ! <form-property name="ipRange" type="java.lang.String"/> ! <form-property name="tcpTimeout" type="java.lang.Integer"/> ! <form-property name="mapSaveFile" type="java.lang.String"/> ! </form-bean> ! </form-beans> --- 29,37 ---- <form-property name="message" type="java.lang.String" /> </form-bean> ! ! <form-bean name="configForm" type="junk.util.ConfigurationForm"> ! <form-property name="value" type="java.util.HashMap" /> ! </form-bean> ! </form-beans> *************** *** 53,57 **** <forward name="search" path="/Search.do" /> <forward name="error" path="/Error.jsp" /> ! <forward name="config" path="/Config.do" /> </global-forwards> --- 49,53 ---- <forward name="search" path="/Search.do" /> <forward name="error" path="/Error.jsp" /> ! <!-- <forward name="config" path="/Config.do" />--> </global-forwards> *************** *** 71,76 **** scope="request" validate="true" ! input="/pages/admin/Config.jsp"> ! <forward name="config" path="/pages/admin/Config.jsp" /> </action> --- 67,72 ---- scope="request" validate="true" ! input="/pages/Config.jsp"> ! <forward name="config" path="/pages/Config.jsp" /> </action> |
From: Marcus <the...@us...> - 2004-03-25 15:36:22
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25193 Modified Files: ScannerPlugin.java Log Message: export of scanning state Index: ScannerPlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerPlugin.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ScannerPlugin.java 24 Mar 2004 15:57:55 -0000 1.8 --- ScannerPlugin.java 25 Mar 2004 15:25:34 -0000 1.9 *************** *** 75,78 **** --- 75,81 ---- public static final String KEY_SCANNER_CONFIG = "scanner-config"; + /** the key under which the scanning status is saved in the servlet context */ + public static final String KEY_SCANNER_RUNNING = "scanner-running"; + /** version */ private static final String VERSION = "v0.1"; *************** *** 135,139 **** public void init(ActionServlet a, ModuleConfig m) throws ServletException { ! this.actionServlet = a; try { --- 138,142 ---- public void init(ActionServlet a, ModuleConfig m) throws ServletException { ! this.actionServlet = a; try { *************** *** 190,194 **** * not sure if i need this anyway... * @param conf fnoc ! */ protected void setConf(ScannerConfig conf) { this.conf = conf; --- 193,197 ---- * not sure if i need this anyway... * @param conf fnoc ! */ protected void setConf(ScannerConfig conf) { this.conf = conf; *************** *** 332,335 **** --- 335,340 ---- this.isScanning = true; //set the semaphore + this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_RUNNING, + new Boolean(this.isScanning)); //get the old hostmap *************** *** 379,382 **** --- 384,389 ---- this.isScanning = false; + this.actionServlet.getServletContext().setAttribute(ScannerPlugin.KEY_SCANNER_RUNNING, + new Boolean(this.isScanning)); return true; |
From: Tyron E. <ty...@us...> - 2004-03-25 15:19:34
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/controller In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20813 Modified Files: SearchAction.java Log Message: Works with new datasource plugin instead of dscp Index: SearchAction.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/controller/SearchAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SearchAction.java 18 Nov 2003 19:14:30 -0000 1.4 --- SearchAction.java 25 Mar 2004 15:08:45 -0000 1.5 *************** *** 41,45 **** import org.apache.struts.action.*; import org.apache.struts.util.*; ! /** Action Class takes care of processing search requests. --- 41,45 ---- import org.apache.struts.action.*; import org.apache.struts.util.*; ! import junk.plugin.database.*; /** Action Class takes care of processing search requests. *************** *** 130,134 **** // Get a Connection from the DatasourceConnectionPool dataSource = getDataSource(httpServletRequest); ! myConnection = dataSource.getConnection(); // Start search via DBNetFiles DB - Helper Class --- 130,136 ---- // Get a Connection from the DatasourceConnectionPool dataSource = getDataSource(httpServletRequest); ! ! myConnection = ((ConnectionProvider)getServlet().getServletContext().getAttribute(DatabasePlugin.KEY_DATABASE_CON)).getConnection(); ! // myConnection = dataSource.getConnection(); // Start search via DBNetFiles DB - Helper Class |
From: Tyron E. <ty...@us...> - 2004-03-25 15:17:19
|
Update of /cvsroot/junk/junk/WEB-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20249 Modified Files: junk-config.xml Log Message: Added Spider Plugin properties Index: junk-config.xml =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/junk-config.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** junk-config.xml 24 Mar 2004 20:54:16 -0000 1.5 --- junk-config.xml 25 Mar 2004 15:06:30 -0000 1.6 *************** *** 17,20 **** --- 17,26 ---- <set-property property="tcp-timeout" value="100" /><!-- 100 ms --> <set-property property="map-save-file" value="data/hostmap" /><!-- relative to context root, directory has to exist! --> + </plug-in> + <plug-in className="junk.plugin.spider.SpiderPlugin"> + <set-property property="configarable" value="true" /> + <set-property property="scan-interval" value="10000" /> + <set-property property="description" value="Spider Plugin" /> + <set-property property="max-spiders" value="10" /> </plug-in> </struts-config> \ No newline at end of file |
From: Tyron E. <ty...@us...> - 2004-03-24 21:04:56
|
Update of /cvsroot/junk/junk/WEB-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26966 Modified Files: junk-config.xml Log Message: DatasourceConnection Pool replaced by own DB-Plugin Conf Index: junk-config.xml =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/junk-config.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** junk-config.xml 24 Mar 2004 20:50:06 -0000 1.4 --- junk-config.xml 24 Mar 2004 20:54:16 -0000 1.5 *************** *** 1,19 **** <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> - <data-sources> - <data-source> - <set-property property="url" value="jdbc:mysql://10.0.80.5/smbsearch" /> <!-- change this to your db connect string --> - <set-property property="user" value="reader" /> <!-- change this to your db user --> - <set-property property="password" value="reader" /> <!--change this to your db password --> - <set-property property="autoCommit" value="false" /> - <set-property property="description" value="Shodan Mysql Datasource Configuration" /> - <set-property property="driverClass" value="org.gjt.mm.mysql.Driver" /> - <set-property property="maxCount" value="4" /> - <set-property property="minCount" value="2" /> - </data-source> - </data-sources> <plug-in className="junk.plugin.database.DatabasePlugin"> <set-property property="configurable" value="true" /> ! <set-property property="url" value="jdbc:mysql://10.0.80.5/smbsearch?autoReconnect=true" /> <!-- change this to your db connect string --> <set-property property="user" value="reader" /> <!-- change this to your db user --> <set-property property="password" value="reader" /> <!--change this to your db password --> --- 1,7 ---- <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <plug-in className="junk.plugin.database.DatabasePlugin"> <set-property property="configurable" value="true" /> ! <set-property property="url" value="jdbc:mysql://10.0.80.5/smbsearch" /> <!-- change this to your db connect string --> <set-property property="user" value="reader" /> <!-- change this to your db user --> <set-property property="password" value="reader" /> <!--change this to your db password --> |
From: Marcus <the...@us...> - 2004-03-24 21:00:47
|
Update of /cvsroot/junk/junk/WEB-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25948 Modified Files: junk-config.xml Log Message: config additions Index: junk-config.xml =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/junk-config.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** junk-config.xml 24 Mar 2004 15:53:27 -0000 1.3 --- junk-config.xml 24 Mar 2004 20:50:06 -0000 1.4 *************** *** 14,17 **** --- 14,18 ---- </data-sources> <plug-in className="junk.plugin.database.DatabasePlugin"> + <set-property property="configurable" value="true" /> <set-property property="url" value="jdbc:mysql://10.0.80.5/smbsearch?autoReconnect=true" /> <!-- change this to your db connect string --> <set-property property="user" value="reader" /> <!-- change this to your db user --> *************** *** 21,29 **** </plug-in> <plug-in className="junk.plugin.scanner.ScannerPlugin"> ! <set-property property="scan-interval" value="300000" /><!--5 minutes --> ! <set-property property="thread-sleep" value="10000" /><!--10 seconds--> ! <set-property property="ip-range" value="10.0.80.0/24" /><!-- a.b.c.d/s,e.f.g.h/t --> ! <set-property property="tcp-timeout" value="100" /><!-- 100 ms --> ! <set-property property="map-save-file" value="data/hostmap" /><!-- relative to context root, directory has to exist! --> </plug-in> </struts-config> \ No newline at end of file --- 22,32 ---- </plug-in> <plug-in className="junk.plugin.scanner.ScannerPlugin"> ! <set-property property="configurable" value="true" /> ! <set-property property="description" value="Scanner Plugin" /> ! <set-property property="scan-interval" value="300000" /><!--5 minutes --> ! <set-property property="thread-sleep" value="10000" /><!--10 seconds--> ! <set-property property="ip-range" value="10.0.80.0/24" /><!-- a.b.c.d/s,e.f.g.h/t --> ! <set-property property="tcp-timeout" value="100" /><!-- 100 ms --> ! <set-property property="map-save-file" value="data/hostmap" /><!-- relative to context root, directory has to exist! --> </plug-in> </struts-config> \ No newline at end of file |
From: Marcus <the...@us...> - 2004-03-24 16:10:15
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26090 Added Files: PluginTools.java Log Message: initial import --- NEW FILE: PluginTools.java --- /* * 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). * * junk is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * junk is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with junk; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package junk.plugin; import java.util.HashMap; import org.apache.struts.config.ModuleConfig; import org.apache.struts.config.PlugInConfig; /** * static tools for handling plugins */ public class PluginTools { /** Creates a new instance of PluginTools */ public PluginTools() { } /** * get a pluginconfig * @param plugin the plugin to get the config for * @param m the moduleconfig passed to the plugin * @return the config for <code>plugin</code> */ public static HashMap getPluginConfig(Class plugin, ModuleConfig m) { 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(plugin.getName())) { return (HashMap) pluginConfigs[x].getProperties(); } } //if there is no pluginconfig for the specified plugin, throw iae throw new IllegalArgumentException("plugin config not found"); } } |
From: Marcus <the...@us...> - 2004-03-24 16:08:36
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25675 Modified Files: ScannerConfig.java ScannerPlugin.java Log Message: improvements Index: ScannerConfig.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerConfig.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScannerConfig.java 22 Mar 2004 13:27:08 -0000 1.5 --- ScannerConfig.java 24 Mar 2004 15:57:55 -0000 1.6 *************** *** 104,123 **** 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"); --- 104,108 ---- protected ScannerConfig(ActionServlet a, ModuleConfig m) throws IllegalArgumentException { ! HashMap conf = junk.plugin.PluginTools.getPluginConfig(ScannerPlugin.class, m); String path = a.getServletContext().getRealPath("/WEB-INF"); Index: ScannerPlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerPlugin.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ScannerPlugin.java 22 Mar 2004 13:27:08 -0000 1.7 --- ScannerPlugin.java 24 Mar 2004 15:57:55 -0000 1.8 *************** *** 32,37 **** --- 32,39 ---- import junk.util.NameOnline; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; *************** *** 61,65 **** */ public class ScannerPlugin implements PlugIn, Runnable { ! /** @deprecated use KEY_HOSTS_MAP */ public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; --- 63,70 ---- */ public class ScannerPlugin implements PlugIn, Runnable { ! /** ! * deprecated ! * @deprecated use KEY_HOSTS_MAP ! */ public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; *************** *** 130,134 **** public void init(ActionServlet a, ModuleConfig m) throws ServletException { ! this.actionServlet = a; try { --- 135,139 ---- public void init(ActionServlet a, ModuleConfig m) throws ServletException { ! this.actionServlet = a; try { *************** *** 182,185 **** --- 187,194 ---- } + /** + * not sure if i need this anyway... + * @param conf fnoc + */ protected void setConf(ScannerConfig conf) { this.conf = conf; *************** *** 234,238 **** } ! /** load an deserialize the hostmap. * @return loaded map */ --- 243,247 ---- } ! /** load and deserialize the hostmap. * @return loaded map */ *************** *** 240,254 **** String path = this.conf.getSaveMapPath(); HostMap h = null; try { ! FileInputStream f = new FileInputStream(path); ! ObjectInputStream o = new ObjectInputStream(f); h = (HostMap) o.readObject(); ! o.close(); ! f.close(); ! 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,283 ---- String path = this.conf.getSaveMapPath(); HostMap h = null; + FileInputStream f = null; + ObjectInputStream o = null; try { ! f = new FileInputStream(path); ! o = new ObjectInputStream(f); h = (HostMap) o.readObject(); ! log.info("Persistent data map loaded (" + path + ")"); ! } catch (IOException e1) { ! log.info("Failed to load persistent data map. " ! + "This should only happen once. ( " + e1.getMessage() + ")"); ! } catch (Exception ex) { ! log.warn("Error loading persistent data map. " ! + "This is not critical, but should not happen.", ex); ! } finally { ! if (h == null) { ! h = populateMap(); //if there is no data, populate map ! } ! ! try { //cleanup. don't care if this fails. ! ! if (o != null) { ! o.close(); ! } ! ! if (f != null) { ! f.close(); ! } ! } catch (IOException e11) { ! ; ! } } *************** *** 289,300 **** 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() { --- 318,328 ---- log.info("Hostmap saved (" + path + ")"); } catch (Exception e) { ! log.warn("Could not save hostmap (" + path + ")", e); } } ! /** ! * scans the net. * @return <CODE>true</CODE> if the scan was performed. */ private synchronized boolean scan() { |