mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 22:58:50 +01:00
add and use stubs for hidserv lookup and store
svn:r1402
This commit is contained in:
parent
93ab51e9ac
commit
670aeb6c8d
1 changed files with 23 additions and 7 deletions
|
@ -288,6 +288,11 @@ int connection_dir_process_inbuf(connection_t *conn) {
|
||||||
return 0;
|
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 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 answer400[] = "HTTP/1.0 400 Bad request\r\n\r\n";
|
||||||
static char answer403[] = "HTTP/1.0 403 Unapproved server\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 */
|
if(!strncmp(url,"/hidserv/",9)) { /* hidserv descriptor fetch */
|
||||||
/* ask back-end for the hidden-services descriptor in
|
char desc[MAX_HIDSERV_DESC_SIZE];
|
||||||
* url+9, and return it with a 200 if valid, or give a 404
|
|
||||||
* otherwise
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
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 */
|
/* 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 */
|
if(!strncmp(url,"/hidserv/",9)) { /* hidserv descriptor post */
|
||||||
/* pass 'body' to the backend */
|
if(hidserv_store(body) < 0)
|
||||||
/* return 400, 403, or 200 as appropriate */
|
connection_write_to_buf(answer400, strlen(answer400), conn);
|
||||||
|
else
|
||||||
|
connection_write_to_buf(answer200, strlen(answer200), conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we didn't recognize the url */
|
/* we didn't recognize the url */
|
||||||
|
|
Loading…
Add table
Reference in a new issue