[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [metrics-db/master 1/2] Remove the bridge's IP address from reject lines.
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue, 11 Jan 2011 08:59:29 +0100
Subject: Remove the bridge's IP address from reject lines.
Commit: e9d42a8878044a323572d18066170237aa080322
When a bridge is configured to use the default exit policy, it adds a
reject line containing its own IP address which we don't sanitize.
Roughly 2.5 % of bridge descriptors are affected. The fix is to replace
the bridge's IP address in reject lines with "127.0.0.1", too.
---
.../ernie/db/SanitizedBridgesWriter.java | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/org/torproject/ernie/db/SanitizedBridgesWriter.java b/src/org/torproject/ernie/db/SanitizedBridgesWriter.java
index 792c66b..651c5fe 100644
--- a/src/org/torproject/ernie/db/SanitizedBridgesWriter.java
+++ b/src/org/torproject/ernie/db/SanitizedBridgesWriter.java
@@ -343,7 +343,7 @@ public class SanitizedBridgesWriter {
BufferedReader br = new BufferedReader(new StringReader(
new String(data, "US-ASCII")));
StringBuilder scrubbed = new StringBuilder();
- String line = null, hashedBridgeIdentity = null,
+ String line = null, hashedBridgeIdentity = null, address = null,
published = null;
boolean skipCrypto = false;
while ((line = br.readLine()) != null) {
@@ -372,6 +372,7 @@ public class SanitizedBridgesWriter {
* database and replace it with 127.0.0.1 in the scrubbed
* version. */
} else if (line.startsWith("router ")) {
+ address = line.split(" ")[2];
scrubbed = new StringBuilder("router Unnamed 127.0.0.1 "
+ line.split(" ")[3] + " " + line.split(" ")[4] + " "
+ line.split(" ")[5] + "\n");
@@ -416,10 +417,20 @@ public class SanitizedBridgesWriter {
+ mapping.extraInfoDescriptorIdentifier.toUpperCase()
+ "\n");
+ /* Possibly sanitize reject lines if they contain the bridge's own
+ * IP address. */
+ } else if (line.startsWith("reject ")) {
+ if (address != null && line.startsWith("reject " + address)) {
+ scrubbed.append("reject 127.0.0.1"
+ + line.substring("reject ".length() + address.length())
+ + "\n");
+ } else {
+ scrubbed.append(line + "\n");
+ }
+
/* Write the following lines unmodified to the sanitized
* descriptor. */
- } else if (line.startsWith("reject ")
- || line.startsWith("accept ")
+ } else if (line.startsWith("accept ")
|| line.startsWith("platform ")
|| line.startsWith("opt protocols ")
|| line.startsWith("uptime ")
--
1.7.1