diff --git a/src/or/or.h b/src/or/or.h index 7dc0de138f..8e8e3387b4 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1415,6 +1415,13 @@ typedef struct routerstatus_t { * we can get v3 downloads from. */ unsigned int version_supports_v3_dir:1; + uint32_t bandwidth; /**< Bandwidth (capacity) of the router as reported in + * the vote/consensus, in kilobytes/sec. */ + addr_policy_action_t exitsummarytype; /**< is the list of ports a list of + * rejected or accepted ports? */ + char *exitsummary; /**< exit policy summary - + * XXX weasel: this probably should not stay a string. */ + /* ---- The fields below aren't derived from the networkstatus; they * hold local information only. */ diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 0cc100a6e6..8c66127cf3 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -53,9 +53,11 @@ typedef enum { K_DIR_OPTIONS, K_CLIENT_VERSIONS, K_SERVER_VERSIONS, + K_P, K_R, K_S, K_V, + K_W, K_EVENTDNS, K_EXTRA_INFO, K_EXTRA_INFO_DIGEST, @@ -264,9 +266,11 @@ static token_rule_t extrainfo_token_table[] = { /** List of tokens allowable in the body part of v2 and v3 networkstatus * documents. */ static token_rule_t rtrstatus_token_table[] = { + T01("p", K_P, GE(2), NO_OBJ ), T1( "r", K_R, GE(8), NO_OBJ ), T1( "s", K_S, ARGS, NO_OBJ ), T01("v", K_V, CONCAT_ARGS, NO_OBJ ), + T01("w", K_W, ARGS, NO_OBJ ), T0N("opt", K_OPT, CONCAT_ARGS, OBJ_OK ), END_OF_TABLE }; @@ -1863,6 +1867,38 @@ routerstatus_parse_entry_from_string(memarea_t *area, } } + /* handle weighting/bandwidth info */ + if ((tok = find_first_by_keyword(tokens, K_W))) { + int i; + for (i=0; i < tok->n_args; ++i) { + if (!strcmpstart(tok->args[i], "Bandwidth=")) { + int ok; + rs->bandwidth = tor_parse_ulong(strchr(tok->args[i], '=')+1, 10, + 0, UINT32_MAX, &ok, NULL); + if (!ok) { + log_warn(LD_DIR, "Invalid Bandwidth %s", escaped(tok->args[i])); + goto err; + } + } + } + } + + /* parse exit policy summaries */ + if ((tok = find_first_by_keyword(tokens, K_P))) { + tor_assert(tok->n_args == 2); + if (!strcmp(tok->args[0], "accept")) + rs->exitsummarytype = ADDR_POLICY_ACCEPT; + else if (!strcmp(tok->args[0], "reject")) + rs->exitsummarytype = ADDR_POLICY_REJECT; + else { + log_warn(LD_DIR, "Unknown exit policy summary type %s.", + escaped(tok->args[0])); + goto err; + } + /* XXX weasel: parse this into ports and represent them somehow smart */ + rs->exitsummary = tor_strdup(tok->args[1]); + } + if (!strcasecmp(rs->nickname, UNNAMED_ROUTER_NICKNAME)) rs->is_named = 0;