[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionoo/master] Remove version, valid_after, and fresh_until lines from responses.
commit 5f98afeb716d5404d819c430ca842cdcfbc8caba
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon Mar 5 08:11:06 2012 +0100
Remove version, valid_after, and fresh_until lines from responses.
---
src/org/torproject/onionoo/ResourceServlet.java | 28 ++---------
src/org/torproject/onionoo/SummaryDataWriter.java | 10 +---
web/index.html | 56 ---------------------
3 files changed, 6 insertions(+), 88 deletions(-)
diff --git a/src/org/torproject/onionoo/ResourceServlet.java b/src/org/torproject/onionoo/ResourceServlet.java
index 529ed2b..63d0edb 100644
--- a/src/org/torproject/onionoo/ResourceServlet.java
+++ b/src/org/torproject/onionoo/ResourceServlet.java
@@ -28,9 +28,7 @@ public class ResourceServlet extends HttpServlet {
long summaryFileLastModified = 0L;
boolean readSummaryFile = false;
- private String versionLine = null, validAfterLine = null,
- freshUntilLine = null, relaysPublishedLine = null,
- bridgesPublishedLine = null;
+ private String relaysPublishedLine = null, bridgesPublishedLine = null;
private List<String> relayLines = new ArrayList<String>(),
bridgeLines = new ArrayList<String>();
private void readSummaryFile() {
@@ -40,7 +38,6 @@ public class ResourceServlet extends HttpServlet {
return;
}
if (summaryFile.lastModified() > this.summaryFileLastModified) {
- this.versionLine = this.validAfterLine = this.freshUntilLine = null;
this.relayLines.clear();
this.bridgeLines.clear();
try {
@@ -48,14 +45,9 @@ public class ResourceServlet extends HttpServlet {
summaryFile));
String line;
while ((line = br.readLine()) != null) {
- if (line.startsWith("{\"version\":")) {
- this.versionLine = line;
- } else if (line.startsWith("\"valid_after\":")) {
- this.validAfterLine = line;
- } else if (line.startsWith("\"fresh_until\":")) {
- this.freshUntilLine = line;
- } else if (line.startsWith("\"relays_published\":")) {
- this.relaysPublishedLine = line;
+ if (line.contains("\"relays_published\":")) {
+ this.relaysPublishedLine = line.startsWith("{") ? line :
+ "{" + line;
} else if (line.startsWith("\"bridges_published\":")) {
this.bridgesPublishedLine = line;
} else if (line.startsWith("\"relays\":")) {
@@ -129,25 +121,21 @@ public class ResourceServlet extends HttpServlet {
response.setCharacterEncoding("utf-8");
PrintWriter pw = response.getWriter();
if (uri.equals("/" + resourceType + "/all")) {
- this.writeHeader(pw);
pw.print(this.relaysPublishedLine + "\n");
this.writeAllRelays(pw, resourceType);
pw.print(this.bridgesPublishedLine + "\n");
this.writeAllBridges(pw, resourceType);
} else if (uri.equals("/" + resourceType + "/running")) {
- this.writeHeader(pw);
pw.print(this.relaysPublishedLine + "\n");
this.writeRunningRelays(pw, resourceType);
pw.print(this.bridgesPublishedLine + "\n");
this.writeRunningBridges(pw, resourceType);
} else if (uri.equals("/" + resourceType + "/relays")) {
- this.writeHeader(pw);
pw.print(this.relaysPublishedLine + "\n");
this.writeAllRelays(pw, resourceType);
pw.print(this.bridgesPublishedLine + "\n");
this.writeNoBridges(pw);
} else if (uri.equals("/" + resourceType + "/bridges")) {
- this.writeHeader(pw);
pw.print(this.relaysPublishedLine + "\n");
this.writeNoRelays(pw);
pw.print(this.bridgesPublishedLine + "\n");
@@ -155,7 +143,6 @@ public class ResourceServlet extends HttpServlet {
} else if (uri.startsWith("/" + resourceType + "/search/")) {
String searchParameter = this.parseSearchParameter(uri.substring(
("/" + resourceType + "/search/").length()));
- this.writeHeader(pw);
pw.print(this.relaysPublishedLine + "\n");
this.writeMatchingRelays(pw, searchParameter, resourceType);
pw.print(this.bridgesPublishedLine + "\n");
@@ -163,7 +150,6 @@ public class ResourceServlet extends HttpServlet {
} else if (uri.startsWith("/" + resourceType + "/lookup/")) {
Set<String> fingerprintParameters = this.parseFingerprintParameters(
uri.substring(("/" + resourceType + "/lookup/").length()));
- this.writeHeader(pw);
pw.print(this.relaysPublishedLine + "\n");
this.writeRelaysWithFingerprints(pw, fingerprintParameters,
resourceType);
@@ -198,12 +184,6 @@ public class ResourceServlet extends HttpServlet {
return parsedFingerprints;
}
- private void writeHeader(PrintWriter pw) {
- pw.print(this.versionLine + "\n");
- pw.print(this.validAfterLine + "\n");
- pw.print(this.freshUntilLine + "\n");
- }
-
private void writeAllRelays(PrintWriter pw, String resourceType) {
pw.print("\"relays\":[");
int written = 0;
diff --git a/src/org/torproject/onionoo/SummaryDataWriter.java b/src/org/torproject/onionoo/SummaryDataWriter.java
index b731900..55f2f11 100644
--- a/src/org/torproject/onionoo/SummaryDataWriter.java
+++ b/src/org/torproject/onionoo/SummaryDataWriter.java
@@ -40,9 +40,6 @@ public class SummaryDataWriter {
"yyyy-MM-dd HH:mm:ss");
dateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
long now = System.currentTimeMillis();
- String validAfterString = dateTimeFormat.format(now);
- String freshUntilString = dateTimeFormat.format(now
- + 75L * 60L * 1000L);
String relaysPublishedString = dateTimeFormat.format(
this.lastValidAfterMillis);
String bridgesPublishedString = dateTimeFormat.format(
@@ -50,11 +47,8 @@ public class SummaryDataWriter {
this.relaySearchDataFile.getParentFile().mkdirs();
BufferedWriter bw = new BufferedWriter(new FileWriter(
this.relaySearchDataFile));
- bw.write("{\"version\":1,\n"
- + "\"valid_after\":\"" + validAfterString + "\",\n"
- + "\"fresh_until\":\"" + freshUntilString + "\",\n"
- + "\"relays_published\":\"" + relaysPublishedString + "\",\n"
- + "\"relays\":[");
+ bw.write("{\"relays_published\":\"" + relaysPublishedString
+ + "\",\n\"relays\":[");
int written = 0;
for (Node entry : this.currentRelays.values()) {
String nickname = !entry.getNickname().equals("Unnamed") ?
diff --git a/web/index.html b/web/index.html
index 3199ea5..8e5766c 100755
--- a/web/index.html
+++ b/web/index.html
@@ -43,30 +43,6 @@ fingerprints, IP addresses, and running information as well as bridges
with hashed fingerprints and running information.
Summary documents contain the following fields:
<ul>
-<li><b><font color="red">"version":</font></b> Version number of this
-document.
-Deprecated field.
-Deploying a versioning scheme to this service seems like overkill.
-Picking new field names and deprecating fields after one month means a lot
-less maintenance overhead.
-Announced on January 26, will be removed after March 4, 2012.</li>
-<li><b><font color="red">"valid_after":</font></b> UTC timestamp
-(YYYY-MM-DD hh:mm:ss) when the contents of this document were generated.
-Deprecated field.
-This field was a quite broken way to implement caching.
-The current caching approach is to have clients cache documents for five
-minutes.
-A future caching mechanism is going to use HTTP headers.
-Announced on January 26, will be removed after March 4, 2012.</li>
-<li><b><font color="red">"fresh_until":</font></b> UTC timestamp
-(YYYY-MM-DD hh:mm:ss) until when the contents of this document shall be
-considered fresh.
-Deprecated field.
-This field was a quite broken way to implement caching.
-The current caching approach is to have clients cache documents for five
-minutes.
-A future caching mechanism is going to use HTTP headers.
-Announced on January 26, will be removed after March 4, 2012.</li>
<li><b>"relays_published":</b> UTC timestamp (YYYY-MM-DD hh:mm:ss) when
the last contained relay network status consensus started being valid.
Indicates how recent the relay summaries in this document are.
@@ -159,22 +135,6 @@ Detail documents are based on the network statuses published by the Tor
directories and the server descriptors published by relays and bridges.
Detail documents contain the following fields:
<ul>
-<li><b><font color="red">"version":</font></b> Version number of this
-document.
-Deprecated field.
-Deprecated for the same reason as stated for summary documents.
-Announced on January 26, will be removed after March 4, 2012.</li>
-<li><b><font color="red">"valid_after":</font></b> UTC timestamp
-(YYYY-MM-DD hh:mm:ss) when the contents of this document were generated.
-Deprecated field.
-Deprecated for the same reason as stated for summary documents.
-Announced on January 26, will be removed after March 4, 2012.</li>
-<li><b><font color="red">"fresh_until":</font></b> UTC timestamp
-(YYYY-MM-DD hh:mm:ss) until when the contents of this document shall be
-considered fresh.
-Deprecated field.
-Deprecated for the same reason as stated for summary documents.
-Announced on January 26, will be removed after March 4, 2012.</li>
<li><b>"relays_published":</b> UTC timestamp (YYYY-MM-DD hh:mm:ss) when
the last contained relay network status consensus started being valid.
Indicates how recent the relay details in this document are.
@@ -449,22 +409,6 @@ Bandwidth documents are available for all relays and bridges that have
been running in the past week.
Bandwidth documents contain the following fields:
<ul>
-<li><b><font color="red">"version":</font></b> Version number of this
-document.
-Deprecated field.
-Deprecated for the same reason as stated for summary documents.
-Announced on January 26, will be removed after March 4, 2012.</li>
-<li><b><font color="red">"valid_after":</font></b> UTC timestamp
-(YYYY-MM-DD hh:mm:ss) when the contents of this document were generated.
-Deprecated field.
-Deprecated for the same reason as stated for summary documents.
-Announced on January 26, will be removed after March 4, 2012.</li>
-<li><b><font color="red">"fresh_until":</font></b> UTC timestamp
-(YYYY-MM-DD hh:mm:ss) until when the contents of this document shall be
-considered fresh.
-Deprecated field.
-Deprecated for the same reason as stated for summary documents.
-Announced on January 26, will be removed after March 4, 2012.</li>
<li><b>"relays_published":</b> UTC timestamp (YYYY-MM-DD hh:mm:ss) when
the last contained relay network status consensus started being valid.
Indicates how recent the relay bandwidth documents in this document are.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits