diff options
author | Roger Dingledine <arma@torproject.org> | 2004-10-17 04:06:48 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-10-17 04:06:48 +0000 |
commit | 560a4a1407b1b9da75f32f75b2b231ce72e9fd98 (patch) | |
tree | 0f5daf4454ee96291d3656fdf26ca0dc0b79f09d /src/or/directory.c | |
parent | 6d1e1b7f46494c1785b49ee996c2e4e2ca668056 (diff) | |
download | tor-560a4a1407b1b9da75f32f75b2b231ce72e9fd98.tar tor-560a4a1407b1b9da75f32f75b2b231ce72e9fd98.tar.gz |
switch conn->addr and conn->dir_port to reflect the final destination,
not the http proxy
svn:r2553
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 5a5ff282a..40f408ffc 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -41,8 +41,7 @@ directory_initiate_command(const char *address, uint32_t addr, uint16_t port, static void directory_send_command(connection_t *conn, const char *platform, - uint16_t dir_port, int purpose, - const char *payload, size_t payload_len); + int purpose, const char *payload, size_t payload_len); static int directory_handle_command(connection_t *conn); /********* START VARIABLES **********/ @@ -195,13 +194,14 @@ directory_initiate_command(const char *address, uint32_t addr, conn = connection_new(CONN_TYPE_DIR); /* set up conn so it's got all the data we need to remember */ + conn->addr = addr; + conn->port = dir_port; + if(options.HttpProxy) { - conn->addr = options.HttpProxyAddr; - conn->port = options.HttpProxyPort; - } else { - conn->addr = addr; - conn->port = dir_port; + addr = options.HttpProxyAddr; + dir_port = options.HttpProxyPort; } + conn->address = tor_strdup(address); /* conn->nickname = tor_strdup(router->nickname); */ /* tor_assert(router->identity_pkey); */ @@ -217,12 +217,12 @@ directory_initiate_command(const char *address, uint32_t addr, if(purpose == DIR_PURPOSE_FETCH_DIR || purpose == DIR_PURPOSE_UPLOAD_DIR) { /* then we want to connect directly */ - switch(connection_connect(conn, conn->address, conn->addr, conn->port)) { + switch(connection_connect(conn, conn->address, addr, dir_port)) { case -1: router_mark_as_down(conn->identity_digest); /* don't try him again */ if(purpose == DIR_PURPOSE_FETCH_DIR && !all_trusted_directory_servers_down()) { - log_fn(LOG_INFO,"Giving up on dirserver %s; trying another.", conn->nickname); + log_fn(LOG_INFO,"Giving up on dirserver %s; trying another.", conn->address); directory_get_from_dirserver(purpose, payload, payload_len); } connection_free(conn); @@ -232,8 +232,7 @@ directory_initiate_command(const char *address, uint32_t addr, /* fall through */ case 0: /* queue the command on the outbuf */ - directory_send_command(conn, platform, dir_port, - purpose, payload, payload_len); + directory_send_command(conn, platform, purpose, payload, payload_len); connection_watch_events(conn, POLLIN | POLLOUT | POLLERR); /* writable indicates finish, readable indicates broken link, @@ -254,8 +253,7 @@ directory_initiate_command(const char *address, uint32_t addr, conn->state = DIR_CONN_STATE_CLIENT_SENDING; connection_add(conn); /* queue the command on the outbuf */ - directory_send_command(conn, platform, dir_port, - purpose, payload, payload_len); + directory_send_command(conn, platform, purpose, payload, payload_len); connection_watch_events(conn, POLLIN | POLLOUT | POLLERR); } } @@ -266,8 +264,7 @@ directory_initiate_command(const char *address, uint32_t addr, */ static void directory_send_command(connection_t *conn, const char *platform, - uint16_t dir_port, int purpose, - const char *payload, size_t payload_len) { + int purpose, const char *payload, size_t payload_len) { char tmp[8192]; char proxystring[128]; char hoststring[128]; @@ -277,15 +274,14 @@ directory_send_command(connection_t *conn, const char *platform, tor_assert(conn); tor_assert(conn->type == CONN_TYPE_DIR); - tor_assert(dir_port); /* If we don't know the platform, assume it's up-to-date. */ use_newer = platform ? tor_version_as_new_as(platform, "0.0.9pre1"):1; - if(dir_port == 80) { + if(conn->port == 80) { strlcpy(hoststring, conn->address, sizeof(hoststring)); } else { - sprintf(hoststring, "%s:%d", conn->address, dir_port); + sprintf(hoststring, "%s:%d", conn->address, conn->port); } if(options.HttpProxy) { sprintf(proxystring, "http://%s", hoststring); |