Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Bug28692 #316

Closed
wants to merge 6 commits into from
Closed

Bug28692 #316

wants to merge 6 commits into from

Conversation

juga0
Copy link
Contributor

@juga0 juga0 commented Dec 15, 2018

No description provided.

to a function.
Replace comment by docstring.
Add an integration test to check the option is set.
The log message might not correspond to the reason.
Only the first one that fails will be logged, but not refactoring
here.
Add an integration test to check a runtime option fails.
and create function to set options that can fail because they are
not supported by some Tor versions at runtime.

Fixes bug 28692. Bugfix v0.4.0
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.

Looks good, but we could make the code easier to understand by doing a bit more refactoring.

"""Set torrc options at runtime."""
try:
cont.set_conf('__DisablePredictedCircuits', '1')
cont.set_conf('__LeaveStreamsUnattached', '1')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you refactor these options into a dictionary constant?
And let's put all the options in the same place.
You could put the new constant in globals.py after TORRC_STARTING_POINT.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my initial idea (https://trac.torproject.org/projects/tor/ticket/28692#comment:8):

>  Even if only stem.py uses these options, i think they should be in globals.py, since we might need to change them and globals.py should be the place where to change sbws defaults.

Let's leave any refactoring until #28737.

@@ -16,6 +18,9 @@
stream_building_lock = RLock()


TORRC_OPTIONS_CAN_FAIL = OrderedDict({'ConnectionPadding': '0'})
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put all the options in the same place.
You could put this constant in globals.py after TORRC_STARTING_POINT.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -117,6 +122,33 @@ def _init_controller_socket(socket):
return c


def set_torrc_runtime_options(cont):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please call this function on line 74 as well, to remove duplicate code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i forgot

They can be set at launch, but since the may fail because they are not
supported in some Tor versions, it's easier to try one by one at runtime
and ignore the ones that fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: extra newline?

@@ -72,8 +73,7 @@ def init_controller(port=None, path=None, set_custom_stream_settings=True):
return None, 'Unable to reach tor on control socket'
assert c is not None
if set_custom_stream_settings:
c.set_conf('__DisablePredictedCircuits', '1')
c.set_conf('__LeaveStreamsUnattached', '1')
set_torrc_runtime_options(c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also need to call set_torrc_options_can_fail(c) here?

@@ -26,6 +29,13 @@
'ProtocolWarnings': '1',
}

TORRC_RUNTIME_OPTIONS = {
Copy link
Contributor

@teor2345 teor2345 Feb 25, 2019

Choose a reason for hiding this comment

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

Do we need a comment here that explains how we use these options?

'__LeaveStreamsUnattached': '1',
}

TORRC_OPTIONS_CAN_FAIL = OrderedDict({'ConnectionPadding': '0'})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a comment here that explains how we use these options?

@juga0
Copy link
Contributor Author

juga0 commented Feb 25, 2019

@juga0
Copy link
Contributor Author

juga0 commented Feb 25, 2019

Merged the squashed branch.

@juga0 juga0 closed this Feb 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants