new deleteHostname() CLI broken
was this reviewed/tested???
+ private static boolean deleteHostname(I2PAppContext ctx, String hostname) {
+ try {
+ Destination dest = lookupHostname(I2PAppContext.getGlobalContext(), hostname);
+ if (dest == null)
+ System.err.println("Destination not found!");
+ else {
+ NamingService ns = I2PAppContext.getGlobalContext().namingService();
+ if (ns != null)
+ return ns.remove(hostname, dest);
+ System.err.print("ns is null");
+ }
+ } catch (I2PSessionException ise) {
+ ise.printStackTrace();
+ }
+ return false;
+ }
- ctx passed in but not used; instead you call getGlobalContext() twice more
+ if (args[0].length() == 2) {
+ if (args[0] == "-d") {
+ deleteHostname(I2PAppContext.getGlobalContext(), args[1]);
+ }
- can't use == instead of String.equals() for comparison, this will fail
- no need for length == 2 check, it's redundant with the string comparison
- there's a fail-out above this for args.length != 1, so this obviously will never work and wasn't tested
- no hint of new option in the Usage println
- no println for success/failure
Also, this whole thing of modifying an addressbook on a running router is ill-advised, will it even work or could it crash the router? Any changes won't be picked up by the router, perhaps there should be a warning not to do this if router is running.