From: <the...@us...> - 2003-12-18 19:17:57
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1:/tmp/cvs-serv18335 Modified Files: Scanner.java ScannerPlugin.java Log Message: changed standalone wrapper functionality to "extend" Index: Scanner.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/Scanner.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Scanner.java 16 Dec 2003 10:54:25 -0000 1.4 --- Scanner.java 18 Dec 2003 19:17:54 -0000 1.5 *************** *** 32,39 **** * @author Marcus Proest (theevilflow at users dot sf dot net) */ ! public class Scanner { ! /** the wrapped scannerplugin */ ! private ScannerPlugin scannerPlugin; ! /** Creates a new instance of Scanner * @param iprange Ip Range to scan in the form --- 32,36 ---- * @author Marcus Proest (theevilflow at users dot sf dot net) */ ! public class Scanner extends ScannerPlugin { /** Creates a new instance of Scanner * @param iprange Ip Range to scan in the form *************** *** 42,58 **** */ public Scanner(String iprange, int tcpto) { if (tcpto < 1) { throw new IllegalArgumentException("tcpto has to be > 0"); } ! HashMap conf = new HashMap(5); ! ! conf.put(ScannerConfig.IP_RANGE_KEY, iprange); ! conf.put(ScannerConfig.SAVE_MAP_KEY, ""); ! conf.put(ScannerConfig.SCAN_INTERVAL_KEY, "0"); ! conf.put(ScannerConfig.TCP_TO_KEY, new Integer(tcpto).toString()); ! conf.put(ScannerConfig.THREAD_SLEEP_KEY, "0"); ! scannerPlugin = new ScannerPlugin(new ScannerConfig(conf)); } --- 39,57 ---- */ public Scanner(String iprange, int tcpto) { + if (tcpto < 1) { throw new IllegalArgumentException("tcpto has to be > 0"); } ! HashMap c = new HashMap(5); ! c.put(ScannerConfig.IP_RANGE_KEY, iprange); ! c.put(ScannerConfig.SAVE_MAP_KEY, ""); ! c.put(ScannerConfig.SCAN_INTERVAL_KEY, "0"); ! c.put(ScannerConfig.TCP_TO_KEY, new Integer(tcpto).toString()); ! c.put(ScannerConfig.THREAD_SLEEP_KEY, "0"); ! ! this.setConf(new ScannerConfig(c)); ! } *************** *** 62,66 **** */ public HostMap scan() { ! return scannerPlugin.performScan(); } --- 61,65 ---- */ public HostMap scan() { ! return this.performScan(); } *************** *** 68,81 **** * @param args - */ - /* public static void main(String[] args) { - Scanner s = new Scanner("10.0.80.0/24", 100); - junk.util.OnlineIteratorProvider h = s.scan(); - java.util.Iterator i = h.getOnlineIterator(); - int x = 0; ! while (i.hasNext()) { ! x++; ! System.out.println(x + " " + i.next()); ! } ! }*/ } --- 67,80 ---- * @param args - */ ! public static void main(String[] args) { ! Scanner s = new Scanner("10.0.80.0/24", 100); ! junk.util.HostIteratorProvider h = s.scan(); ! java.util.Iterator i = h.getOnlineIpStringIterator(); ! int x = 0; ! while (i.hasNext()) { ! x++; ! System.out.println(x + " " + i.next()); ! } ! } } Index: ScannerPlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerPlugin.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScannerPlugin.java 18 Dec 2003 15:28:40 -0000 1.5 --- ScannerPlugin.java 18 Dec 2003 19:17:54 -0000 1.6 *************** *** 116,120 **** * @throws ServletException ServletException */ ! public void init(ActionServlet a, ModuleConfig m) throws ServletException { this.actionServlet = a; --- 116,121 ---- * @throws ServletException ServletException */ ! public void init(ActionServlet a, ModuleConfig m) ! throws ServletException { this.actionServlet = a; *************** *** 381,384 **** --- 382,389 ---- return h; + } + + protected void setConf(ScannerConfig conf) { + this.conf = conf; } } |