[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Logic to launch connections for new directory types.



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv28973/src/or

Modified Files:
	directory.c or.h 
Log Message:
Logic to launch connections for new directory types.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.255
retrieving revision 1.256
diff -u -d -r1.255 -r1.256
--- directory.c	7 Sep 2005 17:15:46 -0000	1.255
+++ directory.c	7 Sep 2005 20:03:02 -0000	1.256
@@ -291,6 +291,12 @@
     case DIR_PURPOSE_FETCH_RUNNING_LIST:
       log_fn(LOG_DEBUG,"initiating running-routers fetch");
       break;
+    case DIR_PURPOSE_FETCH_NETWORKSTATUS:
+      log_fn(LOG_DEBUG,"initiating network-status fetch");
+      break;
+    case DIR_PURPOSE_FETCH_SERVERDESC:
+      log_fn(LOG_DEBUG,"initiating server descriptor fetch");
+      break;
     default:
       log_fn(LOG_ERR, "Unrecognized directory connection purpose.");
       tor_assert(0);
@@ -362,12 +368,13 @@
                        int purpose, const char *resource,
                        const char *payload, size_t payload_len)
 {
-  char tmp[8192];
   char proxystring[256];
   char proxyauthstring[256];
   char hoststring[128];
-  char url[128];
+  char *url;
+  char request[8192];
   const char *httpcommand = NULL;
+  size_t len;
 
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_DIR);
@@ -410,19 +417,31 @@
       log_fn(LOG_DEBUG, "Asking for compressed directory from server running %s",
              platform?platform:"<unknown version>");
       httpcommand = "GET";
-      strlcpy(url, "/tor/dir.z", sizeof(url));
+      url = tor_strdup("/tor/dir.z");
       break;
     case DIR_PURPOSE_FETCH_RUNNING_LIST:
       tor_assert(!resource);
       tor_assert(!payload);
       httpcommand = "GET";
-      strlcpy(url, "/tor/running-routers", sizeof(url));
+      url = tor_strdup("/tor/running-routers");
+      break;
+    case DIR_PURPOSE_FETCH_NETWORKSTATUS:
+      httpcommand = "GET";//XXXX
+      len = strlen(resource)+32;
+      url = tor_malloc(len);
+      tor_snprintf(url, len, "/tor/status/%s", resource);
+      break;
+    case DIR_PURPOSE_FETCH_SERVERDESC:
+      httpcommand = "GET";//XXXX
+      len = strlen(resource)+32;
+      url = tor_malloc(len);
+      tor_snprintf(url, len, "/tor/server/%s", resource);
       break;
     case DIR_PURPOSE_UPLOAD_DIR:
       tor_assert(!resource);
       tor_assert(payload);
       httpcommand = "POST";
-      strlcpy(url, "/tor/", sizeof(url));
+      url = tor_strdup("/tor/");
       break;
     case DIR_PURPOSE_FETCH_RENDDESC:
       tor_assert(resource);
@@ -437,24 +456,28 @@
       /* Request the most recent versioned descriptor. */
       // XXXX011
       //tor_snprintf(url, sizeof(url), "/tor/rendezvous1/%s", resource);
-      tor_snprintf(url, sizeof(url), "/tor/rendezvous/%s", resource);
+      len = strlen(resource)+32;
+      url = tor_malloc(len);
+      tor_snprintf(url, len, "/tor/rendezvous/%s", resource);
       break;
     case DIR_PURPOSE_UPLOAD_RENDDESC:
       tor_assert(!resource);
       tor_assert(payload);
       httpcommand = "POST";
-      tor_snprintf(url, sizeof(url), "/tor/rendezvous/publish");
+      url = tor_strdup("/tor/rendezvous/publish");
       break;
   }
+  tor_snprintf(request, sizeof(request), "%s %s", httpcommand, proxystring);
+  connection_write_to_buf(request, strlen(request), conn);
+  connection_write_to_buf(url, strlen(url), conn);
+  tor_free(url);
 
-  tor_snprintf(tmp, sizeof(tmp), "%s %s%s HTTP/1.0\r\nContent-Length: %lu\r\nHost: %s%s\r\n\r\n",
-           httpcommand,
-           proxystring,
-           url,
+  tor_snprintf(request, len, " HTTP/1.0\r\nContent-Length: %lu\r\nHost: %s%s\r\n\r\n",
            payload ? (unsigned long)payload_len : 0,
            hoststring,
            proxyauthstring);
-  connection_write_to_buf(tmp, strlen(tmp), conn);
+  connection_write_to_buf(request, strlen(request), conn);
+
 
   if (payload) {
     /* then send the payload afterwards too */

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.668
retrieving revision 1.669
diff -u -d -r1.668 -r1.669
--- or.h	7 Sep 2005 17:15:46 -0000	1.668
+++ or.h	7 Sep 2005 20:03:02 -0000	1.669
@@ -323,14 +323,20 @@
 /** Purpose for connection to directory server: set after a rendezvous
  * descriptor is downloaded. */
 #define DIR_PURPOSE_HAS_FETCHED_RENDDESC 4
+/** A connection to a directory server: downoad one or more network-status
+ * objects */
+#define DIR_PURPOSE_FETCH_NETWORKSTATUS 5
+/**  A connection to a directory server: downoad one or more server
+ * descriptors. */
+#define DIR_PURPOSE_FETCH_SERVERDESC 6
 /** Purpose for connection to directory server: upload a server descriptor. */
-#define DIR_PURPOSE_UPLOAD_DIR 5
+#define DIR_PURPOSE_UPLOAD_DIR 7
 /** Purpose for connection to directory server: upload a rendezvous
  * descriptor. */
-#define DIR_PURPOSE_UPLOAD_RENDDESC 6
+#define DIR_PURPOSE_UPLOAD_RENDDESC 8
 /** Purpose for connection at a directory server. */
-#define DIR_PURPOSE_SERVER 7
-#define _DIR_PURPOSE_MAX 7
+#define DIR_PURPOSE_SERVER 9
+#define _DIR_PURPOSE_MAX 9
 
 #define _EXIT_PURPOSE_MIN 1
 #define EXIT_PURPOSE_CONNECT 1