Commit 120fff13 authored by Killian Lufau's avatar Killian Lufau Committed by Julien Muchembled

Fix --disable-proto

argparse is error-prone in that `action='append'` starts from (a copy of) the
given default when it adds values from command-line, rather than restarting
from an empty list. For example, simply passing `--disable-proto udp` resulted
in ['udp', 'udp6', 'udp'], which caused 'udp6' to remain disabled.

/reviewed-on !17
parent d398aa93
......@@ -9,6 +9,8 @@ from re6st import plib, tunnel, utils, version, x509
from re6st.cache import Cache
from re6st.utils import exit, ReexecException
DEFAULT_DISABLED_PROTO = ['udp', 'udp6']
def getConfig():
parser = utils.ArgParser(fromfile_prefix_chars='@',
description="Resilient virtual private network application.")
......@@ -106,9 +108,10 @@ def getConfig():
help="Force each tunnel to be created through one the given gateways,"
" in a round-robin fashion.")
_('--disable-proto', action='append',
choices=('none', 'udp', 'tcp', 'udp6', 'tcp6'), default=['udp', 'udp6'],
choices=('none', 'udp', 'tcp', 'udp6', 'tcp6'),
help="Do never try to create tunnels using given protocols."
" 'none' has precedence over other options.")
" 'none' has precedence over other options."
" (default: %r)" % DEFAULT_DISABLED_PROTO)
_('--client', metavar='HOST,PORT,PROTO[;...]',
help="Do not run any OpenVPN server, but only 1 OpenVPN client,"
" with specified remotes. Any other option not required in this"
......@@ -155,7 +158,9 @@ def main():
if config.default and config.gateway:
sys.exit("error: conflicting options --default and --gateway")
if 'none' in config.disable_proto:
if config.disable_proto is None:
config.disable_proto = DEFAULT_DISABLED_PROTO
elif 'none' in config.disable_proto:
config.disable_proto = ()
if config.default:
# Make sure we won't tunnel over re6st.
......
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