Skip to content

Commit

Permalink
Allow subnets to be given only by file (-s)
Browse files Browse the repository at this point in the history
This should fix #116. Handling this while still having the positional
arguments and -s both write to the same list turned out to be more
complicated than it's worth so each writes to their own variable and we
merge them at the end.
  • Loading branch information
vieira authored and brianmay committed Sep 26, 2016
1 parent 0033efc commit c0c3612
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sshuttle/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def main():

try:
if opt.firewall:
if opt.subnets:
if opt.subnets or opt.subnets_file:
parser.error('exactly zero arguments expected')
return firewall.main(opt.method, opt.syslog)
elif opt.hostwatch:
return hostwatch.hw_main(opt.subnets)
else:
includes = opt.subnets
includes = opt.subnets + opt.subnets_file
excludes = opt.exclude
if not includes and not opt.auto_nets:
parser.error('at least one subnet, subnet file, '
Expand Down
4 changes: 2 additions & 2 deletions sshuttle/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, option_strings, dest, nargs=None, **kwargs):
super(Concat, self).__init__(option_strings, dest, **kwargs)

def __call__(self, parser, namespace, values, option_string=None):
curr_value = getattr(namespace, self.dest, [])
curr_value = getattr(namespace, self.dest, None) or []
setattr(namespace, self.dest, curr_value + values)


Expand Down Expand Up @@ -269,7 +269,7 @@ def __call__(self, parser, namespace, values, option_string=None):
"-s", "--subnets",
metavar="PATH",
action=Concat,
dest="subnets",
dest="subnets_file",
type=parse_subnet_file,
help="""
file where the subnets are stored, instead of on the command line
Expand Down

0 comments on commit c0c3612

Please sign in to comment.