Loading src/feature/client/entrynodes.c +12 −5 Original line number Original line Diff line number Diff line Loading @@ -3996,8 +3996,14 @@ get_max_lifetime_of_layer2_hs_guards(void) static int static int get_layer2_hs_guard_lifetime(void) get_layer2_hs_guard_lifetime(void) { { return crypto_rand_int_range(get_min_lifetime_of_layer2_hs_guards(), int min = get_min_lifetime_of_layer2_hs_guards(); get_max_lifetime_of_layer2_hs_guards()); int max = get_max_lifetime_of_layer2_hs_guards(); if (BUG(min >= max)) { return min; } return crypto_rand_int_range(min, max); } } /** Maintain the L2 guard list. Make sure the list contains enough guards, do /** Maintain the L2 guard list. Make sure the list contains enough guards, do Loading Loading @@ -4107,9 +4113,10 @@ purge_vanguards_lite(void) /** Return a routerset containing the L2 guards or NULL if it's not yet /** Return a routerset containing the L2 guards or NULL if it's not yet * initialized. Callers must not free the routerset. Designed for use in * initialized. Callers must not free the routerset. Designed for use in * pick_vanguard_middle_node() and should not be used anywhere else (because * pick_vanguard_middle_node() and should not be used anywhere else. Do not * the routerset pointer can dangle under your feet) */ * store this pointer -- any future calls to maintain_layer2_guards() and routerset_t * * purge_vanguards_lite() can invalidate it. */ const routerset_t * get_layer2_guards(void) get_layer2_guards(void) { { if (!layer2_guards) { if (!layer2_guards) { Loading src/feature/client/entrynodes.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -651,7 +651,7 @@ guard_get_guardfraction_bandwidth(guardfraction_bandwidth_t *guardfraction_bw, int orig_bandwidth, int orig_bandwidth, uint32_t guardfraction_percentage); uint32_t guardfraction_percentage); routerset_t *get_layer2_guards(void); const routerset_t *get_layer2_guards(void); void maintain_layer2_guards(void); void maintain_layer2_guards(void); void purge_vanguards_lite(void); void purge_vanguards_lite(void); Loading src/test/test_entrynodes.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -3102,7 +3102,7 @@ test_entry_guard_layer2_guards(void *arg) /* Create the guardset */ /* Create the guardset */ maintain_layer2_guards(); maintain_layer2_guards(); routerset_t *l2_guards = get_layer2_guards(); const routerset_t *l2_guards = get_layer2_guards(); tt_assert(l2_guards); tt_assert(l2_guards); tt_int_op(routerset_len(l2_guards), OP_EQ, 4); tt_int_op(routerset_len(l2_guards), OP_EQ, 4); Loading Loading
src/feature/client/entrynodes.c +12 −5 Original line number Original line Diff line number Diff line Loading @@ -3996,8 +3996,14 @@ get_max_lifetime_of_layer2_hs_guards(void) static int static int get_layer2_hs_guard_lifetime(void) get_layer2_hs_guard_lifetime(void) { { return crypto_rand_int_range(get_min_lifetime_of_layer2_hs_guards(), int min = get_min_lifetime_of_layer2_hs_guards(); get_max_lifetime_of_layer2_hs_guards()); int max = get_max_lifetime_of_layer2_hs_guards(); if (BUG(min >= max)) { return min; } return crypto_rand_int_range(min, max); } } /** Maintain the L2 guard list. Make sure the list contains enough guards, do /** Maintain the L2 guard list. Make sure the list contains enough guards, do Loading Loading @@ -4107,9 +4113,10 @@ purge_vanguards_lite(void) /** Return a routerset containing the L2 guards or NULL if it's not yet /** Return a routerset containing the L2 guards or NULL if it's not yet * initialized. Callers must not free the routerset. Designed for use in * initialized. Callers must not free the routerset. Designed for use in * pick_vanguard_middle_node() and should not be used anywhere else (because * pick_vanguard_middle_node() and should not be used anywhere else. Do not * the routerset pointer can dangle under your feet) */ * store this pointer -- any future calls to maintain_layer2_guards() and routerset_t * * purge_vanguards_lite() can invalidate it. */ const routerset_t * get_layer2_guards(void) get_layer2_guards(void) { { if (!layer2_guards) { if (!layer2_guards) { Loading
src/feature/client/entrynodes.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -651,7 +651,7 @@ guard_get_guardfraction_bandwidth(guardfraction_bandwidth_t *guardfraction_bw, int orig_bandwidth, int orig_bandwidth, uint32_t guardfraction_percentage); uint32_t guardfraction_percentage); routerset_t *get_layer2_guards(void); const routerset_t *get_layer2_guards(void); void maintain_layer2_guards(void); void maintain_layer2_guards(void); void purge_vanguards_lite(void); void purge_vanguards_lite(void); Loading
src/test/test_entrynodes.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -3102,7 +3102,7 @@ test_entry_guard_layer2_guards(void *arg) /* Create the guardset */ /* Create the guardset */ maintain_layer2_guards(); maintain_layer2_guards(); routerset_t *l2_guards = get_layer2_guards(); const routerset_t *l2_guards = get_layer2_guards(); tt_assert(l2_guards); tt_assert(l2_guards); tt_int_op(routerset_len(l2_guards), OP_EQ, 4); tt_int_op(routerset_len(l2_guards), OP_EQ, 4); Loading