Circuit padding ProtoVer plumbing.

This helps us to determine if a middle node can pad to us or not.

Co-authored-by: George Kadianakis <desnacked@riseup.net>
This commit is contained in:
Mike Perry
2018-10-23 20:55:10 +00:00
committed by George Kadianakis
parent 70e9245f6f
commit 659a4f06d4
6 changed files with 20 additions and 4 deletions
+4
View File
@@ -836,6 +836,10 @@ typedef struct protover_summary_flags_t {
* service rendezvous point supporting version 3 as seen in proposal 224.
* This requires HSRend=2. */
unsigned int supports_v3_rendezvous_point: 1;
/** True iff this router has a protocol list that allows clients to
* negotiate link-level padding. Requires Padding>=1. */
unsigned int supports_padding : 1;
} protover_summary_flags_t;
typedef struct routerinfo_t routerinfo_t;
+6 -1
View File
@@ -39,6 +39,9 @@ static int protocol_list_contains(const smartlist_t *protos,
static const struct {
protocol_type_t protover_type;
const char *name;
/* If you add a new protocol here, you probably also want to add
* parsing for it in routerstatus_parse_entry_from_string() so that
* it is set in routerstatus_t */
} PROTOCOL_NAMES[] = {
{ PRT_LINK, "Link" },
{ PRT_LINKAUTH, "LinkAuth" },
@@ -49,6 +52,7 @@ static const struct {
{ PRT_HSREND, "HSRend" },
{ PRT_DESC, "Desc" },
{ PRT_MICRODESC, "Microdesc"},
{ PRT_PADDING, "Padding"},
{ PRT_CONS, "Cons" }
};
@@ -396,7 +400,8 @@ protover_get_supported_protocols(void)
"LinkAuth=3 "
#endif
"Microdesc=1-2 "
"Relay=1-2";
"Relay=1-2 "
"Padding=1";
}
/** The protocols from protover_get_supported_protocols(), as parsed into a
+1
View File
@@ -43,6 +43,7 @@ typedef enum protocol_type_t {
PRT_DESC,
PRT_MICRODESC,
PRT_CONS,
PRT_PADDING,
} protocol_type_t;
bool protover_contains_long_protocol_names(const char *s);
+2
View File
@@ -448,6 +448,8 @@ memoize_protover_summary(protover_summary_flags_t *out,
out->supports_v3_rendezvous_point =
protocol_list_supports_protocol(protocols, PRT_HSREND,
PROTOVER_HS_RENDEZVOUS_POINT_V3);
out->supports_padding =
protocol_list_supports_protocol(protocols, PRT_PADDING, 1);
protover_summary_flags_t *new_cached = tor_memdup(out, sizeof(*out));
cached = strmap_set(protover_summary_map, protocols, new_cached);
+1 -1
View File
@@ -1106,7 +1106,7 @@ node_ed25519_id_matches(const node_t *node, const ed25519_public_key_t *id)
/** Dummy object that should be unreturnable. Used to ensure that
* node_get_protover_summary_flags() always returns non-NULL. */
static const protover_summary_flags_t zero_protover_flags = {
0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
};
/** Return the protover_summary_flags for a given node. */
+6 -2
View File
@@ -46,6 +46,7 @@ pub enum Protocol {
LinkAuth,
Microdesc,
Relay,
Padding,
}
impl fmt::Display for Protocol {
@@ -73,6 +74,7 @@ impl FromStr for Protocol {
"LinkAuth" => Ok(Protocol::LinkAuth),
"Microdesc" => Ok(Protocol::Microdesc),
"Relay" => Ok(Protocol::Relay),
"Padding" => Ok(Protocol::Padding),
_ => Err(ProtoverError::UnknownProtocol),
}
}
@@ -163,7 +165,8 @@ pub(crate) fn get_supported_protocols_cstr() -> &'static CStr {
Link=1-5 \
LinkAuth=3 \
Microdesc=1-2 \
Relay=1-2"
Relay=1-2 \
Padding=1"
)
} else {
cstr!(
@@ -176,7 +179,8 @@ pub(crate) fn get_supported_protocols_cstr() -> &'static CStr {
Link=1-5 \
LinkAuth=1,3 \
Microdesc=1-2 \
Relay=1-2"
Relay=1-2 \
Padding=1"
)
}
}