mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r12708@catbus: nickm | 2007-05-10 15:18:08 -0400
Patch from shibz: implement a getinfo status/version/... so a controller can tell whether the current version is recommended, whether any versions are good, and how many authorities agree. svn:r10162
This commit is contained in:
@@ -89,6 +89,9 @@ Changes in version 0.2.0.1-alpha - 2007-??-??
|
||||
- Let the controller specify HOP=%d as an argument to ATTACHSTREAM,
|
||||
so we can exit from the middle of the circuit.
|
||||
- Implement "getinfo status/circuit-established".
|
||||
- Implement "getinfo status/version/..." so a controller can tell whether
|
||||
the current version is recommended, and whether any versions are good,
|
||||
and how many authorities agree. (Patch from shibz.)
|
||||
|
||||
o Minor features (other):
|
||||
- Correctly report Windows 95 OSR2 and Windows 98 SE.
|
||||
|
||||
@@ -15,6 +15,9 @@ P - phobos claims
|
||||
|
||||
Documentation and testing on 0.1.2.x-final series
|
||||
|
||||
- Pending backports for 0.1.2.x:
|
||||
- r10148: Open cached-routers with FILE_SHARE_READ on win32.
|
||||
|
||||
N - Test guard unreachable logic; make sure that we actually attempt to
|
||||
connect to guards that we think are unreachable from time to time.
|
||||
Make sure that we don't freak out when the network is down.
|
||||
|
||||
+39
-1
@@ -1463,8 +1463,40 @@ getinfo_helper_events(control_connection_t *control_conn,
|
||||
SMARTLIST_FOREACH(mappings, char *, cp, tor_free(cp));
|
||||
smartlist_free(mappings);
|
||||
} else if (!strcmpstart(question, "status/")) {
|
||||
/* Note that status/ is not a catch-all for events; there's only supposed
|
||||
* to be a status GETINFO if there's a corresponding STATUS event. */
|
||||
if (!strcmp(question, "status/circuit-established")) {
|
||||
*answer = tor_strdup(has_completed_circuit ? "1" : "0");
|
||||
} else if (!strcmpstart(question, "status/version/")) {
|
||||
combined_version_status_t st;
|
||||
int is_server = server_mode(get_options());
|
||||
char *recommended;
|
||||
recommended = compute_recommended_versions(time(NULL),
|
||||
!is_server, VERSION, &st);
|
||||
if (!strcmp(question, "status/version/recommended")) {
|
||||
*answer = recommended;
|
||||
return 0;
|
||||
}
|
||||
tor_free(recommended);
|
||||
if (!strcmp(question, "status/version/current")) {
|
||||
switch (st.consensus)
|
||||
{
|
||||
case VS_RECOMMENDED: *answer = tor_strdup("recommended"); break;
|
||||
case VS_OLD: *answer = tor_strdup("obsolete"); break;
|
||||
case VS_NEW: *answer = tor_strdup("new"); break;
|
||||
case VS_NEW_IN_SERIES: *answer = tor_strdup("new in series"); break;
|
||||
case VS_UNRECOMMENDED: *answer = tor_strdup("unrecommended"); break;
|
||||
default: tor_fragile_assert();
|
||||
}
|
||||
} else if (!strcmp(question, "status/version/num-versioning")) {
|
||||
char s[33];
|
||||
tor_snprintf(s, sizeof(s), "%d", st.n_versioning);
|
||||
*answer = tor_strdup(s);
|
||||
} else if (!strcmp(question, "status/version/num-concurring")) {
|
||||
char s[33];
|
||||
tor_snprintf(s, sizeof(s), "%d", st.n_concurring);
|
||||
*answer = tor_strdup(s);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -1547,7 +1579,13 @@ static const getinfo_item_t getinfo_items[] = {
|
||||
PREFIX("status/", events, NULL),
|
||||
DOC("status/circuit-established",
|
||||
"Whether we think client functionality is working."),
|
||||
|
||||
/* DOCDOC specify status/version/ */
|
||||
DOC("status/version/recommended", "List of currently recommended versions."),
|
||||
DOC("status/version/current", "Status of the current version."),
|
||||
DOC("status/version/num-versioning", "Number of versioning authorities."),
|
||||
DOC("status/version/num-concurring",
|
||||
"Number of versioning authorities agreeing on the status of the "
|
||||
"current version"),
|
||||
ITEM("address", misc, "IP address of this Tor host, if we can guess it."),
|
||||
ITEM("dir-usage", misc, "Breakdown of bytes transferred over DirPort."),
|
||||
PREFIX("dir/server/", dir,"Router descriptors as retrieved from a DirPort."),
|
||||
|
||||
+12
@@ -3193,6 +3193,18 @@ typedef enum version_status_t {
|
||||
VS_UNRECOMMENDED=4 /**< This version is not recommended (general case) */
|
||||
} version_status_t;
|
||||
|
||||
typedef struct combined_version_status_t {
|
||||
/** How many networkstatuses claim to know about versions? */
|
||||
int n_versioning;
|
||||
/** What do the majority of networkstatuses believe about this version? */
|
||||
version_status_t consensus;
|
||||
/** How many networkstatuses constitute the majority? */
|
||||
int n_concurring;
|
||||
} combined_version_status_t;
|
||||
char *compute_recommended_versions(time_t now, int client,
|
||||
const char *my_version,
|
||||
combined_version_status_t *status_out);
|
||||
|
||||
int router_get_router_hash(const char *s, char *digest);
|
||||
int router_get_dir_hash(const char *s, char *digest);
|
||||
int router_get_runningrouters_hash(const char *s, char *digest);
|
||||
|
||||
+2
-12
@@ -3384,19 +3384,9 @@ networkstatus_get_by_digest(const char *digest)
|
||||
* our server is broken, invalid, obsolete, etc. */
|
||||
#define SELF_OPINION_INTERVAL (90*60)
|
||||
|
||||
/** Result of checking whether a version is recommended. */
|
||||
typedef struct combined_version_status_t {
|
||||
/** How many networkstatuses claim to know about versions? */
|
||||
int n_versioning;
|
||||
/** What do the majority of networkstatuses believe about this version? */
|
||||
version_status_t consensus;
|
||||
/** How many networkstatuses constitute the majority? */
|
||||
int n_concurring;
|
||||
} combined_version_status_t;
|
||||
|
||||
/** Return a string naming the versions of Tor recommended by
|
||||
/** Return a newly allocated string naming the versions of Tor recommended by
|
||||
* more than half the versioning networkstatuses. */
|
||||
static char *
|
||||
char *
|
||||
compute_recommended_versions(time_t now, int client,
|
||||
const char *my_version,
|
||||
combined_version_status_t *status_out)
|
||||
|
||||
Reference in New Issue
Block a user