[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [exonerator/master] Fix links to IP addresses in same /24.
commit b8dbfe1ac93e6e0594efa6b89b390681cd37cb6b
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon Aug 27 15:39:29 2018 +0200
Fix links to IP addresses in same /24.
Fixes #27266.
---
CHANGELOG.md | 6 ++++++
.../torproject/metrics/exonerator/ExoneraTorServlet.java | 14 +++++++-------
.../metrics/exonerator/ExoneraTorServletTest.java | 2 +-
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dce2f3a..44a3631 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# Changes in version 3.0.1 - 2018-08-??
+
+ * Medium changes
+ - Fix links to IP addresses in same /24.
+
+
# Changes in version 3.0.0 - 2018-08-13
* Major changes
diff --git a/src/main/java/org/torproject/metrics/exonerator/ExoneraTorServlet.java b/src/main/java/org/torproject/metrics/exonerator/ExoneraTorServlet.java
index bd593cc..5909f26 100644
--- a/src/main/java/org/torproject/metrics/exonerator/ExoneraTorServlet.java
+++ b/src/main/java/org/torproject/metrics/exonerator/ExoneraTorServlet.java
@@ -215,7 +215,7 @@ public class ExoneraTorServlet extends HttpServlet {
statusEntries);
} else if (addressesInSameNetwork != null
&& !addressesInSameNetwork.isEmpty()) {
- this.writeSummaryAddressesInSameNetwork(out, rb, relayIp,
+ this.writeSummaryAddressesInSameNetwork(out, rb, requestUrl, relayIp,
requestedDate.asString, langStr, addressesInSameNetwork);
} else {
this.writeSummaryNegative(out, rb, relayIp, requestedDate.asString);
@@ -464,8 +464,8 @@ public class ExoneraTorServlet extends HttpServlet {
}
void writeSummaryAddressesInSameNetwork(PrintWriter out,
- ResourceBundle rb, String relayIp, String timestampStr, String langStr,
- List<String> addressesInSameNetwork) {
+ ResourceBundle rb, String requestUrl, String relayIp, String timestampStr,
+ String langStr, List<String> addressesInSameNetwork) {
Object[][] panelItems = new Object[addressesInSameNetwork.size()][];
for (int i = 0; i < addressesInSameNetwork.size(); i++) {
String addressInSameNetwork = addressesInSameNetwork.get(i);
@@ -473,12 +473,12 @@ public class ExoneraTorServlet extends HttpServlet {
String address;
if (addressInSameNetwork.contains(":")) {
address = addressInSameNetwork.replaceAll("[\\[\\]]", "");
- link = String.format("/?ip=[%s]×tamp=%s&lang=%s",
- address.replaceAll(":", "%3A"), timestampStr, langStr);
+ link = String.format("%s?ip=[%s]×tamp=%s&lang=%s",
+ requestUrl, address.replaceAll(":", "%3A"), timestampStr, langStr);
address = "[" + address + "]";
} else {
- link = String.format("/?ip=%s×tamp=%s&lang=%s",
- addressInSameNetwork, timestampStr, langStr);
+ link = String.format("%s?ip=%s×tamp=%s&lang=%s",
+ requestUrl, addressInSameNetwork, timestampStr, langStr);
address = addressInSameNetwork;
}
panelItems[i] = new Object[] { link, address };
diff --git a/src/test/java/org/torproject/metrics/exonerator/ExoneraTorServletTest.java b/src/test/java/org/torproject/metrics/exonerator/ExoneraTorServletTest.java
index 34dfd42..1ede590 100644
--- a/src/test/java/org/torproject/metrics/exonerator/ExoneraTorServletTest.java
+++ b/src/test/java/org/torproject/metrics/exonerator/ExoneraTorServletTest.java
@@ -49,7 +49,7 @@ public class ExoneraTorServletTest {
for (QueryResponse qr : qrs) {
StringWriter sw = new StringWriter();
es.writeSummaryAddressesInSameNetwork(new PrintWriter(sw), rb,
- qr.queryAddress, qr.queryDate, "en",
+ "http://localhost:8080/", qr.queryAddress, qr.queryDate, "en",
Arrays.asList(qr.nearbyAddresses));
String errorMsg = "Test data:" + QueryResponse.toJson(qr)
+ "\nresult:\n" + sw.toString();
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits