[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] add and use stubs for hidserv lookup and store
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
directory.c
Log Message:
add and use stubs for hidserv lookup and store
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- directory.c 30 Mar 2004 22:57:49 -0000 1.71
+++ directory.c 30 Mar 2004 23:41:24 -0000 1.72
@@ -288,6 +288,11 @@
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 @@
}
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 @@
}
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 */