Don't fail if extra-info descriptors are missing.

This commit is contained in:
Karsten Loesing 2010-01-19 19:40:56 +01:00
parent 1732539892
commit 77bfec0122

View File

@ -10,20 +10,28 @@ public class ExtraInfoDownloader {
+ authority + "... ");
Stack<String> extraInfos = new Stack<String>();
for (String fingerprint : directories.keySet()) {
BufferedInputStream in = new BufferedInputStream(new URL(
"http://" + authority + "/tor/extra/fp/" + fingerprint).
openStream());
StringBuilder sb = new StringBuilder();
int len;
byte[] data = new byte[1024];
while ((len = in.read(data, 0, 1024)) >= 0) {
sb.append(new String(data, 0, len));
}
in.close();
String extraInfo = sb.toString();
if (extraInfo.length() > 0) {
BufferedReader br = new BufferedReader(new StringReader(extraInfo));
rdp.parse(br);
URL u = new URL("http://" + authority + "/tor/extra/fp/"
+ fingerprint);
HttpURLConnection huc = (HttpURLConnection) u.openConnection();
huc.setRequestMethod("GET");
huc.connect();
int response = huc.getResponseCode();
if (response == 200) {
BufferedInputStream in = new BufferedInputStream(
huc.getInputStream());
StringBuilder sb = new StringBuilder();
int len;
byte[] data = new byte[1024];
while ((len = in.read(data, 0, 1024)) >= 0) {
sb.append(new String(data, 0, len));
}
in.close();
String extraInfo = sb.toString();
if (extraInfo.length() > 0) {
BufferedReader br = new BufferedReader(
new StringReader(extraInfo));
rdp.parse(br);
}
}
}
System.out.println("done");