mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Parse IPv6 policy summaries from router descriptors and microdescs
This commit is contained in:
parent
a96c0affcb
commit
c53adac122
@ -583,6 +583,7 @@ microdesc_free(microdesc_t *md)
|
||||
smartlist_free(md->family);
|
||||
}
|
||||
short_policy_free(md->exit_policy);
|
||||
short_policy_free(md->ipv6_exit_policy);
|
||||
|
||||
tor_free(md);
|
||||
}
|
||||
|
10
src/or/or.h
10
src/or/or.h
@ -1878,7 +1878,10 @@ typedef struct {
|
||||
/** How many bytes/s is this router known to handle? */
|
||||
uint32_t bandwidthcapacity;
|
||||
smartlist_t *exit_policy; /**< What streams will this OR permit
|
||||
* to exit? NULL for 'reject *:*'. */
|
||||
* to exit on IPv4? NULL for 'reject *:*'. */
|
||||
/** What streams will this OR permit to exit on IPv6?
|
||||
* NULL for 'reject *:*' */
|
||||
struct short_policy_t *ipv6_exit_policy;
|
||||
long uptime; /**< How many seconds the router claims to have been up */
|
||||
smartlist_t *declared_family; /**< Nicknames of router which this router
|
||||
* claims are its family. */
|
||||
@ -2084,8 +2087,11 @@ typedef struct microdesc_t {
|
||||
uint16_t ipv6_orport;
|
||||
/** As routerinfo_t.family */
|
||||
smartlist_t *family;
|
||||
/** Exit policy summary */
|
||||
/** IPv4 exit policy summary */
|
||||
short_policy_t *exit_policy;
|
||||
/** IPv6 exit policy summary */
|
||||
short_policy_t *ipv6_exit_policy;
|
||||
|
||||
} microdesc_t;
|
||||
|
||||
/** A node_t represents a Tor router.
|
||||
|
@ -2402,6 +2402,7 @@ routerinfo_free(routerinfo_t *router)
|
||||
smartlist_free(router->declared_family);
|
||||
}
|
||||
addr_policy_list_free(router->exit_policy);
|
||||
short_policy_free(router->ipv6_exit_policy);
|
||||
|
||||
memset(router, 77, sizeof(routerinfo_t));
|
||||
|
||||
|
@ -66,6 +66,7 @@ typedef enum {
|
||||
K_SERVER_VERSIONS,
|
||||
K_OR_ADDRESS,
|
||||
K_P,
|
||||
K_P6,
|
||||
K_R,
|
||||
K_A,
|
||||
K_S,
|
||||
@ -77,6 +78,7 @@ typedef enum {
|
||||
K_CACHES_EXTRA_INFO,
|
||||
K_HIDDEN_SERVICE_DIR,
|
||||
K_ALLOW_SINGLE_HOP_EXITS,
|
||||
K_IPV6_POLICY,
|
||||
|
||||
K_DIRREQ_END,
|
||||
K_DIRREQ_V2_IPS,
|
||||
@ -271,6 +273,7 @@ static token_rule_t routerdesc_token_table[] = {
|
||||
T0N("reject6", K_REJECT6, ARGS, NO_OBJ ),
|
||||
T0N("accept6", K_ACCEPT6, ARGS, NO_OBJ ),
|
||||
T1_START( "router", K_ROUTER, GE(5), NO_OBJ ),
|
||||
T01("ipv6-policy", K_IPV6_POLICY, CONCAT_ARGS, NO_OBJ),
|
||||
T1( "signing-key", K_SIGNING_KEY, NO_ARGS, NEED_KEY_1024 ),
|
||||
T1( "onion-key", K_ONION_KEY, NO_ARGS, NEED_KEY_1024 ),
|
||||
T1_END( "router-signature", K_ROUTER_SIGNATURE, NO_ARGS, NEED_OBJ ),
|
||||
@ -527,6 +530,7 @@ static token_rule_t microdesc_token_table[] = {
|
||||
T0N("a", K_A, GE(1), NO_OBJ ),
|
||||
T01("family", K_FAMILY, ARGS, NO_OBJ ),
|
||||
T01("p", K_P, CONCAT_ARGS, NO_OBJ ),
|
||||
T01("p6", K_P6, CONCAT_ARGS, NO_OBJ ),
|
||||
A01("@last-listed", A_LAST_LISTED, CONCAT_ARGS, NO_OBJ ),
|
||||
END_OF_TABLE
|
||||
};
|
||||
@ -1573,6 +1577,14 @@ router_parse_entry_from_string(const char *s, const char *end,
|
||||
if (policy_is_reject_star(router->exit_policy))
|
||||
router->policy_is_reject_star = 1;
|
||||
|
||||
if ((tok = find_opt_by_keyword(tokens, K_IPV6_POLICY)) && tok->n_args) {
|
||||
router->ipv6_exit_policy = parse_short_policy(tok->args[0]);
|
||||
if (! router->ipv6_exit_policy) {
|
||||
log_warn(LD_DIR , "Error in ipv6-policy %s", escaped(tok->args[0]));
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tok = find_opt_by_keyword(tokens, K_FAMILY)) && tok->n_args) {
|
||||
int i;
|
||||
router->declared_family = smartlist_new();
|
||||
@ -4484,6 +4496,9 @@ microdescs_parse_from_string(const char *s, const char *eos,
|
||||
if ((tok = find_opt_by_keyword(tokens, K_P))) {
|
||||
md->exit_policy = parse_short_policy(tok->args[0]);
|
||||
}
|
||||
if ((tok = find_opt_by_keyword(tokens, K_P6))) {
|
||||
md->ipv6_exit_policy = parse_short_policy(tok->args[0]);
|
||||
}
|
||||
|
||||
crypto_digest256(md->digest, md->body, md->bodylen, DIGEST_SHA256);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user