summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-08-25 20:33:17 +0000
committerNick Mathewson <nickm@torproject.org>2005-08-25 20:33:17 +0000
commit54a6a8f0ef2695423ce5e3e1583c97786a2449a5 (patch)
treed3b822efd1e52fc171cbc8d11a13b31e20339c31 /src/or/directory.c
parentf0893ddc8c6372b67200dad5ff4cc16fbe2ecc69 (diff)
downloadtor-54a6a8f0ef2695423ce5e3e1583c97786a2449a5.tar.gz
tor-54a6a8f0ef2695423ce5e3e1583c97786a2449a5.zip
Start implementing the server side of the new directory protocol.
Probably very buggy, since I can't actually run an authdir. Features - Generate and publish new network-status format - Code to cache and re-serve network-status objects generated by others. - Publish individual descriptors (by fingerprint, by "all", and by "tell me yours.") [Still needs compression logic] - Publish client and server recommended versions seprately. - Add digest of descriptor to routerinfo_t, so we can track them better, and length, so we can server them more easily. Cleanups - Unify code to sign directory-like things - Make resolve_my_address() able to tell you which name it wound up resolving. - Unify code to store and serve directory-like things so it all uses cached_dir_t. - Unify code to set the value of cached_dir_t objects. svn:r4835
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index a20e94f7c5..740dc1ba0d 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1057,6 +1057,60 @@ directory_handle_command_get(connection_t *conn, char *headers,
return 0;
}
+ if (!strcmpstart(url,"/tor/status/")) {
+ /* v2 network status fetch. */
+ size_t url_len = strlen(url);
+ int deflated = !strcmp(url+url_len-2, ".z");
+ const char *key = url + strlen("/tor/status/");
+ if (deflated)
+ url[url_len-2] = '\0';
+ dlen = dirserv_get_networkstatus_v2(&cp, key, deflated);
+ tor_free(url);
+ if (!dlen) { /* we failed to create/cache cp */
+ write_http_status_line(conn, 503, "Network status object unavailable");
+ /* try to get a new one now */
+ // XXXX NM
+ return 0;
+ }
+ format_rfc1123_time(date, time(NULL));
+ tor_snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nDate: %s\r\nContent-Length: %d\r\nContent-Type: text/plain\r\nContent-Encoding: %s\r\n\r\n",
+ date,
+ (int)dlen,
+ deflated?"deflate":"identity");
+ connection_write_to_buf(tmp, strlen(tmp), conn);
+ connection_write_to_buf(cp, strlen(cp), conn);
+ return 0;
+ }
+
+ if (!strcmpstart(url,"/tor/server/")) {
+ size_t url_len = strlen(url);
+ int deflated = !strcmp(url+url_len-2, ".z");
+ smartlist_t *descs = smartlist_create();
+ if (deflated)
+ url[url_len-2] = '\0';
+ dirserv_get_routerdescs(descs, url);
+ tor_free(url);
+ if (!smartlist_len(descs)) {
+ write_http_status_line(conn, 400, "Servers unavailable.");
+ } else {
+ size_t len = 0;
+ format_rfc1123_time(date, time(NULL));
+ SMARTLIST_FOREACH(descs, routerinfo_t *, ri,
+ len += ri->signed_descriptor_len);
+ /* XXXX We need to support deflate here. */
+ tor_snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nDate: %s\r\nContent-Length: %d\r\nContent-Type: application/octet-stream\r\n\r\n",
+ date,
+ (int)len);
+ connection_write_to_buf(tmp, strlen(tmp), conn);
+ SMARTLIST_FOREACH(descs, routerinfo_t *, ri,
+ connection_write_to_buf(ri->signed_descriptor,
+ ri->signed_descriptor_len,
+ conn));
+ }
+ smartlist_free(descs);
+ return 0;
+ }
+
if (!strcmpstart(url,"/tor/rendezvous/") ||
!strcmpstart(url,"/tor/rendezvous1/")) {
/* rendezvous descriptor fetch */