diff options
author | Roger Dingledine <arma@torproject.org> | 2004-03-30 23:41:24 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-03-30 23:41:24 +0000 |
commit | 670aeb6c8d894cb99a809fd7cc4f516cd0e54933 (patch) | |
tree | 1050ad65d3570384b4624740f7b48aad85104f66 /src | |
parent | 93ab51e9ac6173d3aebde2df1393ee2ee7f6a28e (diff) | |
download | tor-670aeb6c8d894cb99a809fd7cc4f516cd0e54933.tar tor-670aeb6c8d894cb99a809fd7cc4f516cd0e54933.tar.gz |
add and use stubs for hidserv lookup and store
svn:r1402
Diffstat (limited to 'src')
-rw-r--r-- | src/or/directory.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 941ad4d56..0251c953a 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -288,6 +288,11 @@ int connection_dir_process_inbuf(connection_t *conn) { return 0; } +/* XXX stubs, probably shouldn't be located here */ +#define MAX_HIDSERV_DESC_SIZE 2048 +int hidserv_lookup(char *query, char *desc, int max_desc_size) { return 0; } +int hidserv_store(char *desc) { return 0; } + static char answer200[] = "HTTP/1.0 200 OK\r\n\r\n"; static char answer400[] = "HTTP/1.0 400 Bad request\r\n\r\n"; static char answer403[] = "HTTP/1.0 403 Unapproved server\r\n\r\n"; @@ -326,11 +331,21 @@ static int directory_handle_command_get(connection_t *conn, } if(!strncmp(url,"/hidserv/",9)) { /* hidserv descriptor fetch */ - /* ask back-end for the hidden-services descriptor in - * url+9, and return it with a 200 if valid, or give a 404 - * otherwise - */ + char desc[MAX_HIDSERV_DESC_SIZE]; + switch(hidserv_lookup(url+9, desc, MAX_HIDSERV_DESC_SIZE)) { + case 1: /* valid */ + connection_write_to_buf(answer200, strlen(answer200), conn); + connection_write_to_buf(desc, strlen(desc)+1, conn); + break; + case 0: /* well-formed but not present */ + connection_write_to_buf(answer404, strlen(answer404), conn); + break; + case -1: /* not well-formed */ + connection_write_to_buf(answer400, strlen(answer400), conn); + break; + } + return 0; } /* we didn't recognize the url */ @@ -372,9 +387,10 @@ static int directory_handle_command_post(connection_t *conn, } if(!strncmp(url,"/hidserv/",9)) { /* hidserv descriptor post */ - /* pass 'body' to the backend */ - /* return 400, 403, or 200 as appropriate */ - + if(hidserv_store(body) < 0) + connection_write_to_buf(answer400, strlen(answer400), conn); + else + connection_write_to_buf(answer200, strlen(answer200), conn); } /* we didn't recognize the url */ |