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

ticket 30984 control refactor #1505

Merged
merged 10 commits into from Dec 15, 2019
Merged

Conversation

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

@tlyu tlyu commented Nov 5, 2019

No description provided.

@coveralls
Copy link

@coveralls coveralls commented Nov 6, 2019

Pull Request Test Coverage Report for Build 7489

  • 64 of 128 (50.0%) changed or added relevant lines in 4 files are covered.
  • 5 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.03%) to 63.006%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/feature/control/control_proto.c 56 60 93.33%
src/feature/control/control_getinfo.c 0 10 0.0%
src/feature/control/control_cmd.c 0 50 0.0%
Files with Coverage Reduction New Missed Lines %
src/feature/hs/hs_service.c 1 73.29%
src/feature/control/control_cmd.c 2 18.18%
src/feature/control/control_getinfo.c 2 30.67%
Totals Coverage Status
Change from base Build 7477: 0.03%
Covered Lines: 49540
Relevant Lines: 78627

💛 - Coveralls

Copy link
Contributor

@teor2345 teor2345 left a comment

This looks great!

I have a function name change suggestion, and a request for missing function docs.

control_reply_add_str(reply, 250, "OK");
}

void
Copy link
Contributor

@teor2345 teor2345 Nov 6, 2019

Doc?
And the remaining functions in this file.

* @param val value
*/
void
control_reply_add_1kv(smartlist_t *reply, int code, int flags,
Copy link
Contributor

@teor2345 teor2345 Nov 6, 2019

This name is hard to read and type, because "1" and "l" and "I" look similar:

Suggested change
control_reply_add_1kv(smartlist_t *reply, int code, int flags,
control_reply_add_single_kv(smartlist_t *reply, int code, int flags,

tlyu added 8 commits Dec 8, 2019
Add a check for '=' characters in needs_escape().  This simplifies the
logic in kvline_can_encode_lines().

Part of #30984.
Add the KV_RAW flag to kvline_encode().  This allows generation of
output that is compatible with some quirks of the control protocol.

Part of #30984.
Part of #30984.
In handle_control_getconf(), use the new control reply line
abstraction to simplify output generation.  Previously, this function
explicitly checked for whether it should generate a MidReplyLine or an
EndReplyLine.  control_write_reply_lines() now abstracts this check.

Part of #30984.
Factor out the parts of handle_control_protocolinfo() that assemble
the AUTHMETHODS and COOKIEFILE strings.

Part of #30984.
Simplify handle_control_protocolinfo() by using the new reply line
abstraction.

Part of #30984.
Simplify handle_control_getinfo() by using the new reply lines
abstraction.  Previously, this function explicitly checked for whether
it should generate a MidReplyLine, a DataReplyLine, or an
EndReplyLine.  control_write_reply_lines() now abstracts this check.

Part of #30984.
Part of ticket 30984.
@tlyu tlyu force-pushed the control-refactor branch from a6fe4ba to 719a4ce Dec 9, 2019
@tlyu tlyu changed the title WIP ticket 30984 control refactor ticket 30984 control refactor Dec 9, 2019
}

while (answer) {
config_line_t *next;
control_reply_add_1kv(answers, 250, KV_RAW, answer->key,
control_reply_add_one_kv(answers, 250, KV_RAW, answer->key,
answer->value);
Copy link
Contributor

@teor2345 teor2345 Dec 9, 2019

Nit: If you want to fix the spacing on this line before we merge, that would be good. Leaving it would also be ok.

@tlyu tlyu force-pushed the control-refactor branch from 719a4ce to 7bd7089 Dec 9, 2019
@torproject-pusher torproject-pusher merged commit 7bd7089 into torproject:master Dec 15, 2019
2 checks passed
@tlyu tlyu deleted the control-refactor branch Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment