From a7492269fb93c836b2eb41743fe1fed86d1d2803 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Sat, 24 Dec 2016 14:24:30 +0000
Subject: [PATCH] RKG command line tool multiple args

---
 .../i2p/data/router/RouterKeyGenerator.java   | 32 +++++++++++--------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/router/java/src/net/i2p/data/router/RouterKeyGenerator.java b/router/java/src/net/i2p/data/router/RouterKeyGenerator.java
index dd5d4312d7..0525a4f372 100644
--- a/router/java/src/net/i2p/data/router/RouterKeyGenerator.java
+++ b/router/java/src/net/i2p/data/router/RouterKeyGenerator.java
@@ -222,25 +222,31 @@ public class RouterKeyGenerator extends RoutingKeyGenerator {
      */
     public static void main(String args[]) {
         if (args.length <= 0) {
-            System.err.println("Usage: RouterKeyGenerator [-days] [+days] hash|hostname|destination");
+            System.err.println("Usage: RouterKeyGenerator [-days] [+days] hash|hostname|destination...");
             System.exit(1);
         }
         long now = System.currentTimeMillis();
-        Hash h;
+        int st = 0;
         if (args.length > 1 && (args[0].startsWith("+") || args[0].startsWith("-"))) {
             now += Integer.parseInt(args[0]) * 24*60*60*1000L;
-            h = ConvertToHash.getHash(args[1]);
-        } else {
-            h = ConvertToHash.getHash(args[0]);
-        }
-        if (h == null) {
-            System.err.println("Bad hash");
-            System.exit(1);
+            st++;
         }
         RouterKeyGenerator rkg = new RouterKeyGenerator(I2PAppContext.getGlobalContext());
-        Hash rkey = rkg.getRoutingKey(h, now);
-        System.out.println("Date:         " + rkg._fmt.format(now));
-        System.out.println("Original key: " + h.toBase64());
-        System.out.println("Routing key:  " + rkey.toBase64());
+        System.out.println("Date: " + rkg._fmt.format(now) + '\n' +
+                           "Hash                                         Routing Key\n" +
+                           "----                                         -----------");
+        for (int i = st; i < args.length; i++) {
+            String s = args[i];
+            String sp = " ";
+            if (s.length() < 44)
+                sp = "                                            ".substring(0, 45 - s.length());
+            Hash h = ConvertToHash.getHash(s);
+            if (h == null) {
+                System.out.println(s + sp + "Bad hash");
+                continue;
+            }
+            Hash rkey = rkg.getRoutingKey(h, now);
+            System.out.println(s + sp + rkey.toBase64());
+        }
     }
 }
-- 
GitLab