summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-01-05 06:03:10 +0000
committerRoger Dingledine <arma@torproject.org>2007-01-05 06:03:10 +0000
commit658c09c06fdcf32764c9e30aa1e824e6750edca2 (patch)
treedab24e6f955d4ae95ef73412f80ec95c457d6db5 /src/or/directory.c
parent466650aa14459bf6a2553f6c500f41c164b46712 (diff)
downloadtor-658c09c06fdcf32764c9e30aa1e824e6750edca2.tar.gz
tor-658c09c06fdcf32764c9e30aa1e824e6750edca2.zip
more progress and cleanups
svn:r9269
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 5aea7c57d3..470089ae26 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1325,8 +1325,8 @@ connection_dir_process_inbuf(dir_connection_t *conn)
}
if (buf_datalen(conn->_base.inbuf) > MAX_DIRECTORY_OBJECT_SIZE) {
- log_warn(LD_HTTP, "Too much data received from directory connection; "
- "DOS attempt or protocol shift.");
+ log_warn(LD_HTTP, "Too much data received from directory connection: "
+ "denial of service attempt, or you need to upgrade?");
connection_mark_for_close(TO_CONN(conn));
return -1;
}
@@ -1639,6 +1639,16 @@ directory_handle_command_get(dir_connection_t *conn, char *headers,
smartlist_free(dir_fps);
return 0;
}
+ dlen = dirserv_estimate_data_size(conn->fingerprint_stack,
+ 0, deflated);
+ if (global_write_bucket_low(dlen, 2)) {
+ log_info(LD_DIRSERV,
+ "Client asked for server descriptors, but we've been "
+ "writing too many bytes lately. Sending 503 Dir busy.");
+ write_http_status_line(conn, 503, "Directory busy, try again later");
+ return 0;
+ }
+
// note_request(request_type,dlen);
(void) request_type;
write_http_response_header(conn, -1,
@@ -1696,6 +1706,15 @@ directory_handle_command_get(dir_connection_t *conn, char *headers,
if (res < 0)
write_http_status_line(conn, 404, msg);
else {
+ dlen = dirserv_estimate_data_size(conn->fingerprint_stack,
+ 1, deflated);
+ if (global_write_bucket_low(dlen, 2)) {
+ log_info(LD_DIRSERV,
+ "Client asked for server descriptors, but we've been "
+ "writing too many bytes lately. Sending 503 Dir busy.");
+ write_http_status_line(conn, 503, "Directory busy, try again later");
+ return 0;
+ }
write_http_response_header(conn, -1,
deflated?"application/octet_stream":"text/plain",
deflated?"deflate":NULL, cache_lifetime);