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

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

RKG command line tool multiple args

parent 074c630a
No related branches found
No related tags found
No related merge requests found
...@@ -222,25 +222,31 @@ public class RouterKeyGenerator extends RoutingKeyGenerator { ...@@ -222,25 +222,31 @@ public class RouterKeyGenerator extends RoutingKeyGenerator {
*/ */
public static void main(String args[]) { public static void main(String args[]) {
if (args.length <= 0) { 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); System.exit(1);
} }
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
Hash h; int st = 0;
if (args.length > 1 && (args[0].startsWith("+") || args[0].startsWith("-"))) { if (args.length > 1 && (args[0].startsWith("+") || args[0].startsWith("-"))) {
now += Integer.parseInt(args[0]) * 24*60*60*1000L; now += Integer.parseInt(args[0]) * 24*60*60*1000L;
h = ConvertToHash.getHash(args[1]); st++;
} else {
h = ConvertToHash.getHash(args[0]);
}
if (h == null) {
System.err.println("Bad hash");
System.exit(1);
} }
RouterKeyGenerator rkg = new RouterKeyGenerator(I2PAppContext.getGlobalContext()); RouterKeyGenerator rkg = new RouterKeyGenerator(I2PAppContext.getGlobalContext());
Hash rkey = rkg.getRoutingKey(h, now); System.out.println("Date: " + rkg._fmt.format(now) + '\n' +
System.out.println("Date: " + rkg._fmt.format(now)); "Hash Routing Key\n" +
System.out.println("Original key: " + h.toBase64()); "---- -----------");
System.out.println("Routing key: " + rkey.toBase64()); 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());
}
} }
} }
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