[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [onionoo/master] Clean up previous commit a bit.



commit 9aede3cccb380052bee988e19d435fa71ce4567c
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Thu Jun 14 16:55:38 2012 +0200

    Clean up previous commit a bit.
---
 src/org/torproject/onionoo/CurrentNodes.java    |    6 +++---
 src/org/torproject/onionoo/Main.java            |    4 +++-
 src/org/torproject/onionoo/ResourceServlet.java |    9 +++++----
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/org/torproject/onionoo/CurrentNodes.java b/src/org/torproject/onionoo/CurrentNodes.java
index 7ed16a8..74879af 100644
--- a/src/org/torproject/onionoo/CurrentNodes.java
+++ b/src/org/torproject/onionoo/CurrentNodes.java
@@ -35,11 +35,11 @@ import com.maxmind.geoip.regionName;
  * days. */
 public class CurrentNodes {
 
-  private File internalRelaySearchDataFile =
-      new File("status/summary.csv");
+  private File internalRelaySearchDataFile;
 
   /* Read the internal relay search data file from disk. */
-  public void readRelaySearchDataFile() {
+  public void readRelaySearchDataFile(File internalRelaySearchDataFile) {
+    this.internalRelaySearchDataFile = internalRelaySearchDataFile;
     if (this.internalRelaySearchDataFile.exists() &&
         !this.internalRelaySearchDataFile.isDirectory()) {
       try {
diff --git a/src/org/torproject/onionoo/Main.java b/src/org/torproject/onionoo/Main.java
index edac926..2c906db 100644
--- a/src/org/torproject/onionoo/Main.java
+++ b/src/org/torproject/onionoo/Main.java
@@ -2,13 +2,15 @@
  * See LICENSE for licensing information */
 package org.torproject.onionoo;
 
+import java.io.File;
+
 /* Update search data and status data files. */
 public class Main {
   public static void main(String[] args) {
 
     printStatus("Updating internal node list.");
     CurrentNodes cn = new CurrentNodes();
-    cn.readRelaySearchDataFile();
+    cn.readRelaySearchDataFile(new File("out/summary"));
     cn.readRelayNetworkConsensuses();
     cn.setRelayRunningBits();
     cn.lookUpCountries();
diff --git a/src/org/torproject/onionoo/ResourceServlet.java b/src/org/torproject/onionoo/ResourceServlet.java
index 38ae248..e821500 100644
--- a/src/org/torproject/onionoo/ResourceServlet.java
+++ b/src/org/torproject/onionoo/ResourceServlet.java
@@ -29,13 +29,14 @@ public class ResourceServlet extends HttpServlet {
 
   private static final long serialVersionUID = 7236658979947465319L;
 
-  private File summaryFile = new File("status/summary.csv");
+  private File summaryFile;
 
   private String outDirString;
 
   public void init(ServletConfig config) throws ServletException {
     super.init(config);
     this.outDirString = config.getInitParameter("outDir");
+    this.summaryFile = new File(outDirString, "summary");
     this.readSummaryFile();
   }
 
@@ -53,7 +54,7 @@ public class ResourceServlet extends HttpServlet {
     }
     if (summaryFile.lastModified() > this.summaryFileLastModified) {
       CurrentNodes cn = new CurrentNodes();
-      cn.readRelaySearchDataFile();
+      cn.readRelaySearchDataFile(this.summaryFile);
       SimpleDateFormat dateTimeFormat = new SimpleDateFormat(
           "yyyy-MM-dd HH:mm:ss");
       dateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
@@ -100,7 +101,7 @@ public class ResourceServlet extends HttpServlet {
     String fingerprint = entry.getFingerprint();
     String running = entry.getRunning() ? "true" : "false";
     String address = entry.getAddress();
-    return String.format("\n{%s\"f\":\"%s\",\"a\":[\"%s\"],\"r\":%s}",
+    return String.format("{%s\"f\":\"%s\",\"a\":[\"%s\"],\"r\":%s}",
         (nickname == null ? "" : "\"n\":\"" + nickname + "\","),
         fingerprint, address, running);
   }
@@ -110,7 +111,7 @@ public class ResourceServlet extends HttpServlet {
         entry.getNickname() : null;
     String hashedFingerprint = entry.getFingerprint();
     String running = entry.getRunning() ? "true" : "false";
-    return String.format("\n{%s\"h\":\"%s\",\"r\":%s}",
+    return String.format("{%s\"h\":\"%s\",\"r\":%s}",
          (nickname == null ? "" : "\"n\":\"" + nickname + "\","),
          hashedFingerprint, running);
   }

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits