I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 8ed280eb authored by zzz's avatar zzz
Browse files

* RouterInfo: Exit 1 on error in main()

parent 762e96b8
No related branches found
No related tags found
No related merge requests found
...@@ -637,7 +637,8 @@ public class RouterInfo extends DatabaseEntry { ...@@ -637,7 +637,8 @@ public class RouterInfo extends DatabaseEntry {
} }
/** /**
* Print out routerinfos from files specified on the command line * Print out routerinfos from files specified on the command line.
* Exits 1 if any RI is invalid, fails signature, etc.
* @since 0.8 * @since 0.8
*/ */
public static void main(String[] args) { public static void main(String[] args) {
...@@ -645,23 +646,29 @@ public class RouterInfo extends DatabaseEntry { ...@@ -645,23 +646,29 @@ public class RouterInfo extends DatabaseEntry {
System.err.println("Usage: RouterInfo file ..."); System.err.println("Usage: RouterInfo file ...");
System.exit(1); System.exit(1);
} }
boolean fail = false;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
RouterInfo ri = new RouterInfo(); RouterInfo ri = new RouterInfo();
InputStream is = null; InputStream is = null;
try { try {
is = new java.io.FileInputStream(args[i]); is = new java.io.FileInputStream(args[i]);
ri.readBytes(is); ri.readBytes(is);
if (ri.isValid()) if (ri.isValid()) {
System.out.println(ri.toString()); System.out.println(ri.toString());
else } else {
System.err.println("Router info " + args[i] + " is invalid"); System.err.println("Router info " + args[i] + " is invalid");
fail = true;
}
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error reading " + args[i] + ": " + e); System.err.println("Error reading " + args[i] + ": " + e);
fail = true;
} finally { } finally {
if (is != null) { if (is != null) {
try { is.close(); } catch (IOException ioe) {} try { is.close(); } catch (IOException ioe) {}
} }
} }
} }
if (fail)
System.exit(1);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment