-
Notifications
You must be signed in to change notification settings - Fork 970
Talk to the control socket using my old draft tor daemon manager. #14146
Conversation
app/filtering.js
Outdated
@@ -47,6 +48,8 @@ const headersReceivedFilteringFns = [] | |||
let partitionsToInitialize = ['default', appConfig.tor.partition] | |||
let initializedPartitions = {} | |||
|
|||
let torDaemon = new tor.TorDaemon() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like you don't reassign to this variable so better to use const
instead of let
also this doesn't need to be in the module scope, right? so it can be declared in setupTor instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 453e327
loop(i + 1) | ||
}) | ||
} | ||
loop(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be slightly clearer if you used directories.forEach
instead of this recursive loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callbacks make forEach a little tricky. If this should be done with mkdirSync, I guess that's OK, but I figured it would be better to avoid that. (I'm not sure this is necessary, but the ordering of directory creation in muon vs browser-laptop is not obvious, so I figured it would be safer to keep this logic than delete it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@riastradh-brave i see now that one of the directories is a subdir of the other. in that case you can just use fs-extra's mkdir instead of fs's mkdir, which will behave like mkdir -p
: https://github.com/jprichardson/node-fs-extra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does that help to do multiple ones in a loop? I guess I could replace the whole thing by a single mkdirp for the deepest subdirectory, but I didn't want to embed the assumption that there is a single deepest subdirectory in that function.
app/tor.js
Outdated
module.exports.torControlParseQuoted = torControlParseQuoted | ||
module.exports.torrcEscapeBuffer = torrcEscapeBuffer | ||
module.exports.torrcEscapePath = torrcEscapePath | ||
module.exports.torrcEscapeString = torrcEscapeString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add unit tests for these exported methods (located in test/unit, npm run unittest
to run)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 4282807
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding tests - could you also document the input types of any externally-callable methods/constructors using jsdoc so it's harder to get the types wrong? http://usejsdoc.org/ - see js/lib/request for an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 8f532a9
fc600c5
to
a93cfd4
Compare
81e4ac4
to
4b39b3a
Compare
In 4b39b3a, I added some automatic tests for the logic to launch tor and wait for a notification that it has launched within a reasonable time, but they are broken because These tests may also be problematic because they deliberately put in a half-second delay to make sure we exercise both orders of (a) tor process startup, and (b) fs event watch notification logic setup. What to do? |
4b39b3a
to
d265aa9
Compare
Never mind, apparently this works now and I have no idea why it failed before. |
For #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
TODO(riastradh): These are currently broken because something futzes with fs.mkdir when run as `npm run unittest'.
This directory will have been populated by tor stuff, which, by intent, nothing else cleans up.
These indicate when tor thinks it's definitely ready, or definitely not ready (any more).
- 'end' means end of input only - 'error' means an error happened but no state change - 'close' means underlying resource is now closed Make sure TorDaemon emits 'exit' event when control closes. Confirm in automatic tests that (a) the TorDaemon emits 'exit', _and_ (b) the tor process exits. This increases the total amount of code by about 70 lines, but the logic in each of the event handlers is smaller because their use more precisely reflects their fine-grained intent in the nodejs APIs, and many of the new lines are in comments on new short internal subroutines.
277a354
to
daf4f24
Compare
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
…4146) Needed for #14043. Auditors: @diracdeltas Test Plan: 1. Launch Brave. 2. Examine console output. 3. Confirm it mentions tor bootstrapping.
This doesn't solve #14043 yet, but it provides a candidate place to hook up a progress indicator. See the
TODO(riastradh): Visually update a progress bar!
comment for the place where we should update a progress bar, currently c2b3eda#diff-8a9bac13ef6264feb2b6da7c18d86b3cR751.Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Launch Brave. Confirm that the console output mentions tor bootstrapping.
Reviewer Checklist:
Tests