forked from I2P_Developers/i2p.i2p
Util: Switch users of net.minidev.json to com.json.simple
Tested with bundled 1.1.1 and Debian/Ubuntu 2.3.0
This commit is contained in:
@ -30,9 +30,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
import edu.internet2.ndt.Tcpbw100;
|
import edu.internet2.ndt.Tcpbw100;
|
||||||
|
|
||||||
import net.minidev.json.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import net.minidev.json.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import net.minidev.json.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
@ -136,9 +136,10 @@ public class MLabRunner {
|
|||||||
int code = eepget.getStatusCode();
|
int code = eepget.getStatusCode();
|
||||||
if (code != 200)
|
if (code != 200)
|
||||||
throw new IOException("ns fetch failed: " + code);
|
throw new IOException("ns fetch failed: " + code);
|
||||||
JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
|
JSONParser parser = new JSONParser();
|
||||||
byte[] b = baos.toByteArray();
|
byte[] b = baos.toByteArray();
|
||||||
JSONObject map = (JSONObject) parser.parse(b);
|
String s = new String(b, "ISO-8859-1");
|
||||||
|
JSONObject map = (JSONObject) parser.parse(s);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
throw new IOException("no map");
|
throw new IOException("no map");
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package edu.internet2.ndt;
|
package edu.internet2.ndt;
|
||||||
|
|
||||||
import net.minidev.json.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import net.minidev.json.JSONValue;
|
import org.json.simple.JSONValue;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
import gnu.getopt.Getopt;
|
import gnu.getopt.Getopt;
|
||||||
|
|
||||||
import net.minidev.json.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import net.minidev.json.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import net.minidev.json.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
@ -98,7 +98,7 @@ public class DNSOverHTTPS implements EepGet.StatusListener {
|
|||||||
_log = ctx.logManager().getLog(DNSOverHTTPS.class);
|
_log = ctx.logManager().getLog(DNSOverHTTPS.class);
|
||||||
state = sslState;
|
state = sslState;
|
||||||
baos = new ByteArrayOutputStream(512);
|
baos = new ByteArrayOutputStream(512);
|
||||||
parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
|
parser = new JSONParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Type { V4_ONLY, V6_ONLY, V4_PREFERRED, V6_PREFERRED }
|
public enum Type { V4_ONLY, V6_ONLY, V4_PREFERRED, V6_PREFERRED }
|
||||||
@ -255,12 +255,13 @@ public class DNSOverHTTPS implements EepGet.StatusListener {
|
|||||||
log("Got response in " + (end - fetchStart) + "ms");
|
log("Got response in " + (end - fetchStart) + "ms");
|
||||||
byte[] b = baos.toByteArray();
|
byte[] b = baos.toByteArray();
|
||||||
try {
|
try {
|
||||||
JSONObject map = (JSONObject) parser.parse(b);
|
String s = new String(b, "ISO-8859-1");
|
||||||
|
JSONObject map = (JSONObject) parser.parse(s);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
log("No map");
|
log("No map");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Integer status = (Integer) map.get("Status");
|
Number status = (Number) map.get("Status");
|
||||||
if (status == null || status.intValue() != 0) {
|
if (status == null || status.intValue() != 0) {
|
||||||
log("Bad status: " + status);
|
log("Bad status: " + status);
|
||||||
return null;
|
return null;
|
||||||
@ -280,7 +281,7 @@ public class DNSOverHTTPS implements EepGet.StatusListener {
|
|||||||
log("no data");
|
log("no data");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Integer typ = (Integer) a.get("type");
|
Number typ = (Number) a.get("type");
|
||||||
if (typ == null)
|
if (typ == null)
|
||||||
continue;
|
continue;
|
||||||
String name = (String) a.get("name");
|
String name = (String) a.get("name");
|
||||||
@ -314,7 +315,7 @@ public class DNSOverHTTPS implements EepGet.StatusListener {
|
|||||||
log("name mismatch: " + name);
|
log("name mismatch: " + name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Integer ttl = (Integer) a.get("TTL");
|
Number ttl = (Number) a.get("TTL");
|
||||||
int ittl = (ttl != null) ? Math.min(ttl.intValue(), MAX_TTL) : 3600;
|
int ittl = (ttl != null) ? Math.min(ttl.intValue(), MAX_TTL) : 3600;
|
||||||
long expires = end + (ittl * 1000L);
|
long expires = end + (ittl * 1000L);
|
||||||
Map<String, Result> cache = isv6 ? v6Cache : v4Cache;
|
Map<String, Result> cache = isv6 ? v6Cache : v4Cache;
|
||||||
|
Reference in New Issue
Block a user