Adds getinfo:
"status/good-server-descriptor"
"status/or-reachability-succeeded"
"status/dir-reachability-succeeded"
and splits out the REACHABILITY_SUCCEEDED event into:
OR_REACHABILITY_SUCCEEDED
DIR_REACHABILITY_SUCCEEDED
This makes sense because it maintains the one-to-one relationship between
getinfo requests and status-events, getinfo reachability-succeeded would be
too ambiguous to be useful, and makes writing controllers simpler because it
is easier to identify the meaning of a status event by the 'action' of *all*
status events rather than, in special cases, a combination of the action and
one or more of the arguments.
Index: src/or/control.c
===================================================================
--- src/or/control.c (revision 11403)
+++ src/or/control.c (working copy)
@@ -1590,6 +1590,12 @@
*answer = tor_strdup(has_completed_circuit ? "1" : "0");
} else if (!strcmp(question, "status/enough-dir-info")) {
*answer = tor_strdup(router_have_minimum_dir_info() ? "1" : "0");
+ } else if (!strcmp(question, "status/good-server-descriptor")) {
+ *answer = tor_strdup(have_good_server_descriptor() ? "1" : "0");
+ } else if (!strcmp(question, "status/or-reachability-succeeded")) {
+ *answer = tor_strdup(check_whether_orport_reachable() ? "1" : "0");
+ } else if (!strcmp(question, "status/dir-reachability-succeeded")) {
+ *answer = tor_strdup(check_whether_dirport_reachable() ? "1" : "0");
} else if (!strcmpstart(question, "status/version/")) {
combined_version_status_t st;
int is_server = server_mode(get_options());
Index: src/or/or.h
===================================================================
--- src/or/or.h (revision 11403)
+++ src/or/or.h (working copy)
@@ -2761,6 +2761,7 @@
/********************************* directory.c ***************************/
+int have_good_server_descriptor(void);
char *authority_type_to_string(authority_type_t auth);
void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
authority_type_t type, const char *payload,
Index: src/or/directory.c
===================================================================
--- src/or/directory.c (revision 11403)
+++ src/or/directory.c (working copy)
@@ -183,6 +183,25 @@
return 0;
}
+/** Return true iff all trusted directory servers have accepted our
+ * server descriptor. */
+int
+have_good_server_descriptor(void)
+{
+ int all_done = 1;
+ smartlist_t *servers;
+ servers = router_get_trusted_dir_servers();
+ SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
+ if ((d->type & (V1_AUTHORITY|V2_AUTHORITY)) &&
+ !d->has_accepted_serverdesc) {
+ all_done = 0;
+ break;
+ }
+ });
+ return all_done;
+}
+
+
/** Start a connection to every suitable directory authority, using
* connection purpose 'purpose' and uploading the payload 'payload'
* (length 'payload_len'). The purpose should be one of
@@ -1385,10 +1404,8 @@
if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_DIR) {
switch (status_code) {
case 200: {
- int all_done = 1;
trusted_dir_server_t *ds =
router_get_trusteddirserver_by_digest(conn->identity_digest);
- smartlist_t *servers;
log_info(LD_GENERAL,"eof (status 200) after uploading server "
"descriptor: finished.");
control_event_server_status(
@@ -1396,15 +1413,7 @@
conn->_base.address, conn->_base.port);
ds->has_accepted_serverdesc = 1;
- servers = router_get_trusted_dir_servers();
- SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
- if ((d->type & (V1_AUTHORITY|V2_AUTHORITY)) &&
- !d->has_accepted_serverdesc) {
- all_done = 0;
- break;
- }
- });
- if (all_done)
+ if (have_good_server_descriptor())
control_event_server_status(LOG_NOTICE, "GOOD_SERVER_DESCRIPTOR");
}
break;
Index: src/or/router.c
===================================================================
--- src/or/router.c (revision 11403)
+++ src/or/router.c (working copy)
@@ -649,7 +649,7 @@
if (!me)
return;
control_event_server_status(LOG_NOTICE,
- "REACHABILITY_SUCCEEDED ORADDRESS=%s:%d",
+ "OR_REACHABILITY_SUCCEEDED ORADDRESS=%s:%d",
me->address, me->dir_port);
}
}
@@ -667,7 +667,7 @@
if (!me)
return;
control_event_server_status(LOG_NOTICE,
- "REACHABILITY_SUCCEEDED DIRADDRESS=%s:%d",
+ "DIR_REACHABILITY_SUCCEEDED_DIR DIRADDRESS=%s:%d",
me->address, me->dir_port);
}
}
Index: doc/spec/control-spec.txt
===================================================================
--- doc/spec/control-spec.txt (revision 11403)
+++ doc/spec/control-spec.txt (working copy)
@@ -524,6 +524,9 @@
"status/circuit-established"
"status/enough-dir-info"
+ "status/good-server-descriptor"
+ "status/or-reachability-succeeded"
+ "status/dir-reachability-succeeded"
"status/..."
These provide the current internal Tor values for various Tor
states. See Section 4.1.10 for explanations. (Only a few of the
@@ -1318,11 +1321,14 @@
{This event could effect the controller's idea of server status, but
the controller should not interrupt the user to tell them so.}
- REACHABILITY_SUCCEEDED
+ OR_REACHABILITY_SUCCEEDED
"ORADDRESS=IP:port"
+ We successfully verified the reachability of our external OR port.
+
+ DIR_REACHABILITY_SUCCEEDED
"DIRADDRESS=IP:port"
- We successfully verified the reachability of our external OR port or
- directory port.
+ We successfully verified the reachability of our external directory
+ port.
{This event could effect the controller's idea of server status, but
the controller should not interrupt the user to tell them so.}
Attachment:
signature.asc
Description: This is a digitally signed message part.