mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
Logic to launch connections for new directory types.
svn:r4914
This commit is contained in:
parent
9e76eae810
commit
4aca47268d
@ -291,6 +291,12 @@ directory_initiate_command(const char *address, uint32_t addr,
|
|||||||
case DIR_PURPOSE_FETCH_RUNNING_LIST:
|
case DIR_PURPOSE_FETCH_RUNNING_LIST:
|
||||||
log_fn(LOG_DEBUG,"initiating running-routers fetch");
|
log_fn(LOG_DEBUG,"initiating running-routers fetch");
|
||||||
break;
|
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:
|
default:
|
||||||
log_fn(LOG_ERR, "Unrecognized directory connection purpose.");
|
log_fn(LOG_ERR, "Unrecognized directory connection purpose.");
|
||||||
tor_assert(0);
|
tor_assert(0);
|
||||||
@ -362,12 +368,13 @@ directory_send_command(connection_t *conn, const char *platform,
|
|||||||
int purpose, const char *resource,
|
int purpose, const char *resource,
|
||||||
const char *payload, size_t payload_len)
|
const char *payload, size_t payload_len)
|
||||||
{
|
{
|
||||||
char tmp[8192];
|
|
||||||
char proxystring[256];
|
char proxystring[256];
|
||||||
char proxyauthstring[256];
|
char proxyauthstring[256];
|
||||||
char hoststring[128];
|
char hoststring[128];
|
||||||
char url[128];
|
char *url;
|
||||||
|
char request[8192];
|
||||||
const char *httpcommand = NULL;
|
const char *httpcommand = NULL;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
tor_assert(conn->type == CONN_TYPE_DIR);
|
tor_assert(conn->type == CONN_TYPE_DIR);
|
||||||
@ -410,19 +417,31 @@ directory_send_command(connection_t *conn, const char *platform,
|
|||||||
log_fn(LOG_DEBUG, "Asking for compressed directory from server running %s",
|
log_fn(LOG_DEBUG, "Asking for compressed directory from server running %s",
|
||||||
platform?platform:"<unknown version>");
|
platform?platform:"<unknown version>");
|
||||||
httpcommand = "GET";
|
httpcommand = "GET";
|
||||||
strlcpy(url, "/tor/dir.z", sizeof(url));
|
url = tor_strdup("/tor/dir.z");
|
||||||
break;
|
break;
|
||||||
case DIR_PURPOSE_FETCH_RUNNING_LIST:
|
case DIR_PURPOSE_FETCH_RUNNING_LIST:
|
||||||
tor_assert(!resource);
|
tor_assert(!resource);
|
||||||
tor_assert(!payload);
|
tor_assert(!payload);
|
||||||
httpcommand = "GET";
|
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;
|
break;
|
||||||
case DIR_PURPOSE_UPLOAD_DIR:
|
case DIR_PURPOSE_UPLOAD_DIR:
|
||||||
tor_assert(!resource);
|
tor_assert(!resource);
|
||||||
tor_assert(payload);
|
tor_assert(payload);
|
||||||
httpcommand = "POST";
|
httpcommand = "POST";
|
||||||
strlcpy(url, "/tor/", sizeof(url));
|
url = tor_strdup("/tor/");
|
||||||
break;
|
break;
|
||||||
case DIR_PURPOSE_FETCH_RENDDESC:
|
case DIR_PURPOSE_FETCH_RENDDESC:
|
||||||
tor_assert(resource);
|
tor_assert(resource);
|
||||||
@ -437,24 +456,28 @@ directory_send_command(connection_t *conn, const char *platform,
|
|||||||
/* Request the most recent versioned descriptor. */
|
/* Request the most recent versioned descriptor. */
|
||||||
// XXXX011
|
// XXXX011
|
||||||
//tor_snprintf(url, sizeof(url), "/tor/rendezvous1/%s", resource);
|
//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;
|
break;
|
||||||
case DIR_PURPOSE_UPLOAD_RENDDESC:
|
case DIR_PURPOSE_UPLOAD_RENDDESC:
|
||||||
tor_assert(!resource);
|
tor_assert(!resource);
|
||||||
tor_assert(payload);
|
tor_assert(payload);
|
||||||
httpcommand = "POST";
|
httpcommand = "POST";
|
||||||
tor_snprintf(url, sizeof(url), "/tor/rendezvous/publish");
|
url = tor_strdup("/tor/rendezvous/publish");
|
||||||
break;
|
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",
|
tor_snprintf(request, len, " HTTP/1.0\r\nContent-Length: %lu\r\nHost: %s%s\r\n\r\n",
|
||||||
httpcommand,
|
|
||||||
proxystring,
|
|
||||||
url,
|
|
||||||
payload ? (unsigned long)payload_len : 0,
|
payload ? (unsigned long)payload_len : 0,
|
||||||
hoststring,
|
hoststring,
|
||||||
proxyauthstring);
|
proxyauthstring);
|
||||||
connection_write_to_buf(tmp, strlen(tmp), conn);
|
connection_write_to_buf(request, strlen(request), conn);
|
||||||
|
|
||||||
|
|
||||||
if (payload) {
|
if (payload) {
|
||||||
/* then send the payload afterwards too */
|
/* then send the payload afterwards too */
|
||||||
|
14
src/or/or.h
14
src/or/or.h
@ -323,14 +323,20 @@ typedef enum {
|
|||||||
/** Purpose for connection to directory server: set after a rendezvous
|
/** Purpose for connection to directory server: set after a rendezvous
|
||||||
* descriptor is downloaded. */
|
* descriptor is downloaded. */
|
||||||
#define DIR_PURPOSE_HAS_FETCHED_RENDDESC 4
|
#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. */
|
/** 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
|
/** Purpose for connection to directory server: upload a rendezvous
|
||||||
* descriptor. */
|
* descriptor. */
|
||||||
#define DIR_PURPOSE_UPLOAD_RENDDESC 6
|
#define DIR_PURPOSE_UPLOAD_RENDDESC 8
|
||||||
/** Purpose for connection at a directory server. */
|
/** Purpose for connection at a directory server. */
|
||||||
#define DIR_PURPOSE_SERVER 7
|
#define DIR_PURPOSE_SERVER 9
|
||||||
#define _DIR_PURPOSE_MAX 7
|
#define _DIR_PURPOSE_MAX 9
|
||||||
|
|
||||||
#define _EXIT_PURPOSE_MIN 1
|
#define _EXIT_PURPOSE_MIN 1
|
||||||
#define EXIT_PURPOSE_CONNECT 1
|
#define EXIT_PURPOSE_CONNECT 1
|
||||||
|
Loading…
Reference in New Issue
Block a user