diff --git a/src/main/java/qubo/CLI.java b/src/main/java/qubo/CLI.java index 6a0d58c..66b404f 100644 --- a/src/main/java/qubo/CLI.java +++ b/src/main/java/qubo/CLI.java @@ -73,7 +73,11 @@ private static void standardRun(String[] a) } Info.debugMode = i.isDebugMode(); quboInstance = new QuboInstance(i); - quboInstance.run(); + try{ + quboInstance.run(); + }catch (NumberFormatException e){ + quboInstance.inputData.help(); + } } private static void txtRun() diff --git a/src/main/java/qubo/InputData.java b/src/main/java/qubo/InputData.java index 96390bf..b2762f7 100644 --- a/src/main/java/qubo/InputData.java +++ b/src/main/java/qubo/InputData.java @@ -20,6 +20,8 @@ public class InputData{ private boolean ping; private final String filename; + private Options options; + private Options buildOptions() { Option iprange = new Option("range","iprange",true,"The IP range that qubo will scan"); @@ -79,14 +81,14 @@ private Options buildOptions() return options; } - private void help(Options options){ + public void help(){ HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("-range -ports -th -ti ",options); System.exit(-1); } public InputData(String[] command) throws InvalidRangeException,NumberFormatException { - Options options = buildOptions(); + options = buildOptions(); CommandLineParser parser = new DefaultParser(); String ipStart = "",ipEnd = ""; try @@ -114,7 +116,8 @@ public InputData(String[] command) throws InvalidRangeException,NumberFormatExce } catch (NullPointerException | IndexOutOfBoundsException e) { - throw new InvalidRangeException(); + if(Info.gui) throw new InvalidRangeException(); + else help(); } try @@ -124,12 +127,17 @@ public InputData(String[] command) throws InvalidRangeException,NumberFormatExce catch (IllegalArgumentException e){ throw new IllegalArgumentException(e.getMessage()); } + try{ + portrange = new PortList(cmd.getOptionValue("ports")); + }catch (NumberFormatException e){ + if(Info.gui) throw new NumberFormatException(); + help(); + } - portrange = new PortList(cmd.getOptionValue("ports")); ping = !cmd.hasOption("noping"); } catch (ParseException e) { - help(options); //help contiene system.exit + help(); //help contiene system.exit } if(isOutput()) diff --git a/src/main/java/qubo/gui/InstanceRunnable.java b/src/main/java/qubo/gui/InstanceRunnable.java index 93e6d51..57d9f09 100644 --- a/src/main/java/qubo/gui/InstanceRunnable.java +++ b/src/main/java/qubo/gui/InstanceRunnable.java @@ -25,7 +25,7 @@ public void run() { quboInstance.run(); } catch (NumberFormatException e){ - if(Confirm.requestConfirm("Check input and relaunch program, would you like to see an example configuration?")) + if(Confirm.requestConfirm("Check threads or timeout fields and relaunch program, would you like to see an example configuration?")) window.exampleConf(); } window.idle();