commit 2a506d6ab1c626d70f00d45fb310c0c59bca4907 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue May 26 23:05:02 2020 +0200
Make -o/-i arguments mutually exclusive.
Right now, it's possible to specify both -o and -i at the same time, which doesn't make any sense.
Also, it's rather non-intuitive that both argument defaults are True and that setting either of them changes their value to False.
This patch fixes both issues above.
Fixes #34316. --- onionperf/onionperf | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/onionperf/onionperf b/onionperf/onionperf index f430c3f..bc95e2b 100755 --- a/onionperf/onionperf +++ b/onionperf/onionperf @@ -194,15 +194,17 @@ def main(): action="store", dest="tgenconnectport", default=8080)
- measure_parser.add_argument('-o', '--onion-only', - help="""disable measuring download times over Tor back to {0}""".format(hostname), - action="store_false", dest="do_inet", - default=True) + onion_or_inet_only_group = measure_parser.add_mutually_exclusive_group()
- measure_parser.add_argument('-i', '--inet-only', - help="""disable measuring download times over Tor to an ephemeral onion service""", - action="store_false", dest="do_onion", - default=True) + onion_or_inet_only_group.add_argument('-o', '--onion-only', + help="""only measure download times over Tor to an ephemeral onion service""", + action="store_true", dest="onion_only", + default=False) + + onion_or_inet_only_group.add_argument('-i', '--inet-only', + help="""only measure download times over Tor exiting to a public webserver""", + action="store_true", dest="inet_only", + default=False)
measure_parser.add_argument('-n', '--nickname', help="""the 'SOURCE' STRING to use in measurement result files produced by OnionPerf""", @@ -352,7 +354,7 @@ def measure(args): server_tor_socks_port = util.get_random_free_port()
meas = Measurement(args.torpath, args.tgenpath, args.prefix, args.private_prefix, args.nickname, args.oneshot, args.additional_client_conf, args.torclient_conf_file, args.torserver_conf_file) - meas.run(do_onion=args.do_onion, do_inet=args.do_inet, + meas.run(do_onion=not args.inet_only, do_inet=not args.onion_only, client_tgen_listen_port=client_tgen_port, client_tgen_connect_ip=client_connect_ip, client_tgen_connect_port=client_connect_port, client_tor_ctl_port=client_tor_ctl_port, client_tor_socks_port=client_tor_socks_port, server_tgen_listen_port=server_tgen_port, server_tor_ctl_port=server_tor_ctl_port, server_tor_socks_port=server_tor_socks_port) else:
tor-commits@lists.torproject.org