forked from I2P_Developers/i2p.i2p
Util: Improve LookupDest CLI, add to CommandLine
This commit is contained in:
@@ -30,8 +30,9 @@ import net.i2p.data.Hash;
|
|||||||
* Using an existing I2PSession is much more efficient and
|
* Using an existing I2PSession is much more efficient and
|
||||||
* flexible than using this class.
|
* flexible than using this class.
|
||||||
*
|
*
|
||||||
|
* Public since 0.9.45 only for main(). Not a public API.
|
||||||
*/
|
*/
|
||||||
class LookupDest {
|
public class LookupDest {
|
||||||
|
|
||||||
private static final long DEFAULT_TIMEOUT = 15*1000;
|
private static final long DEFAULT_TIMEOUT = 15*1000;
|
||||||
|
|
||||||
@@ -120,11 +121,34 @@ class LookupDest {
|
|||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String args[]) throws I2PSessionException {
|
/**
|
||||||
Destination dest = lookupBase32Hash(I2PAppContext.getGlobalContext(), args[0]);
|
* TODO: does not support hostnames, extended b32, I2CP options...
|
||||||
if (dest == null)
|
*/
|
||||||
System.out.println("Destination not found!");
|
public static void main(String args[]) {
|
||||||
else
|
if (args.length != 1) {
|
||||||
System.out.println(dest.toBase64());
|
System.err.println("Usage: LookupDest base32");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
String arg = args[0];
|
||||||
|
if (arg.endsWith(".b32.i2p"))
|
||||||
|
arg = arg.substring(0, arg.length() - 8);
|
||||||
|
if (arg.length() != 52) {
|
||||||
|
System.err.println("Bad Base32 format");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
byte[] h = Base32.decode(arg);
|
||||||
|
if (h == null) {
|
||||||
|
System.err.println("Bad Base32 format");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Destination dest = lookupHash(I2PAppContext.getGlobalContext(), h);
|
||||||
|
if (dest == null)
|
||||||
|
System.err.println("Destination not found!");
|
||||||
|
else
|
||||||
|
System.out.println(dest.toBase64());
|
||||||
|
} catch (I2PSessionException ise) {
|
||||||
|
ise.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class CommandLine {
|
|||||||
protected static final List<String> CLASSES = Arrays.asList(new String[] {
|
protected static final List<String> CLASSES = Arrays.asList(new String[] {
|
||||||
"freenet.support.CPUInformation.CPUID",
|
"freenet.support.CPUInformation.CPUID",
|
||||||
"net.i2p.CoreVersion",
|
"net.i2p.CoreVersion",
|
||||||
|
"net.i2p.client.naming.LookupDest",
|
||||||
"net.i2p.crypto.Blinding",
|
"net.i2p.crypto.Blinding",
|
||||||
"net.i2p.crypto.CertUtil",
|
"net.i2p.crypto.CertUtil",
|
||||||
"net.i2p.crypto.CryptoCheck",
|
"net.i2p.crypto.CryptoCheck",
|
||||||
|
|||||||
Reference in New Issue
Block a user