diff --git a/changes/ticket40872 b/changes/ticket40872 new file mode 100644 index 0000000000000000000000000000000000000000..38b2521c8d1d529503b8b3f5d345a3089bcd253a --- /dev/null +++ b/changes/ticket40872 @@ -0,0 +1,3 @@ + o Minor bugfixes (control port): + - Correctly report conflux pair information to controller fields + Fixes bug 40872; bugfix on 0.4.8.1-alpha diff --git a/src/core/or/conflux_util.c b/src/core/or/conflux_util.c index 4277424ec8b4d9f41448e7a0c609e0d45cedbc22..1911849e4f600a275c351b26186d2eff2b6ea7ad 100644 --- a/src/core/or/conflux_util.c +++ b/src/core/or/conflux_util.c @@ -442,3 +442,33 @@ conflux_validate_legs(const conflux_t *cfx) conflux_log_set(LOG_PROTOCOL_WARN, cfx, is_client); } } + +/** Return the nonce for a circuit, for use on the control port */ +const uint8_t * +conflux_get_nonce(const circuit_t *circ) +{ + if (circ->conflux_pending_nonce) { + return circ->conflux_pending_nonce; + } else if (circ->conflux) { + return circ->conflux->nonce; + } else { + return NULL; + } +} + +/** Return the conflux RTT for a circuit, for use on the control port */ +uint64_t +conflux_get_circ_rtt(const circuit_t *circ) +{ + if (circ->conflux) { + conflux_leg_t *leg = conflux_get_leg(circ->conflux, circ); + if (BUG(!leg)) { + return 0; + } else { + return leg->circ_rtts_usec; + } + } else { + return 0; + } +} + diff --git a/src/core/or/conflux_util.h b/src/core/or/conflux_util.h index c556ae184857ebf0b5f511c8b32674ba2f2d8da3..501ce61d82e88bc31a997be8521f9cbe3446e02d 100644 --- a/src/core/or/conflux_util.h +++ b/src/core/or/conflux_util.h @@ -34,6 +34,9 @@ CIRCUIT_IS_CONFLUX(const circuit_t *circ) } } +const uint8_t *conflux_get_nonce(const circuit_t *circ); +uint64_t conflux_get_circ_rtt(const circuit_t *circ); + int circuit_get_package_window(circuit_t *circ, const crypt_path_t *cpath); bool conflux_can_send(conflux_t *cfx); diff --git a/src/feature/control/control_fmt.c b/src/feature/control/control_fmt.c index b6efd18163de45a0b15f1d16cfea4ad591438d75..4816f7847ab75d51896692b4a6b62bb8f4e76aae 100644 --- a/src/feature/control/control_fmt.c +++ b/src/feature/control/control_fmt.c @@ -21,6 +21,7 @@ #include "core/or/entry_connection_st.h" #include "core/or/or_connection_st.h" #include "core/or/origin_circuit_st.h" +#include "core/or/conflux_util.h" #include "core/or/socks_request_st.h" #include "feature/control/control_connection_st.h" @@ -160,6 +161,26 @@ circuit_describe_status_for_controller(origin_circuit_t *circ) smartlist_add_asprintf(descparts, "HS_POW=v1,%u", circ->hs_pow_effort); } + /* Add conflux id and RTT info, for accurate circuit display. The RTT is + * provided to indicate the primary (preferred) circuit of a set + * (which will have the lowest current RTT). */ + if (CIRCUIT_IS_CONFLUX(TO_CIRCUIT(circ))) { + const uint8_t *nonce = conflux_get_nonce(TO_CIRCUIT(circ)); + tor_assert(nonce); + + /* The conflux nonce is sensitive data. Only output half of it. */ + smartlist_add_asprintf(descparts, "CONFLUX_ID=%s", + hex_str((const char *)nonce, DIGEST256_LEN/2)); + + /* If we have a conflux object, the circ is linked and has an RTT */ + if (TO_CIRCUIT(circ)->conflux) { + uint64_t circ_rtt = conflux_get_circ_rtt(TO_CIRCUIT(circ)); + if (circ_rtt) { + smartlist_add_asprintf(descparts, "CONFLUX_RTT=%" PRIu64, circ_rtt); + } + } + } + rv = smartlist_join_strings(descparts, " ", 0, NULL); SMARTLIST_FOREACH(descparts, char *, cp, tor_free(cp));