mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-03-16 00:59:29 +01:00
Allow subnets to be given only by file (-s)
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.
This commit is contained in:
parent
0033efca11
commit
c0c3612e6d
@ -20,13 +20,13 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if opt.firewall:
|
if opt.firewall:
|
||||||
if opt.subnets:
|
if opt.subnets or opt.subnets_file:
|
||||||
parser.error('exactly zero arguments expected')
|
parser.error('exactly zero arguments expected')
|
||||||
return firewall.main(opt.method, opt.syslog)
|
return firewall.main(opt.method, opt.syslog)
|
||||||
elif opt.hostwatch:
|
elif opt.hostwatch:
|
||||||
return hostwatch.hw_main(opt.subnets)
|
return hostwatch.hw_main(opt.subnets)
|
||||||
else:
|
else:
|
||||||
includes = opt.subnets
|
includes = opt.subnets + opt.subnets_file
|
||||||
excludes = opt.exclude
|
excludes = opt.exclude
|
||||||
if not includes and not opt.auto_nets:
|
if not includes and not opt.auto_nets:
|
||||||
parser.error('at least one subnet, subnet file, '
|
parser.error('at least one subnet, subnet file, '
|
||||||
|
@ -106,7 +106,7 @@ class Concat(Action):
|
|||||||
super(Concat, self).__init__(option_strings, dest, **kwargs)
|
super(Concat, self).__init__(option_strings, dest, **kwargs)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
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)
|
setattr(namespace, self.dest, curr_value + values)
|
||||||
|
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ parser.add_argument(
|
|||||||
"-s", "--subnets",
|
"-s", "--subnets",
|
||||||
metavar="PATH",
|
metavar="PATH",
|
||||||
action=Concat,
|
action=Concat,
|
||||||
dest="subnets",
|
dest="subnets_file",
|
||||||
type=parse_subnet_file,
|
type=parse_subnet_file,
|
||||||
help="""
|
help="""
|
||||||
file where the subnets are stored, instead of on the command line
|
file where the subnets are stored, instead of on the command line
|
||||||
|
Loading…
Reference in New Issue
Block a user