|
@@ -246,7 +246,7 @@ directories_have_accepted_server_descriptor(void)
|
|
|
smartlist_t *servers = router_get_trusted_dir_servers();
|
|
|
const or_options_t *options = get_options();
|
|
|
SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
|
|
|
- if ((d->type & options->_PublishServerDescriptor) &&
|
|
|
+ if ((d->type & options->PublishServerDescriptor_) &&
|
|
|
d->has_accepted_serverdesc) {
|
|
|
return 1;
|
|
|
}
|
|
@@ -645,8 +645,8 @@ directory_conn_is_self_reachability_test(dir_connection_t *conn)
|
|
|
const routerinfo_t *me = router_get_my_routerinfo();
|
|
|
if (me &&
|
|
|
router_digest_is_me(conn->identity_digest) &&
|
|
|
- tor_addr_eq_ipv4h(&conn->_base.addr, me->addr) && /*XXXX prop 118*/
|
|
|
- me->dir_port == conn->_base.port)
|
|
|
+ tor_addr_eq_ipv4h(&conn->base_.addr, me->addr) && /*XXXX prop 118*/
|
|
|
+ me->dir_port == conn->base_.port)
|
|
|
return 1;
|
|
|
}
|
|
|
return 0;
|
|
@@ -664,35 +664,35 @@ connection_dir_request_failed(dir_connection_t *conn)
|
|
|
}
|
|
|
if (!entry_list_is_constrained(get_options()))
|
|
|
router_set_status(conn->identity_digest, 0); /* don't try him again */
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
|
|
|
log_info(LD_DIR, "Giving up on directory server at '%s'; retrying",
|
|
|
- conn->_base.address);
|
|
|
+ conn->base_.address);
|
|
|
connection_dir_download_v2_networkstatus_failed(conn, -1);
|
|
|
- } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
- conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
|
|
|
+ } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
+ conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
|
|
|
log_info(LD_DIR, "Giving up on serverdesc/extrainfo fetch from "
|
|
|
"directory server at '%s'; retrying",
|
|
|
- conn->_base.address);
|
|
|
+ conn->base_.address);
|
|
|
if (conn->router_purpose == ROUTER_PURPOSE_BRIDGE)
|
|
|
connection_dir_bridge_routerdesc_failed(conn);
|
|
|
connection_dir_download_routerdesc_failed(conn);
|
|
|
- } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
|
|
|
+ } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
|
|
|
if (conn->requested_resource)
|
|
|
networkstatus_consensus_download_failed(0, conn->requested_resource);
|
|
|
- } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
|
|
|
+ } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
|
|
|
log_info(LD_DIR, "Giving up on certificate fetch from directory server "
|
|
|
"at '%s'; retrying",
|
|
|
- conn->_base.address);
|
|
|
+ conn->base_.address);
|
|
|
connection_dir_download_cert_failed(conn, 0);
|
|
|
- } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
|
|
|
+ } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
|
|
|
log_info(LD_DIR, "Giving up downloading detached signatures from '%s'",
|
|
|
- conn->_base.address);
|
|
|
- } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
|
|
|
+ conn->base_.address);
|
|
|
+ } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
|
|
|
log_info(LD_DIR, "Giving up downloading votes from '%s'",
|
|
|
- conn->_base.address);
|
|
|
- } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
|
|
|
+ conn->base_.address);
|
|
|
+ } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
|
|
|
log_info(LD_DIR, "Giving up on downloading microdescriptors from "
|
|
|
- " directory server at '%s'; will retry", conn->_base.address);
|
|
|
+ " directory server at '%s'; will retry", conn->base_.address);
|
|
|
connection_dir_download_routerdesc_failed(conn);
|
|
|
}
|
|
|
}
|
|
@@ -718,7 +718,7 @@ connection_dir_download_v2_networkstatus_failed(dir_connection_t *conn,
|
|
|
smartlist_t *trusted_dirs = router_get_trusted_dir_servers();
|
|
|
SMARTLIST_FOREACH(trusted_dirs, trusted_dir_server_t *, ds,
|
|
|
download_status_failed(&ds->v2_ns_dl_status, 0));
|
|
|
- directory_get_from_dirserver(conn->_base.purpose, conn->router_purpose,
|
|
|
+ directory_get_from_dirserver(conn->base_.purpose, conn->router_purpose,
|
|
|
"all.z", 0 /* don't retry_if_no_servers */);
|
|
|
} else if (!strcmpstart(conn->requested_resource, "fp/")) {
|
|
|
/* We were trying to download by fingerprint; mark them all as having
|
|
@@ -763,9 +763,9 @@ connection_dir_download_routerdesc_failed(dir_connection_t *conn)
|
|
|
|
|
|
/* No need to relaunch descriptor downloads here: we already do it
|
|
|
* every 10 or 60 seconds (FOO_DESCRIPTOR_RETRY_INTERVAL) in main.c. */
|
|
|
- tor_assert(conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
- conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
|
|
|
- conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC);
|
|
|
+ tor_assert(conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
+ conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
|
|
|
+ conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC);
|
|
|
|
|
|
(void) conn;
|
|
|
}
|
|
@@ -789,7 +789,7 @@ connection_dir_bridge_routerdesc_failed(dir_connection_t *conn)
|
|
|
+ strlen("fp/"),
|
|
|
which, NULL, 0);
|
|
|
|
|
|
- tor_assert(conn->_base.purpose != DIR_PURPOSE_FETCH_EXTRAINFO);
|
|
|
+ tor_assert(conn->base_.purpose != DIR_PURPOSE_FETCH_EXTRAINFO);
|
|
|
if (smartlist_len(which)) {
|
|
|
connection_dir_retry_bridges(which);
|
|
|
SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
|
|
@@ -802,7 +802,7 @@ static void
|
|
|
connection_dir_download_cert_failed(dir_connection_t *conn, int status)
|
|
|
{
|
|
|
smartlist_t *failed;
|
|
|
- tor_assert(conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE);
|
|
|
+ tor_assert(conn->base_.purpose == DIR_PURPOSE_FETCH_CERTIFICATE);
|
|
|
|
|
|
if (!conn->requested_resource)
|
|
|
return;
|
|
@@ -934,16 +934,16 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
|
|
|
conn = dir_connection_new(tor_addr_family(&addr));
|
|
|
|
|
|
/* set up conn so it's got all the data we need to remember */
|
|
|
- tor_addr_copy(&conn->_base.addr, &addr);
|
|
|
- conn->_base.port = use_begindir ? or_port : dir_port;
|
|
|
- conn->_base.address = tor_strdup(address);
|
|
|
+ tor_addr_copy(&conn->base_.addr, &addr);
|
|
|
+ conn->base_.port = use_begindir ? or_port : dir_port;
|
|
|
+ conn->base_.address = tor_strdup(address);
|
|
|
memcpy(conn->identity_digest, digest, DIGEST_LEN);
|
|
|
|
|
|
- conn->_base.purpose = dir_purpose;
|
|
|
+ conn->base_.purpose = dir_purpose;
|
|
|
conn->router_purpose = router_purpose;
|
|
|
|
|
|
/* give it an initial state */
|
|
|
- conn->_base.state = DIR_CONN_STATE_CONNECTING;
|
|
|
+ conn->base_.state = DIR_CONN_STATE_CONNECTING;
|
|
|
|
|
|
/* decide whether we can learn our IP address from this conn */
|
|
|
/* XXXX This is a bad name for this field now. */
|
|
@@ -961,7 +961,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
|
|
|
dir_port = options->HTTPProxyPort;
|
|
|
}
|
|
|
|
|
|
- switch (connection_connect(TO_CONN(conn), conn->_base.address, &addr,
|
|
|
+ switch (connection_connect(TO_CONN(conn), conn->base_.address, &addr,
|
|
|
dir_port, &socket_error)) {
|
|
|
case -1:
|
|
|
connection_dir_request_failed(conn); /* retry if we want */
|
|
@@ -971,7 +971,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
|
|
|
return;
|
|
|
case 1:
|
|
|
/* start flushing conn */
|
|
|
- conn->_base.state = DIR_CONN_STATE_CLIENT_SENDING;
|
|
|
+ conn->base_.state = DIR_CONN_STATE_CLIENT_SENDING;
|
|
|
/* fall through */
|
|
|
case 0:
|
|
|
/* queue the command on the outbuf */
|
|
@@ -994,7 +994,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
|
|
|
if (anonymized_connection && use_begindir)
|
|
|
rep_hist_note_used_internal(time(NULL), 0, 1);
|
|
|
else if (anonymized_connection && !use_begindir)
|
|
|
- rep_hist_note_used_port(time(NULL), conn->_base.port);
|
|
|
+ rep_hist_note_used_port(time(NULL), conn->base_.port);
|
|
|
|
|
|
/* make an AP connection
|
|
|
* populate it and add it at the right state
|
|
@@ -1002,7 +1002,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
|
|
|
*/
|
|
|
linked_conn =
|
|
|
connection_ap_make_link(TO_CONN(conn),
|
|
|
- conn->_base.address, conn->_base.port,
|
|
|
+ conn->base_.address, conn->base_.port,
|
|
|
digest,
|
|
|
SESSION_GROUP_DIRCONN, iso_flags,
|
|
|
use_begindir, conn->dirconn_direct);
|
|
@@ -1017,7 +1017,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
|
|
|
connection_mark_for_close(TO_CONN(conn));
|
|
|
return;
|
|
|
}
|
|
|
- conn->_base.state = DIR_CONN_STATE_CLIENT_SENDING;
|
|
|
+ conn->base_.state = DIR_CONN_STATE_CLIENT_SENDING;
|
|
|
/* queue the command on the outbuf */
|
|
|
directory_send_command(conn, dir_purpose, 0, resource,
|
|
|
payload, payload_len,
|
|
@@ -1050,7 +1050,7 @@ connection_dir_is_encrypted(dir_connection_t *conn)
|
|
|
* sort strings alphabetically
|
|
|
*/
|
|
|
static int
|
|
|
-_compare_strs(const void **a, const void **b)
|
|
|
+compare_strs_(const void **a, const void **b)
|
|
|
{
|
|
|
const char *s1 = *a, *s2 = *b;
|
|
|
return strcmp(s1, s2);
|
|
@@ -1097,7 +1097,7 @@ directory_get_consensus_url(const char *resource)
|
|
|
ds->v3_identity_digest, CONDITIONAL_CONSENSUS_FPR_LEN);
|
|
|
smartlist_add(authority_digests, hex);
|
|
|
} SMARTLIST_FOREACH_END(ds);
|
|
|
- smartlist_sort(authority_digests, _compare_strs);
|
|
|
+ smartlist_sort(authority_digests, compare_strs_);
|
|
|
authority_id_list = smartlist_join_strings(authority_digests,
|
|
|
"+", 0, NULL);
|
|
|
|
|
@@ -1128,18 +1128,18 @@ directory_send_command(dir_connection_t *conn,
|
|
|
const char *httpcommand = NULL;
|
|
|
|
|
|
tor_assert(conn);
|
|
|
- tor_assert(conn->_base.type == CONN_TYPE_DIR);
|
|
|
+ tor_assert(conn->base_.type == CONN_TYPE_DIR);
|
|
|
|
|
|
tor_free(conn->requested_resource);
|
|
|
if (resource)
|
|
|
conn->requested_resource = tor_strdup(resource);
|
|
|
|
|
|
/* come up with a string for which Host: we want */
|
|
|
- if (conn->_base.port == 80) {
|
|
|
- strlcpy(hoststring, conn->_base.address, sizeof(hoststring));
|
|
|
+ if (conn->base_.port == 80) {
|
|
|
+ strlcpy(hoststring, conn->base_.address, sizeof(hoststring));
|
|
|
} else {
|
|
|
tor_snprintf(hoststring, sizeof(hoststring),"%s:%d",
|
|
|
- conn->_base.address, conn->_base.port);
|
|
|
+ conn->base_.address, conn->base_.port);
|
|
|
}
|
|
|
|
|
|
/* Format if-modified-since */
|
|
@@ -1574,9 +1574,9 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
compress_method_t compression;
|
|
|
int plausible;
|
|
|
int skewed=0;
|
|
|
- int allow_partial = (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
- conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
|
|
|
- conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC);
|
|
|
+ int allow_partial = (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
+ conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
|
|
|
+ conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC);
|
|
|
int was_compressed=0;
|
|
|
time_t now = time(NULL);
|
|
|
|
|
@@ -1587,7 +1587,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
case -1: /* overflow */
|
|
|
log_warn(LD_PROTOCOL,
|
|
|
"'fetch' response too large (server '%s:%d'). Closing.",
|
|
|
- conn->_base.address, conn->_base.port);
|
|
|
+ conn->base_.address, conn->base_.port);
|
|
|
return -1;
|
|
|
case 0:
|
|
|
log_info(LD_HTTP,
|
|
@@ -1600,7 +1600,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
if (parse_http_response(headers, &status_code, &date_header,
|
|
|
&compression, &reason) < 0) {
|
|
|
log_warn(LD_HTTP,"Unparseable headers (server '%s:%d'). Closing.",
|
|
|
- conn->_base.address, conn->_base.port);
|
|
|
+ conn->base_.address, conn->base_.port);
|
|
|
tor_free(body); tor_free(headers);
|
|
|
return -1;
|
|
|
}
|
|
@@ -1609,9 +1609,9 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log_debug(LD_DIR,
|
|
|
"Received response from directory server '%s:%d': %d %s "
|
|
|
"(purpose: %d)",
|
|
|
- conn->_base.address, conn->_base.port, status_code,
|
|
|
+ conn->base_.address, conn->base_.port, status_code,
|
|
|
escaped(reason),
|
|
|
- conn->_base.purpose);
|
|
|
+ conn->base_.purpose);
|
|
|
|
|
|
/* now check if it's got any hints for us about our IP address. */
|
|
|
if (conn->dirconn_direct) {
|
|
@@ -1628,7 +1628,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
* and the date header. (We used to check now-date_header, but that's
|
|
|
* inaccurate if we spend a lot of time downloading.)
|
|
|
*/
|
|
|
- delta = conn->_base.timestamp_lastwritten - date_header;
|
|
|
+ delta = conn->base_.timestamp_lastwritten - date_header;
|
|
|
if (labs(delta)>ALLOW_DIRECTORY_TIME_SKEW) {
|
|
|
char dbuf[64];
|
|
|
int trusted = router_digest_is_trusted_dir(conn->identity_digest);
|
|
@@ -1639,14 +1639,14 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
"It seems that our clock is %s by %s, or that theirs is %s. "
|
|
|
"Tor requires an accurate clock to work: please check your time, "
|
|
|
"timezone, and date settings.",
|
|
|
- conn->_base.address, conn->_base.port,
|
|
|
+ conn->base_.address, conn->base_.port,
|
|
|
delta>0 ? "ahead" : "behind", dbuf,
|
|
|
delta>0 ? "behind" : "ahead");
|
|
|
skewed = 1; /* don't check the recommended-versions line */
|
|
|
if (trusted)
|
|
|
control_event_general_status(LOG_WARN,
|
|
|
"CLOCK_SKEW SKEW=%ld SOURCE=DIRSERV:%s:%d",
|
|
|
- delta, conn->_base.address, conn->_base.port);
|
|
|
+ delta, conn->base_.address, conn->base_.port);
|
|
|
} else {
|
|
|
log_debug(LD_HTTP, "Time on received directory is within tolerance; "
|
|
|
"we are %ld seconds skewed. (That's okay.)", delta);
|
|
@@ -1660,8 +1660,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
const char *id_digest = conn->identity_digest;
|
|
|
log_info(LD_DIR,"Received http status code %d (%s) from server "
|
|
|
"'%s:%d'. I'll try again soon.",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
if ((rs = router_get_mutable_consensus_status_by_id(id_digest)))
|
|
|
rs->last_dir_503_at = now;
|
|
|
if ((ds = router_get_trusteddirserver_by_digest(id_digest)))
|
|
@@ -1671,7 +1671,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- plausible = body_is_plausible(body, body_len, conn->_base.purpose);
|
|
|
+ plausible = body_is_plausible(body, body_len, conn->base_.purpose);
|
|
|
if (compression != NO_METHOD || !plausible) {
|
|
|
char *new_body = NULL;
|
|
|
size_t new_len = 0;
|
|
@@ -1698,7 +1698,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
|
|
|
log_info(LD_HTTP, "HTTP body from server '%s:%d' was labeled %s, "
|
|
|
"but it seems to be %s.%s",
|
|
|
- conn->_base.address, conn->_base.port, description1,
|
|
|
+ conn->base_.address, conn->base_.port, description1,
|
|
|
description2,
|
|
|
(compression>0 && guessed>0)?" Trying both.":"");
|
|
|
}
|
|
@@ -1718,7 +1718,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
if (!plausible && !new_body) {
|
|
|
log_fn(LOG_PROTOCOL_WARN, LD_HTTP,
|
|
|
"Unable to decompress HTTP body (server '%s:%d').",
|
|
|
- conn->_base.address, conn->_base.port);
|
|
|
+ conn->base_.address, conn->base_.port);
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
|
return -1;
|
|
|
}
|
|
@@ -1730,12 +1730,12 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
|
|
|
smartlist_t *which = NULL;
|
|
|
v2_networkstatus_source_t source;
|
|
|
char *cp;
|
|
|
log_info(LD_DIR,"Received networkstatus objects (size %d) from server "
|
|
|
- "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
|
|
|
+ "'%s:%d'", (int)body_len, conn->base_.address, conn->base_.port);
|
|
|
if (status_code != 200) {
|
|
|
static ratelim_t warning_limit = RATELIM_INIT(3600);
|
|
|
char *m;
|
|
@@ -1744,8 +1744,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
"Received http status code %d (%s) from server "
|
|
|
"'%s:%d' while fetching \"/tor/status/%s\". "
|
|
|
"I'll try again soon.%s",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port, conn->requested_resource, m);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port, conn->requested_resource, m);
|
|
|
tor_free(m);
|
|
|
}
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
@@ -1801,7 +1801,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
|
|
|
int r;
|
|
|
const char *flavname = conn->requested_resource;
|
|
|
if (status_code != 200) {
|
|
@@ -1809,19 +1809,19 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log(severity, LD_DIR,
|
|
|
"Received http status code %d (%s) from server "
|
|
|
"'%s:%d' while fetching consensus directory.",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
|
networkstatus_consensus_download_failed(status_code, flavname);
|
|
|
return -1;
|
|
|
}
|
|
|
log_info(LD_DIR,"Received consensus directory (size %d) from server "
|
|
|
- "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
|
|
|
+ "'%s:%d'", (int)body_len, conn->base_.address, conn->base_.port);
|
|
|
if ((r=networkstatus_set_current_consensus(body, flavname, 0))<0) {
|
|
|
log_fn(r<-1?LOG_WARN:LOG_INFO, LD_DIR,
|
|
|
"Unable to load %s consensus directory downloaded from "
|
|
|
"server '%s:%d'. I'll try again soon.",
|
|
|
- flavname, conn->_base.address, conn->_base.port);
|
|
|
+ flavname, conn->base_.address, conn->base_.port);
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
|
networkstatus_consensus_download_failed(0, flavname);
|
|
|
return -1;
|
|
@@ -1834,19 +1834,19 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log_info(LD_DIR, "Successfully loaded consensus.");
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
|
|
|
if (status_code != 200) {
|
|
|
log_warn(LD_DIR,
|
|
|
"Received http status code %d (%s) from server "
|
|
|
"'%s:%d' while fetching \"/tor/keys/%s\".",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port, conn->requested_resource);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port, conn->requested_resource);
|
|
|
connection_dir_download_cert_failed(conn, status_code);
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
|
return -1;
|
|
|
}
|
|
|
log_info(LD_DIR,"Received authority certificates (size %d) from server "
|
|
|
- "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
|
|
|
+ "'%s:%d'", (int)body_len, conn->base_.address, conn->base_.port);
|
|
|
if (trusted_dirs_load_certs_from_string(body, 0, 1)<0) {
|
|
|
log_warn(LD_DIR, "Unable to parse fetched certificates");
|
|
|
/* if we fetched more than one and only some failed, the successful
|
|
@@ -1857,17 +1857,17 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log_info(LD_DIR, "Successfully loaded certificates from fetch.");
|
|
|
}
|
|
|
}
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
|
|
|
const char *msg;
|
|
|
int st;
|
|
|
log_info(LD_DIR,"Got votes (size %d) from server %s:%d",
|
|
|
- (int)body_len, conn->_base.address, conn->_base.port);
|
|
|
+ (int)body_len, conn->base_.address, conn->base_.port);
|
|
|
if (status_code != 200) {
|
|
|
log_warn(LD_DIR,
|
|
|
"Received http status code %d (%s) from server "
|
|
|
"'%s:%d' while fetching \"/tor/status-vote/next/%s.z\".",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port, conn->requested_resource);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port, conn->requested_resource);
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
|
return -1;
|
|
|
}
|
|
@@ -1878,35 +1878,35 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log_info(LD_DIR, "Added vote(s) successfully [msg: %s]", msg);
|
|
|
}
|
|
|
}
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
|
|
|
const char *msg = NULL;
|
|
|
log_info(LD_DIR,"Got detached signatures (size %d) from server %s:%d",
|
|
|
- (int)body_len, conn->_base.address, conn->_base.port);
|
|
|
+ (int)body_len, conn->base_.address, conn->base_.port);
|
|
|
if (status_code != 200) {
|
|
|
log_warn(LD_DIR,
|
|
|
"Received http status code %d (%s) from server '%s:%d' while fetching "
|
|
|
"\"/tor/status-vote/next/consensus-signatures.z\".",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
|
return -1;
|
|
|
}
|
|
|
- if (dirvote_add_signatures(body, conn->_base.address, &msg)<0) {
|
|
|
+ if (dirvote_add_signatures(body, conn->base_.address, &msg)<0) {
|
|
|
log_warn(LD_DIR, "Problem adding detached signatures from %s:%d: %s",
|
|
|
- conn->_base.address, conn->_base.port, msg?msg:"???");
|
|
|
+ conn->base_.address, conn->base_.port, msg?msg:"???");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
- conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
|
|
|
- int was_ei = conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO;
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
|
|
+ conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
|
|
|
+ int was_ei = conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO;
|
|
|
smartlist_t *which = NULL;
|
|
|
int n_asked_for = 0;
|
|
|
int descriptor_digests = conn->requested_resource &&
|
|
|
!strcmpstart(conn->requested_resource,"d/");
|
|
|
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);
|
|
|
+ (int)body_len, conn->base_.address, conn->base_.port);
|
|
|
if (conn->requested_resource &&
|
|
|
(!strcmpstart(conn->requested_resource,"d/") ||
|
|
|
!strcmpstart(conn->requested_resource,"fp/"))) {
|
|
@@ -1924,8 +1924,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log_fn(dir_okay ? LOG_INFO : LOG_WARN, LD_DIR,
|
|
|
"Received http status code %d (%s) from server '%s:%d' "
|
|
|
"while fetching \"/tor/server/%s\". I'll try again soon.",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port, conn->requested_resource);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port, conn->requested_resource);
|
|
|
if (!which) {
|
|
|
connection_dir_download_routerdesc_failed(conn);
|
|
|
} else {
|
|
@@ -1959,7 +1959,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
// descriptor_digests, conn->router_purpose);
|
|
|
if (load_downloaded_routers(body, which, descriptor_digests,
|
|
|
conn->router_purpose,
|
|
|
- conn->_base.address))
|
|
|
+ conn->base_.address))
|
|
|
directory_info_has_arrived(now, 0);
|
|
|
}
|
|
|
}
|
|
@@ -1967,7 +1967,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log_info(LD_DIR, "Received %d/%d %s requested from %s:%d",
|
|
|
n_asked_for-smartlist_len(which), n_asked_for,
|
|
|
was_ei ? "extra-info documents" : "router descriptors",
|
|
|
- conn->_base.address, (int)conn->_base.port);
|
|
|
+ conn->base_.address, (int)conn->base_.port);
|
|
|
if (smartlist_len(which)) {
|
|
|
dir_routerdesc_download_failed(which, status_code,
|
|
|
conn->router_purpose,
|
|
@@ -1979,12 +1979,12 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
if (directory_conn_is_self_reachability_test(conn))
|
|
|
router_dirport_found_reachable();
|
|
|
}
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
|
|
|
smartlist_t *which = NULL;
|
|
|
log_info(LD_DIR,"Received answer to microdescriptor request (status %d, "
|
|
|
"size %d) from server '%s:%d'",
|
|
|
- status_code, (int)body_len, conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, (int)body_len, conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
tor_assert(conn->requested_resource &&
|
|
|
!strcmpstart(conn->requested_resource, "d/"));
|
|
|
which = smartlist_new();
|
|
@@ -1995,8 +1995,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
log_info(LD_DIR, "Received status code %d (%s) from server "
|
|
|
"'%s:%d' while fetching \"/tor/micro/%s\". I'll try again "
|
|
|
"soon.",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- (int)conn->_base.port, conn->requested_resource);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ (int)conn->base_.port, conn->requested_resource);
|
|
|
dir_microdesc_download_failed(which, status_code);
|
|
|
SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
|
|
|
smartlist_free(which);
|
|
@@ -2017,7 +2017,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_DIR) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_DIR) {
|
|
|
switch (status_code) {
|
|
|
case 200: {
|
|
|
trusted_dir_server_t *ds =
|
|
@@ -2043,7 +2043,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
"descriptor: finished.");
|
|
|
control_event_server_status(
|
|
|
LOG_NOTICE, "ACCEPTED_SERVER_DESCRIPTOR DIRAUTH=%s:%d",
|
|
|
- conn->_base.address, conn->_base.port);
|
|
|
+ conn->base_.address, conn->base_.port);
|
|
|
|
|
|
ds->has_accepted_serverdesc = 1;
|
|
|
if (directories_have_accepted_server_descriptor())
|
|
@@ -2053,72 +2053,72 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
case 400:
|
|
|
log_warn(LD_GENERAL,"http status 400 (%s) response from "
|
|
|
"dirserver '%s:%d'. Please correct.",
|
|
|
- escaped(reason), conn->_base.address, conn->_base.port);
|
|
|
+ escaped(reason), conn->base_.address, conn->base_.port);
|
|
|
control_event_server_status(LOG_WARN,
|
|
|
"BAD_SERVER_DESCRIPTOR DIRAUTH=%s:%d REASON=\"%s\"",
|
|
|
- conn->_base.address, conn->_base.port, escaped(reason));
|
|
|
+ conn->base_.address, conn->base_.port, escaped(reason));
|
|
|
break;
|
|
|
default:
|
|
|
log_warn(LD_GENERAL,
|
|
|
"http status %d (%s) reason unexpected while uploading "
|
|
|
"descriptor to server '%s:%d').",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
break;
|
|
|
}
|
|
|
/* return 0 in all cases, since we don't want to mark any
|
|
|
* dirservers down just because they don't like us. */
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_VOTE) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_VOTE) {
|
|
|
switch (status_code) {
|
|
|
case 200: {
|
|
|
log_notice(LD_DIR,"Uploaded a vote to dirserver %s:%d",
|
|
|
- conn->_base.address, conn->_base.port);
|
|
|
+ conn->base_.address, conn->base_.port);
|
|
|
}
|
|
|
break;
|
|
|
case 400:
|
|
|
log_warn(LD_DIR,"http status 400 (%s) response after uploading "
|
|
|
"vote to dirserver '%s:%d'. Please correct.",
|
|
|
- escaped(reason), conn->_base.address, conn->_base.port);
|
|
|
+ escaped(reason), conn->base_.address, conn->base_.port);
|
|
|
break;
|
|
|
default:
|
|
|
log_warn(LD_GENERAL,
|
|
|
"http status %d (%s) reason unexpected while uploading "
|
|
|
"vote to server '%s:%d').",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
break;
|
|
|
}
|
|
|
/* return 0 in all cases, since we don't want to mark any
|
|
|
* dirservers down just because they don't like us. */
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_SIGNATURES) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_SIGNATURES) {
|
|
|
switch (status_code) {
|
|
|
case 200: {
|
|
|
log_notice(LD_DIR,"Uploaded signature(s) to dirserver %s:%d",
|
|
|
- conn->_base.address, conn->_base.port);
|
|
|
+ conn->base_.address, conn->base_.port);
|
|
|
}
|
|
|
break;
|
|
|
case 400:
|
|
|
log_warn(LD_DIR,"http status 400 (%s) response after uploading "
|
|
|
"signatures to dirserver '%s:%d'. Please correct.",
|
|
|
- escaped(reason), conn->_base.address, conn->_base.port);
|
|
|
+ escaped(reason), conn->base_.address, conn->base_.port);
|
|
|
break;
|
|
|
default:
|
|
|
log_warn(LD_GENERAL,
|
|
|
"http status %d (%s) reason unexpected while uploading "
|
|
|
"signatures to server '%s:%d').",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
break;
|
|
|
}
|
|
|
/* return 0 in all cases, since we don't want to mark any
|
|
|
* dirservers down just because they don't like us. */
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_RENDDESC) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_RENDDESC) {
|
|
|
tor_assert(conn->rend_data);
|
|
|
log_info(LD_REND,"Received rendezvous descriptor (size %d, status %d "
|
|
|
"(%s))",
|
|
@@ -2136,7 +2136,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
} else {
|
|
|
/* Success, or at least there's a v2 descriptor already
|
|
|
* present. Notify pending connections about this. */
|
|
|
- conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
|
|
|
+ conn->base_.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
|
|
|
rend_client_desc_trynow(conn->rend_data->onion_address);
|
|
|
}
|
|
|
break;
|
|
@@ -2152,13 +2152,13 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
default:
|
|
|
log_warn(LD_REND,"http status %d (%s) response unexpected while "
|
|
|
"fetching hidden service descriptor (server '%s:%d').",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_FETCH_RENDDESC_V2) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_FETCH_RENDDESC_V2) {
|
|
|
tor_assert(conn->rend_data);
|
|
|
log_info(LD_REND,"Received rendezvous descriptor (size %d, status %d "
|
|
|
"(%s))",
|
|
@@ -2177,13 +2177,13 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
* and _not_ performing another request. */
|
|
|
log_info(LD_REND, "Successfully fetched v2 rendezvous "
|
|
|
"descriptor, but we already have a v0 descriptor.");
|
|
|
- conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
|
|
|
+ conn->base_.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
|
|
|
break;
|
|
|
default:
|
|
|
/* success. notify pending connections about this. */
|
|
|
log_info(LD_REND, "Successfully fetched v2 rendezvous "
|
|
|
"descriptor.");
|
|
|
- conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
|
|
|
+ conn->base_.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
|
|
|
rend_client_desc_trynow(conn->rend_data->onion_address);
|
|
|
break;
|
|
|
}
|
|
@@ -2205,14 +2205,14 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
"http status %d (%s) response unexpected while "
|
|
|
"fetching v2 hidden service descriptor (server '%s:%d'). "
|
|
|
"Retrying at another directory.",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_RENDDESC ||
|
|
|
- conn->_base.purpose == DIR_PURPOSE_UPLOAD_RENDDESC_V2) {
|
|
|
+ if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_RENDDESC ||
|
|
|
+ conn->base_.purpose == DIR_PURPOSE_UPLOAD_RENDDESC_V2) {
|
|
|
log_info(LD_REND,"Uploaded rendezvous descriptor (status %d "
|
|
|
"(%s))",
|
|
|
status_code, escaped(reason));
|
|
@@ -2225,17 +2225,17 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|
|
case 400:
|
|
|
log_warn(LD_REND,"http status 400 (%s) response from dirserver "
|
|
|
"'%s:%d'. Malformed rendezvous descriptor?",
|
|
|
- escaped(reason), conn->_base.address, conn->_base.port);
|
|
|
+ escaped(reason), conn->base_.address, conn->base_.port);
|
|
|
break;
|
|
|
default:
|
|
|
log_warn(LD_REND,"http status %d (%s) response unexpected (server "
|
|
|
"'%s:%d').",
|
|
|
- status_code, escaped(reason), conn->_base.address,
|
|
|
- conn->_base.port);
|
|
|
+ status_code, escaped(reason), conn->base_.address,
|
|
|
+ conn->base_.port);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- note_client_request(conn->_base.purpose, was_compressed, orig_len);
|
|
|
+ note_client_request(conn->base_.purpose, was_compressed, orig_len);
|
|
|
tor_free(body); tor_free(headers); tor_free(reason);
|
|
|
return 0;
|
|
|
}
|
|
@@ -2245,9 +2245,9 @@ int
|
|
|
connection_dir_reached_eof(dir_connection_t *conn)
|
|
|
{
|
|
|
int retval;
|
|
|
- if (conn->_base.state != DIR_CONN_STATE_CLIENT_READING) {
|
|
|
+ if (conn->base_.state != DIR_CONN_STATE_CLIENT_READING) {
|
|
|
log_info(LD_HTTP,"conn reached eof, not reading. [state=%d] Closing.",
|
|
|
- conn->_base.state);
|
|
|
+ conn->base_.state);
|
|
|
connection_close_immediate(TO_CONN(conn)); /* error: give up on flushing */
|
|
|
connection_mark_for_close(TO_CONN(conn));
|
|
|
return -1;
|
|
@@ -2255,7 +2255,7 @@ connection_dir_reached_eof(dir_connection_t *conn)
|
|
|
|
|
|
retval = connection_dir_client_reached_eof(conn);
|
|
|
if (retval == 0) /* success */
|
|
|
- conn->_base.state = DIR_CONN_STATE_CLIENT_FINISHED;
|
|
|
+ conn->base_.state = DIR_CONN_STATE_CLIENT_FINISHED;
|
|
|
connection_mark_for_close(TO_CONN(conn));
|
|
|
return retval;
|
|
|
}
|
|
@@ -2273,7 +2273,7 @@ int
|
|
|
connection_dir_process_inbuf(dir_connection_t *conn)
|
|
|
{
|
|
|
tor_assert(conn);
|
|
|
- tor_assert(conn->_base.type == CONN_TYPE_DIR);
|
|
|
+ tor_assert(conn->base_.type == CONN_TYPE_DIR);
|
|
|
|
|
|
/* Directory clients write, then read data until they receive EOF;
|
|
|
* directory servers read data until they get an HTTP command, then
|
|
@@ -2282,7 +2282,7 @@ connection_dir_process_inbuf(dir_connection_t *conn)
|
|
|
*/
|
|
|
|
|
|
/* If we're on the dirserver side, look for a command. */
|
|
|
- if (conn->_base.state == DIR_CONN_STATE_SERVER_COMMAND_WAIT) {
|
|
|
+ if (conn->base_.state == DIR_CONN_STATE_SERVER_COMMAND_WAIT) {
|
|
|
if (directory_handle_command(conn) < 0) {
|
|
|
connection_mark_for_close(TO_CONN(conn));
|
|
|
return -1;
|
|
@@ -2297,7 +2297,7 @@ connection_dir_process_inbuf(dir_connection_t *conn)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- if (!conn->_base.inbuf_reached_eof)
|
|
|
+ if (!conn->base_.inbuf_reached_eof)
|
|
|
log_debug(LD_HTTP,"Got data, not eof. Leaving on inbuf.");
|
|
|
return 0;
|
|
|
}
|
|
@@ -2370,12 +2370,12 @@ write_http_response_header_impl(dir_connection_t *conn, ssize_t length,
|
|
|
tor_snprintf(cp, sizeof(tmp)-(cp-tmp), "Content-Type: %s\r\n", type);
|
|
|
cp += strlen(cp);
|
|
|
}
|
|
|
- if (!is_local_addr(&conn->_base.addr)) {
|
|
|
+ if (!is_local_addr(&conn->base_.addr)) {
|
|
|
/* Don't report the source address for a nearby/private connection.
|
|
|
* Otherwise we tend to mis-report in cases where incoming ports are
|
|
|
* being forwarded to a Tor server running behind the firewall. */
|
|
|
tor_snprintf(cp, sizeof(tmp)-(cp-tmp),
|
|
|
- X_ADDRESS_HEADER "%s\r\n", conn->_base.address);
|
|
|
+ X_ADDRESS_HEADER "%s\r\n", conn->base_.address);
|
|
|
cp += strlen(cp);
|
|
|
}
|
|
|
if (encoding) {
|
|
@@ -2627,7 +2627,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
|
|
|
|
|
log_debug(LD_DIRSERV,"Received GET command.");
|
|
|
|
|
|
- conn->_base.state = DIR_CONN_STATE_SERVER_WRITING;
|
|
|
+ conn->base_.state = DIR_CONN_STATE_SERVER_WRITING;
|
|
|
|
|
|
if (parse_http_url(headers, &url) < 0) {
|
|
|
write_http_status_line(conn, 400, "Bad request");
|
|
@@ -3220,7 +3220,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
|
|
}
|
|
|
|
|
|
if (options->BridgeAuthoritativeDir &&
|
|
|
- options->_BridgePassword_AuthDigest &&
|
|
|
+ options->BridgePassword_AuthDigest_ &&
|
|
|
connection_dir_is_encrypted(conn) &&
|
|
|
!strcmp(url,"/tor/networkstatus-bridges")) {
|
|
|
char *status;
|
|
@@ -3233,7 +3233,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
|
|
/* now make sure the password is there and right */
|
|
|
if (!header ||
|
|
|
tor_memneq(digest,
|
|
|
- options->_BridgePassword_AuthDigest, DIGEST256_LEN)) {
|
|
|
+ options->BridgePassword_AuthDigest_, DIGEST256_LEN)) {
|
|
|
write_http_status_line(conn, 404, "Not found");
|
|
|
tor_free(header);
|
|
|
goto done;
|
|
@@ -3289,7 +3289,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
|
|
}while(0);
|
|
|
|
|
|
if (!strcmp(url,"/tor/mallinfo.txt") &&
|
|
|
- (tor_addr_eq_ipv4h(&conn->_base.addr, 0x7f000001ul))) {
|
|
|
+ (tor_addr_eq_ipv4h(&conn->base_.addr, 0x7f000001ul))) {
|
|
|
char *result;
|
|
|
size_t len;
|
|
|
struct mallinfo mi;
|
|
@@ -3344,7 +3344,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
|
|
|
log_debug(LD_DIRSERV,"Received POST command.");
|
|
|
|
|
|
- conn->_base.state = DIR_CONN_STATE_SERVER_WRITING;
|
|
|
+ conn->base_.state = DIR_CONN_STATE_SERVER_WRITING;
|
|
|
|
|
|
if (parse_http_url(headers, &url) < 0) {
|
|
|
write_http_status_line(conn, 400, "Bad request");
|
|
@@ -3359,13 +3359,13 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
case -2:
|
|
|
log_info(LD_REND, "Rejected v2 rend descriptor (length %d) from %s "
|
|
|
"since we're not currently a hidden service directory.",
|
|
|
- (int)body_len, conn->_base.address);
|
|
|
+ (int)body_len, conn->base_.address);
|
|
|
write_http_status_line(conn, 503, "Currently not acting as v2 "
|
|
|
"hidden service directory");
|
|
|
break;
|
|
|
case -1:
|
|
|
log_warn(LD_REND, "Rejected v2 rend descriptor (length %d) from %s.",
|
|
|
- (int)body_len, conn->_base.address);
|
|
|
+ (int)body_len, conn->base_.address);
|
|
|
write_http_status_line(conn, 400,
|
|
|
"Invalid v2 service descriptor rejected");
|
|
|
break;
|
|
@@ -3390,7 +3390,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
uint8_t purpose = authdir_mode_bridge(options) ?
|
|
|
ROUTER_PURPOSE_BRIDGE : ROUTER_PURPOSE_GENERAL;
|
|
|
was_router_added_t r = dirserv_add_multiple_descriptors(body, purpose,
|
|
|
- conn->_base.address, &msg);
|
|
|
+ conn->base_.address, &msg);
|
|
|
tor_assert(msg);
|
|
|
if (WRA_WAS_ADDED(r))
|
|
|
dirserv_get_directory(); /* rebuild and write to disk */
|
|
@@ -3400,7 +3400,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
log_info(LD_DIRSERV,
|
|
|
"Problematic router descriptor or extra-info from %s "
|
|
|
"(\"%s\").",
|
|
|
- conn->_base.address, msg);
|
|
|
+ conn->base_.address, msg);
|
|
|
write_http_status_line(conn, 400, msg);
|
|
|
} else if (r == ROUTER_ADDED_SUCCESSFULLY) {
|
|
|
write_http_status_line(conn, 200, msg);
|
|
@@ -3411,7 +3411,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
log_info(LD_DIRSERV,
|
|
|
"Rejected router descriptor or extra-info from %s "
|
|
|
"(\"%s\").",
|
|
|
- conn->_base.address, msg);
|
|
|
+ conn->base_.address, msg);
|
|
|
write_http_status_line(conn, 400, msg);
|
|
|
}
|
|
|
goto done;
|
|
@@ -3424,7 +3424,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
if (rend_cache_store(body, body_len, 1, NULL) < 0) {
|
|
|
log_fn(LOG_PROTOCOL_WARN, LD_DIRSERV,
|
|
|
"Rejected rend descriptor (length %d) from %s.",
|
|
|
- (int)body_len, conn->_base.address);
|
|
|
+ (int)body_len, conn->base_.address);
|
|
|
write_http_status_line(conn, 400,
|
|
|
"Invalid v0 service descriptor rejected");
|
|
|
} else {
|
|
@@ -3442,7 +3442,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
} else {
|
|
|
tor_assert(msg);
|
|
|
log_warn(LD_DIRSERV, "Rejected vote from %s (\"%s\").",
|
|
|
- conn->_base.address, msg);
|
|
|
+ conn->base_.address, msg);
|
|
|
write_http_status_line(conn, status, msg);
|
|
|
}
|
|
|
goto done;
|
|
@@ -3451,11 +3451,11 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|
|
if (authdir_mode_v3(options) &&
|
|
|
!strcmp(url,"/tor/post/consensus-signature")) { /* sigs on consensus. */
|
|
|
const char *msg = NULL;
|
|
|
- if (dirvote_add_signatures(body, conn->_base.address, &msg)>=0) {
|
|
|
+ if (dirvote_add_signatures(body, conn->base_.address, &msg)>=0) {
|
|
|
write_http_status_line(conn, 200, msg?msg:"Signatures stored");
|
|
|
} else {
|
|
|
log_warn(LD_DIR, "Unable to store signatures posted by %s: %s",
|
|
|
- conn->_base.address, msg?msg:"???");
|
|
|
+ conn->base_.address, msg?msg:"???");
|
|
|
write_http_status_line(conn, 400, msg?msg:"Unable to store signatures");
|
|
|
}
|
|
|
goto done;
|
|
@@ -3482,7 +3482,7 @@ directory_handle_command(dir_connection_t *conn)
|
|
|
int r;
|
|
|
|
|
|
tor_assert(conn);
|
|
|
- tor_assert(conn->_base.type == CONN_TYPE_DIR);
|
|
|
+ tor_assert(conn->base_.type == CONN_TYPE_DIR);
|
|
|
|
|
|
switch (connection_fetch_from_buf_http(TO_CONN(conn),
|
|
|
&headers, MAX_HEADERS_SIZE,
|
|
@@ -3490,7 +3490,7 @@ directory_handle_command(dir_connection_t *conn)
|
|
|
case -1: /* overflow */
|
|
|
log_warn(LD_DIRSERV,
|
|
|
"Request too large from address '%s' to DirPort. Closing.",
|
|
|
- safe_str(conn->_base.address));
|
|
|
+ safe_str(conn->base_.address));
|
|
|
return -1;
|
|
|
case 0:
|
|
|
log_debug(LD_DIRSERV,"command not all here yet.");
|
|
@@ -3524,7 +3524,7 @@ int
|
|
|
connection_dir_finished_flushing(dir_connection_t *conn)
|
|
|
{
|
|
|
tor_assert(conn);
|
|
|
- tor_assert(conn->_base.type == CONN_TYPE_DIR);
|
|
|
+ tor_assert(conn->base_.type == CONN_TYPE_DIR);
|
|
|
|
|
|
/* Note that we have finished writing the directory response. For direct
|
|
|
* connections this means we're done, for tunneled connections its only
|
|
@@ -3536,11 +3536,11 @@ connection_dir_finished_flushing(dir_connection_t *conn)
|
|
|
geoip_change_dirreq_state(TO_CONN(conn)->global_identifier,
|
|
|
DIRREQ_DIRECT,
|
|
|
DIRREQ_FLUSHING_DIR_CONN_FINISHED);
|
|
|
- switch (conn->_base.state) {
|
|
|
+ switch (conn->base_.state) {
|
|
|
case DIR_CONN_STATE_CONNECTING:
|
|
|
case DIR_CONN_STATE_CLIENT_SENDING:
|
|
|
log_debug(LD_DIR,"client finished sending command.");
|
|
|
- conn->_base.state = DIR_CONN_STATE_CLIENT_READING;
|
|
|
+ conn->base_.state = DIR_CONN_STATE_CLIENT_READING;
|
|
|
return 0;
|
|
|
case DIR_CONN_STATE_SERVER_WRITING:
|
|
|
if (conn->dir_spool_src != DIR_SPOOL_NONE) {
|
|
@@ -3561,7 +3561,7 @@ connection_dir_finished_flushing(dir_connection_t *conn)
|
|
|
return 0;
|
|
|
default:
|
|
|
log_warn(LD_BUG,"called in unexpected state %d.",
|
|
|
- conn->_base.state);
|
|
|
+ conn->base_.state);
|
|
|
tor_fragile_assert();
|
|
|
return -1;
|
|
|
}
|
|
@@ -3574,13 +3574,13 @@ int
|
|
|
connection_dir_finished_connecting(dir_connection_t *conn)
|
|
|
{
|
|
|
tor_assert(conn);
|
|
|
- tor_assert(conn->_base.type == CONN_TYPE_DIR);
|
|
|
- tor_assert(conn->_base.state == DIR_CONN_STATE_CONNECTING);
|
|
|
+ tor_assert(conn->base_.type == CONN_TYPE_DIR);
|
|
|
+ tor_assert(conn->base_.state == DIR_CONN_STATE_CONNECTING);
|
|
|
|
|
|
log_debug(LD_HTTP,"Dir connection to router %s:%u established.",
|
|
|
- conn->_base.address,conn->_base.port);
|
|
|
+ conn->base_.address,conn->base_.port);
|
|
|
|
|
|
- conn->_base.state = DIR_CONN_STATE_CLIENT_SENDING; /* start flushing conn */
|
|
|
+ conn->base_.state = DIR_CONN_STATE_CLIENT_SENDING; /* start flushing conn */
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -3817,7 +3817,7 @@ dir_microdesc_download_failed(smartlist_t *failed,
|
|
|
/** Helper. Compare two fp_pair_t objects, and return negative, 0, or
|
|
|
* positive as appropriate. */
|
|
|
static int
|
|
|
-_compare_pairs(const void **a, const void **b)
|
|
|
+compare_pairs_(const void **a, const void **b)
|
|
|
{
|
|
|
const fp_pair_t *fp1 = *a, *fp2 = *b;
|
|
|
int r;
|
|
@@ -3868,8 +3868,8 @@ dir_split_resource_into_fingerprint_pairs(const char *res,
|
|
|
smartlist_free(pairs_tmp);
|
|
|
|
|
|
/* Uniq-and-sort */
|
|
|
- smartlist_sort(pairs_result, _compare_pairs);
|
|
|
- smartlist_uniq(pairs_result, _compare_pairs, _tor_free);
|
|
|
+ smartlist_sort(pairs_result, compare_pairs_);
|
|
|
+ smartlist_uniq(pairs_result, compare_pairs_, tor_free_);
|
|
|
|
|
|
smartlist_add_all(pairs_out, pairs_result);
|
|
|
smartlist_free(pairs_result);
|