aboutsummaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorJacob Appelbaum <jacob@appelbaum.net>2008-12-07 01:21:19 +0000
committerJacob Appelbaum <jacob@appelbaum.net>2008-12-07 01:21:19 +0000
commit6b178b46ef52fc146fee566e9bdd12929d3ad0a3 (patch)
treee1c1a8e6b340573a2395d29c2b37336855cefd46 /src/or/directory.c
parent92562d6e7a57df315698fbdfb9476bcac24bc10e (diff)
downloadtor-6b178b46ef52fc146fee566e9bdd12929d3ad0a3.tar.gz
tor-6b178b46ef52fc146fee566e9bdd12929d3ad0a3.zip
New DirPortFrontPage option that takes an html file and publishes it as "/" on the DirPort. Now relay operators can provide a disclaimer without needin to set up a separate webserver. There's a sample disclaimer in contrib/tor-exit-notice.html.
svn:r17500
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 5bd85bab7c..14470060a0 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -88,6 +88,7 @@ static void directory_initiate_command_rend(const char *address,
* kind of document we serve? */
#define FULL_DIR_CACHE_LIFETIME (60*60)
#define RUNNINGROUTERS_CACHE_LIFETIME (20*60)
+#define DIRPORTFRONTPAGE_CACHE_LIFETIME (20*60)
#define NETWORKSTATUS_CACHE_LIFETIME (5*60)
#define ROUTERDESC_CACHE_LIFETIME (30*60)
#define ROUTERDESC_BY_DIGEST_CACHE_LIFETIME (48*60*60)
@@ -2473,6 +2474,27 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
url_len -= 2;
}
+ if (!strcmp(url,"/tor/")) {
+ const char *frontpage = get_dirportfrontpage();
+
+ if (frontpage) {
+ dlen = strlen(frontpage);
+ /* Lets return a disclaimer, users shouldn't use V1 anymore */
+ if (global_write_bucket_low(TO_CONN(conn), dlen, 1)) {
+ log_info(LD_DIRSERV,
+ "Client asked for DirPortFrontPage content, but we've been "
+ "writing too many bytes lately. Sending 503 Dir busy.");
+ write_http_status_line(conn, 503, "Directory busy, try again later");
+ goto done;
+ }
+ note_request(url, dlen);
+ write_http_response_header_impl(conn, dlen, "text/html", "identity",
+ NULL, DIRPORTFRONTPAGE_CACHE_LIFETIME);
+ connection_write_to_buf(frontpage, dlen, TO_CONN(conn));
+ goto done;
+ }
+ }
+
if (!strcmp(url,"/tor/") || !strcmp(url,"/tor/dir")) { /* v1 dir fetch */
cached_dir_t *d = dirserv_get_directory();