I would really like to work on this, just wondering if I should go through pluggable transport tor specs first or should I directly approach the issue.
For this, I was thinking of wrapping up the common functionalities of the two methods into a single function which can then be used by both of them to carry on parsing the line. Is this a good way to go or should I think of some other way to merge them?
For this, I was thinking of wrapping up the common functionalities of the two methods into a single function which can then be used by both of them to carry on parsing the line. Is this a good way to go or should I think of some other way to merge them?
Yes indeed fristonio. That's the logic.
Here are the things that I would try to united between those two functions:
a) method_name parsing and validation
b) addrport parsing and validation
c) transport_new and adding it to mp->transports.
Hello! Thanks for the code! Concept looks pretty good!
Some simplification suggestions:
a) You don't really need to compare proto_method with PROTO_CMETHOD since you control those two things yourself anyway. Instead of proto_method, I'd pass an is_smethod boolean variable to the helper function which would specify whether it's an SMETHOD or CMETHOD line. That way you don't need to do all these strcmps either, and you can just do if (is_smethod) { }.
b) You don't really need this proxy_manager thing. You just use it in a log statement, and there you can do:
log_warn(LD_CONFIG, "%s managed proxy sent us a %s line " "with too few arguments.", is_smethod ? "Server" : "Client", proto_method);
c) You don't need the else clause in the final logging if block. Since you have already validated on top that proto_method is either CMETHOD or SMETHOD.
d) You don't need to pass SMETHOD_MIN_ARGS_COUNT as a function argument. Instead you can set min_args_count inside the helper function based on is_smethod.
Please check it out, and if you like it, squash it into your branch (so that the final branch only has one commit) and push it out. Then mark this ticket as merge_ready.