GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 9d76ca4b authored by Karsten Loesing's avatar Karsten Loesing

Tweak --drop-guards switch.

This commit tweaks the recently added --drop-guards switch as follows:

 - Guards are dropped right at startup and then every N hours.
   Otherwise we might not receive the first round of GUARD NEW/UP
   events. It's unclear why we don't receive those events, but finding
   out might be time-consuming whereas dropping guards at startup is
   basically free.

 - Right after guards are dropped, circuit build timeouts are dropped,
   too, if supported by the Tor version. If the Tor version does not
   support this, there's going to be a warning, and the control log
   will simply not contain BUILDTIMEOUT_SET events.

Still part of the reopened #33399.
parent f496edec
# Changes in version 0.7 - 2020-??-??
- Add `onionperf measure --drop-guards` parameter to use and drop
guards after a given number of hours. Implements #33399.
guards and circuit build timeouts every given number of hours, if
supported by the Tor version. Implements #33399.
- Remove the `onionperf measure --oneshot` switch and replace it with
new switches `--tgen-pause-initial`, `--tgen-pause-between`,
`--tgen-transfer-size`, and `--tgen-num-transfers ` to further
......
......@@ -57,21 +57,23 @@ class TorMonitor(object):
interval_count = 0
if newnym_interval_seconds is not None:
next_newnym = newnym_interval_seconds
if drop_guards_interval_hours > 0:
next_drop_guards = drop_guards_interval_hours * 3600
next_drop_guards = 0
while done_ev is None or not done_ev.is_set():
# if self.filepath != '-' and os.path.exists(self.filepath):
# with open(self.filepath, 'rb') as sizef:
# msg = "tor-ctl-logger[port={0}] logged {1} bytes to {2}, press CTRL-C to quit".format(self.tor_ctl_port, os.fstat(sizef.fileno()).st_size, self.filepath)
# logging.info(msg)
if drop_guards_interval_hours > 0 and interval_count >= next_drop_guards:
next_drop_guards += drop_guards_interval_hours * 3600
torctl.drop_guards()
drop_timeouts_response = torctl.msg("DROPTIMEOUTS")
if not drop_timeouts_response.is_ok():
self.__log(self.writable, "[WARNING] unrecognized command DROPTIMEOUTS in tor\n")
sleep(1)
interval_count += 1
if newnym_interval_seconds is not None and interval_count >= next_newnym:
next_newnym += newnym_interval_seconds
torctl.signal(Signal.NEWNYM)
if drop_guards_interval_hours > 0 and interval_count >= next_drop_guards:
next_drop_guards += drop_guards_interval_hours * 3600
torctl.drop_guards()
except KeyboardInterrupt:
pass # the user hit ctrl+c
......
......@@ -215,7 +215,7 @@ def main():
default=0)
measure_parser.add_argument('--drop-guards',
help="""Use and drop guards every N > 0 hours, or do not use guards at all if N = 0""",
help="""Use and drop guards and circuit build timeouts every N > 0 hours, or do not use guards at all and never drop circuit build timeouts if N = 0""",
metavar="N", type=type_nonnegative_integer,
action="store", dest="drop_guards_interval_hours",
default=0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment