commit df282b4ddc4d89d622d41bf55c1b577229f687b3 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Jul 17 18:22:50 2012 +0200
Stop supporting old-style URLs. --- src/org/torproject/onionoo/ResourceServlet.java | 71 ++++------------------- web/index.html | 6 +- 2 files changed, 14 insertions(+), 63 deletions(-)
diff --git a/src/org/torproject/onionoo/ResourceServlet.java b/src/org/torproject/onionoo/ResourceServlet.java index ba1d434..43c2110 100644 --- a/src/org/torproject/onionoo/ResourceServlet.java +++ b/src/org/torproject/onionoo/ResourceServlet.java @@ -160,21 +160,14 @@ public class ResourceServlet extends HttpServlet { uri = uri.substring("/onionoo".length()); } String resourceType = null; - boolean isOldStyleUri = false; - if (uri.startsWith("/summary/")) { + if (uri.startsWith("/summary") && + !uri.startsWith("/summary/")) { resourceType = "summary"; - isOldStyleUri = true; - } else if (uri.startsWith("/details/")) { + } else if (uri.startsWith("/details") && + !uri.startsWith("/details/")) { resourceType = "details"; - isOldStyleUri = true; - } else if (uri.startsWith("/bandwidth/")) { - resourceType = "bandwidth"; - isOldStyleUri = true; - } else if (uri.startsWith("/summary")) { - resourceType = "summary"; - } else if (uri.startsWith("/details")) { - resourceType = "details"; - } else if (uri.startsWith("/bandwidth")) { + } else if (uri.startsWith("/bandwidth") && + !uri.startsWith("/bandwidth/")) { resourceType = "bandwidth"; } else { response.sendError(HttpServletResponse.SC_BAD_REQUEST); @@ -183,21 +176,11 @@ public class ResourceServlet extends HttpServlet {
/* Extract parameters either from the old-style URI or from request * parameters. */ - Map<String, String> parameterMap; - if (isOldStyleUri) { - parameterMap = this.getParameterMapForOldStyleUri(uri, - resourceType); - if (parameterMap == null) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return; - } - } else { - parameterMap = new HashMap<String, String>(); - for (Object parameterKey : request.getParameterMap().keySet()) { - String[] parameterValues = - request.getParameterValues((String) parameterKey); - parameterMap.put((String) parameterKey, parameterValues[0]); - } + Map<String, String> parameterMap = new HashMap<String, String>(); + for (Object parameterKey : request.getParameterMap().keySet()) { + String[] parameterValues = + request.getParameterValues((String) parameterKey); + parameterMap.put((String) parameterKey, parameterValues[0]); }
/* Make sure that the request doesn't contain any unknown @@ -372,38 +355,6 @@ public class ResourceServlet extends HttpServlet { pw.close(); }
- private Map<String, String> getParameterMapForOldStyleUri(String uri, - String resourceType) { - Map<String, String> result = new HashMap<String, String>(); - if (uri.equals("/" + resourceType + "/all")) { - } else if (uri.equals("/" + resourceType + "/running")) { - result.put("running", "true"); - } else if (uri.equals("/" + resourceType + "/relays")) { - result.put("type", "relays"); - } else if (uri.equals("/" + resourceType + "/bridges")) { - result.put("type", "bridges"); - } else if (uri.startsWith("/" + resourceType + "/search/")) { - String[] searchParameters = this.parseSearchParameters( - uri.substring(("/" + resourceType + "/search/").length())); - if (searchParameters == null || searchParameters.length != 1) { - result = null; - } else { - result.put("search", searchParameters[0]); - } - } else if (uri.startsWith("/" + resourceType + "/lookup/")) { - String fingerprintParameter = this.parseFingerprintParameter( - uri.substring(("/" + resourceType + "/lookup/").length())); - if (fingerprintParameter == null) { - result = null; - } else { - result.put("lookup", fingerprintParameter); - } - } else { - result = null; - } - return result; - } - private static Pattern searchParameterPattern = Pattern.compile("^\$?[0-9a-fA-F]{1,40}$|" /* Fingerprint. */ + "^[0-9a-zA-Z\.]{1,19}$|" /* Nickname or IPv4 address. */ diff --git a/web/index.html b/web/index.html index 5365173..5788bf9 100755 --- a/web/index.html +++ b/web/index.html @@ -91,7 +91,7 @@ document. The method and its parameters determines which relay and/or bridge summaries are included in the response. <font color="red">These methods have been deprecated on May 14, 2012 and -will be removed after July 14, 2012. +have been removed on July 17, 2012. See the Methods section at the end of this page.</font> </p> <table border="0" cellpadding="4" cellspacing="0" summary=""> @@ -338,7 +338,7 @@ document. The method and its parameters determines which relay and/or bridge details are included in the response. <font color="red">These methods have been deprecated on May 14, 2012 and -will be removed after July 14, 2012. +have been removed on July 17, 2012. See the Methods section at the end of this page.</font> </p> <table border="0" cellpadding="4" cellspacing="0" summary=""> @@ -500,7 +500,7 @@ The specification of bandwidth history objects is similar to those in the The method and its parameters determines which relay and/or bridge bandwidth documents are included in the response. <font color="red">These methods have been deprecated on May 14, 2012 and -will be removed after July 14, 2012. +have been removed on July 17, 2012. See the Methods section at the end of this page.</font> </p> <table border="0" cellpadding="4" cellspacing="0" summary="">