mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-01-19 04:18:23 +01:00
Exclude the IP where sshuttle is really listening
We were always excluding 127.0.0.1/8 but sshuttle might be listening on other IP, e.g., ::1 for IPv6 or any other defined with -l
This commit is contained in:
parent
e0dfb95596
commit
e9be2deea0
@ -549,6 +549,7 @@ def main(listenip_v6, listenip_v4,
|
||||
listenip_v6 = None
|
||||
|
||||
required.ipv6 = len(subnets_v6) > 0 or listenip_v6 is not None
|
||||
required.ipv4 = len(subnets_v4) > 0 or listenip_v4 is not None
|
||||
required.udp = avail.udp
|
||||
required.dns = len(nslist) > 0
|
||||
|
||||
@ -571,6 +572,14 @@ def main(listenip_v6, listenip_v4,
|
||||
if listenip_v4 == "auto":
|
||||
listenip_v4 = ('127.0.0.1', 0)
|
||||
|
||||
if required.ipv4 and \
|
||||
not any(listenip_v4[0] == sex[1] for sex in subnets_v4):
|
||||
subnets_exclude.append((socket.AF_INET, listenip_v4[0], 32))
|
||||
|
||||
if required.ipv6 and \
|
||||
not any(listenip_v6[0] == sex[1] for sex in subnets_v6):
|
||||
subnets_exclude.append((socket.AF_INET6, listenip_v6[0], 128))
|
||||
|
||||
if listenip_v6 and listenip_v6[1] and listenip_v4 and listenip_v4[1]:
|
||||
# if both ports given, no need to search for a spare port
|
||||
ports = [0, ]
|
||||
|
@ -187,7 +187,7 @@ parser.add_argument(
|
||||
"-x", "--exclude",
|
||||
metavar="IP/MASK",
|
||||
action="append",
|
||||
default=[parse_subnet('127.0.0.1/8')],
|
||||
default=[],
|
||||
type=parse_subnet,
|
||||
help="""
|
||||
exclude this subnet (can be used more than once)
|
||||
|
Loading…
Reference in New Issue
Block a user