Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket31684 #1328

Closed
wants to merge 3 commits into from
Closed

Ticket31684 #1328

wants to merge 3 commits into from

Conversation

Labels
None yet
Projects
None yet
4 participants
@ltbringer
Copy link
Contributor

@ltbringer ltbringer commented Sep 16, 2019

Add control port GETINFO support for dumping the local consensus

Refer: (ticket)[https://trac.torproject.org/projects/tor/ticket/31684]

@coveralls
Copy link

@coveralls coveralls commented Sep 16, 2019

Pull Request Test Coverage Report for Build 6594

  • 22 of 27 (81.48%) changed or added relevant lines in 4 files are covered.
  • 267 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.2%) to 63.145%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/feature/dircache/dirserv.c 0 1 0.0%
src/feature/control/control_getinfo.c 19 23 82.61%
Files with Coverage Reduction New Missed Lines %
src/feature/hs/hs_cell.c 60 41.79%
src/feature/dircache/dirserv.c 207 0.91%
Totals Coverage Status
Change from base Build 6587: -0.2%
Covered Lines: 47835
Relevant Lines: 75754

💛 - Coveralls

@ltbringer ltbringer force-pushed the Ticket31684 branch 5 times, most recently from 683cb91 to eca91ff Sep 23, 2019
- Allows control port to read microdesc consensus using:
GETINFO dir/status-vote/microdesc/consensus

refer: [ticket](https://trac.torproject.org/projects/tor/ticket/31684)
refer: [comment](https://trac.torproject.org/projects/tor/ticket/31684#comment:6)

add: Helper function `getinfo_helper_current_consensus`
add(changes/ticket31684): track changes within ticket31684
fix(changes/ticket31684): formatting and ticket#number
refactor: remove redundant conditionals
fix: getinfo_helper_current_consensus returns -1 for any question that doesn't ask for microdesc or ns descriptors

lint: wide condition
Copy link
Member

@asn-d6 asn-d6 left a comment

OK here is a review. Also please change the commit message to specify what the changes did, instead of which trac ticket they fixed. Example "Add GETINFO support for dumping microdesc consensus".

changes/ticket31684 Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
@ltbringer ltbringer requested a review from asn-d6 Sep 26, 2019
@ltbringer ltbringer force-pushed the Ticket31684 branch 8 times, most recently from 3d18911 to e8a060d Sep 28, 2019
@ltbringer ltbringer requested a review from asn-d6 Sep 28, 2019
@ltbringer ltbringer force-pushed the Ticket31684 branch 3 times, most recently from 8f3a3f1 to e546a6a Sep 30, 2019
changes/ticket31684 Outdated Show resolved Hide resolved
@ltbringer ltbringer force-pushed the Ticket31684 branch 7 times, most recently from 42149a2 to 5b34a4d Oct 3, 2019
@teor2345
Copy link
Contributor

@teor2345 teor2345 commented Oct 4, 2019

It seems like you're pushing a lot of commits here.
Can we help you get set up to run these tests locally?

Or maybe this task isn't a good fit for you.
Would you like us to take over this refactor?

@ltbringer
Copy link
Contributor Author

@ltbringer ltbringer commented Oct 4, 2019

I'll take it off on a separate branch and use the CI on my fork. I assumed I'd get this done faster but I should have done this before. Sincere apologies.

@ltbringer ltbringer requested a review from asn-d6 Oct 6, 2019
changes/ticket31684 Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
src/feature/control/control_getinfo.c Outdated Show resolved Hide resolved
src/test/test_controller.c Outdated Show resolved Hide resolved
src/test/test_controller.c Outdated Show resolved Hide resolved
src/test/test_controller.c Outdated Show resolved Hide resolved
src/test/test_controller.c Outdated Show resolved Hide resolved
src/test/test_controller.c Outdated Show resolved Hide resolved
src/test/test_controller.c Outdated Show resolved Hide resolved
@ltbringer ltbringer force-pushed the Ticket31684 branch 2 times, most recently from a4ebfbc to 933ea85 Oct 9, 2019
@ltbringer ltbringer requested a review from asn-d6 Oct 10, 2019
test: check if GETINFO commands return expected consensus data..
docs: function docs easier to understand
update: Code simplification and refactoring change
…nd type of getinfo_helper_current_consensus accepts flavor as a type(enum) consensus_flavor_t instead of plain int

lint: removed unnecessary line
Copy link
Contributor

@teor2345 teor2345 left a comment

Fixes made by me in #1434

No action required.

(int flav,
const char *flavorname,
int unverified_consensus));
tor_mmap_t * networkstatus_map_cached_consensus(const char *flavorname);
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Extra space

{
const char *flavor_name = networkstatus_get_flavor_name(flavor);
if (!strcmp(flavor_name, "??")) {
*errmsg = "Could not open cached consensus. "
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Wrong error message

return -1;
}
}
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Weird spacing?

@@ -1513,6 +1544,8 @@ static const getinfo_item_t getinfo_items[] = {
"v2 networkstatus docs as retrieved from a DirPort."),
ITEM("dir/status-vote/current/consensus", dir,
"v3 Networkstatus consensus as retrieved from a DirPort."),
ITEM("dir/status-vote/current/consensus-microdesc", dir,
"v3 Microdescriptors consensus as retrieved from a DirPort."),
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Typo

dirserv_get_consensus(const char *flavor_name)
MOCK_IMPL(cached_dir_t *,
dirserv_get_consensus,
(const char *flavor_name))
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Spacing

} else if (!strcmp(question, "dir/status-vote/current/consensus")) {
int consensus_result = getinfo_helper_current_consensus(FLAV_NS,
answer, errmsg);
if (consensus_result == -1) {
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

We use < 0

const char *errmsg = NULL;

(void)arg;
setup_bridge_mocks();
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Not needed

tor_free(mock_microdesc_consensus_cache->dir);
tor_free(answer);
errmsg = NULL;
options->FetchUselessDescriptors = previous_fetch_value;
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Should be after done:

(void)arg;
setup_bridge_mocks();
or_options_t *options = get_options_mutable();
int previous_fetch_value = options->FetchUselessDescriptors;
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Not needed

options->FetchUselessDescriptors = previous_fetch_value;

done:
clear_bridge_mocks();
Copy link
Contributor

@teor2345 teor2345 Oct 21, 2019

Not needed

@teor2345
Copy link
Contributor

@teor2345 teor2345 commented Oct 21, 2019

Latest code in #1434.

@teor2345 teor2345 closed this Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment