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

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

HostTxtParser: Comment out tests, beginning of a command-line tool

parent be5fdea5
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ import java.util.HashMap; ...@@ -13,6 +13,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import net.i2p.client.naming.HostTxtEntry; import net.i2p.client.naming.HostTxtEntry;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
...@@ -234,7 +235,41 @@ class HostTxtParser { ...@@ -234,7 +235,41 @@ class HostTxtParser {
} }
} }
/**
* Usage: HostTxtParser validate example.i2p=b64dest[#!key1=val1#key2=val2]
*/
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (args.length != 2 || !args[0].equals("validate")) {
System.err.println("Usage: HostTxtParser validate example.i2p=b64dest[#!key1=val1#key2=val2]");
System.exit(1);
}
HostTxtEntry e = parse(args[1].trim(), false);
if (e == null) {
System.err.println("Bad format");
System.exit(1);
}
if (!e.hasValidSig()) {
System.err.println("Bad signature");
System.exit(1);
}
Properties p = e.getProps();
if (p != null) {
if (p.containsKey(HostTxtEntry.PROP_ACTION) ||
p.containsKey(HostTxtEntry.PROP_OLDDEST) ||
p.containsKey(HostTxtEntry.PROP_OLDNAME) ||
p.containsKey(HostTxtEntry.PROP_OLDSIG)) {
if (!e.hasValidSig()) {
System.err.println("Bad inner signature");
System.exit(1);
}
}
}
System.err.println("Good signature for " + e.getName());
System.exit(0);
}
/****
public static void test(String[] args) throws Exception {
File f = new File("tmp-hosts.txt"); File f = new File("tmp-hosts.txt");
Map<String, HostTxtEntry> map = parse(f); Map<String, HostTxtEntry> map = parse(f);
for (HostTxtEntry e : map.values()) { for (HostTxtEntry e : map.values()) {
...@@ -246,5 +281,5 @@ class HostTxtParser { ...@@ -246,5 +281,5 @@ class HostTxtParser {
'\n'); '\n');
} }
} }
****/
} }
...@@ -436,6 +436,7 @@ public class HostTxtEntry { ...@@ -436,6 +436,7 @@ public class HostTxtEntry {
/** /**
* Usage: HostTxtEntry [-i] [-x] [hostname.i2p] [key=val]... * Usage: HostTxtEntry [-i] [-x] [hostname.i2p] [key=val]...
*/ */
/****
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
boolean inner = false; boolean inner = false;
boolean remove = false; boolean remove = false;
...@@ -531,4 +532,5 @@ public class HostTxtEntry { ...@@ -531,4 +532,5 @@ public class HostTxtEntry {
//out.write("Test passed\n"); //out.write("Test passed\n");
//out.flush(); //out.flush();
} }
****/
} }
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