Update criteria for partial/full IPv6 support.
[tor-metrics-tasks.git] / task-3276 / ParseServerDescriptors.java
blob2810d53db354c20877853759095dd3a9c6d48344
1 import java.io.*;
2 import java.util.*;
3 public class ParseServerDescriptors {
4 public static void main(String[] args) throws Exception {
5 Stack<File> files = new Stack<File>();
6 files.add(new File(args[0]));
7 while (!files.isEmpty()) {
8 File file = files.pop();
9 if (file.isDirectory()) {
10 for (File f : file.listFiles()) {
11 files.add(f);
13 } else {
14 BufferedReader br = new BufferedReader(new FileReader(file));
15 String line, published = null, fingerprint = null;
16 boolean readOnionKey = false;
17 StringBuilder onionKey = new StringBuilder();
18 while ((line = br.readLine()) != null) {
19 if (readOnionKey && !line.startsWith("-----")) {
20 onionKey.append(line);
21 } else if (line.startsWith("published ")) {
22 published = line.substring("published ".length());
23 } else if (line.startsWith("opt fingerprint")) {
24 fingerprint = line.substring("opt fingerprint ".length()).
25 replaceAll(" ", "");
26 } else if (line.equals("onion-key")) {
27 readOnionKey = true;
28 } else if (line.equals("-----END RSA PUBLIC KEY-----")) {
29 readOnionKey = false;
32 br.close();
33 System.out.println(fingerprint + "," + published + ","
34 + onionKey.toString());