int was_extrainfo,
int was_descriptor_digests);
static void note_request(const char *key, size_t bytes);
+static void note_client_request(int purpose, int compressed, size_t bytes);
static int client_likes_consensus(networkstatus_t *v, const char *want_url);
/********* START VARIABLES **********/
log_notice(LD_DIR,"I failed to parse the directory I fetched from "
"'%s:%d'. Ignoring.", conn->_base.address, conn->_base.port);
}
- note_request(was_compressed?"dl/dir.z":"dl/dir", orig_len);
}
if (conn->_base.purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
tor_free(body); tor_free(headers); tor_free(reason);
return -1;
}
- note_request(was_compressed?"dl/running-routers.z":
- "dl/running-routers", orig_len);
}
if (conn->_base.purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) {
connection_dir_download_networkstatus_failed(conn, status_code);
return -1;
}
- note_request(was_compressed?"dl/status.z":"dl/status", orig_len);
if (conn->requested_resource &&
!strcmpstart(conn->requested_resource,"fp/")) {
source = NS_FROM_DIR_BY_FP;
log_info(LD_DIR,"Received %s (size %d) from server '%s:%d'",
was_ei ? "extra server info" : "server info",
(int)body_len, conn->_base.address, conn->_base.port);
- if (was_ei)
- note_request(was_compressed?"dl/extra.z":"dl/extra", orig_len);
- else
- note_request(was_compressed?"dl/server.z":"dl/server", orig_len);
if (conn->requested_resource &&
(!strcmpstart(conn->requested_resource,"d/") ||
!strcmpstart(conn->requested_resource,"fp/"))) {
break;
}
}
+ note_client_request(conn->_base.purpose, was_compressed, orig_len);
tor_free(body); tor_free(headers); tor_free(reason);
return 0;
}
* of request. Maps from request type to pointer to uint64_t. */
static strmap_t *request_bytes_map = NULL;
+static void
+note_client_request(int purpose, int compressed, size_t bytes)
+{
+ char *key;
+ const char *kind = NULL;
+ switch (purpose) {
+ case DIR_PURPOSE_FETCH_DIR: kind = "dl/dir"; break;
+ case DIR_PURPOSE_FETCH_RUNNING_LIST: kind = "dl/running-routers"; break;
+ case DIR_PURPOSE_FETCH_NETWORKSTATUS: kind = "dl/status"; break;
+ case DIR_PURPOSE_FETCH_CONSENSUS: kind = "dl/consensus"; break;
+ case DIR_PURPOSE_FETCH_CERTIFICATE: kind = "dl/cert"; break;
+ case DIR_PURPOSE_FETCH_STATUS_VOTE: kind = "dl/vote"; break;
+ case DIR_PURPOSE_FETCH_DETACHED_SIGNATURES: kind = "dl/detached_sig"; break;
+ case DIR_PURPOSE_FETCH_SERVERDESC: kind = "dl/server"; break;
+ case DIR_PURPOSE_FETCH_EXTRAINFO: kind = "dl/extra"; break;
+ case DIR_PURPOSE_UPLOAD_DIR: kind = "dl/ul-dir"; break;
+ case DIR_PURPOSE_UPLOAD_VOTE: kind = "dl/ul-vote"; break;
+ case DIR_PURPOSE_UPLOAD_SIGNATURES: kind = "dl/ul-sig"; break;
+ case DIR_PURPOSE_FETCH_RENDDESC: kind = "dl/rend"; break;
+ case DIR_PURPOSE_FETCH_RENDDESC_V2: kind = "dl/rend2"; break;
+ case DIR_PURPOSE_UPLOAD_RENDDESC: kind = "dl/ul-rend"; break;
+ case DIR_PURPOSE_UPLOAD_RENDDESC_V2: kind = "dl/ul-rend2"; break;
+ }
+ if (kind) {
+ key = tor_malloc(256);
+ tor_snprintf(key, 256, "%s%s", kind, compressed?"":".z");
+ } else {
+ key = tor_malloc(256);
+ tor_snprintf(key, 256, "unknown purpose (%d)%s",
+ purpose, compressed?"":".z");
+ }
+ note_request(key, bytes);
+ tor_free(key);
+}
+
/** Called when we just transmitted or received <b>bytes</b> worth of data
* because of a request of type <b>key</b> (an arbitrary identifier): adds
* <b>bytes</b> to the total associated with key. */
return result;
}
#else
+static void
+note_client_request(int purpose, int compressed, size_t bytes)
+{
+ (void)purpose;
+ (void)compressed;
+ (void)bytes;
+}
+
static void
note_request(const char *key, size_t bytes)
{