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

ltbringer
Copy link
Contributor

Add control port GETINFO support for dumping the local consensus

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

@coveralls
Copy link

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 Compare September 23, 2019 21:20
- 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 force-pushed the Ticket31684 branch 8 times, most recently from 3d18911 to e8a060d Compare September 28, 2019 21:04
@ltbringer ltbringer force-pushed the Ticket31684 branch 3 times, most recently from 8f3a3f1 to e546a6a Compare September 30, 2019 18:25
changes/ticket31684 Outdated Show resolved Hide resolved
@ltbringer ltbringer force-pushed the Ticket31684 branch 7 times, most recently from 42149a2 to 5b34a4d Compare October 3, 2019 22:42
@teor2345
Copy link
Contributor

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

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.

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 Compare October 9, 2019 18:18
@ltbringer ltbringer requested a review from asn-d6 October 10, 2019 05:48
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong error message

return -1;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use < 0

const char *errmsg = NULL;

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

options->FetchUselessDescriptors = previous_fetch_value;

done:
clear_bridge_mocks();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

@teor2345
Copy link
Contributor

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
Labels
None yet
Projects
None yet
4 participants