Commit b555dc1c authored by Jondy Zhao's avatar Jondy Zhao

Use subprocess.STDOUT other than subprocess.OUTPUT in the Cygwin;

When get ipv6 route table, netsh return interface index other than
name in the Windows 7.
parent 330ae7e8
......@@ -305,19 +305,36 @@ class TunnelManager(object):
if sys.platform == 'cygwin':
def _iterRoutes(self):
interface_dict = {}
interfaces = subprocess.check_output(
('netsh', 'interface', 'ipv6', 'show', 'interface'),
stderr=subprocess.STDOUT)
for line in interfaces.splitlines():
if not line == '':
fs = line.split(None, 4)
if fs[0].isdigit():
interface_dict[fs[0].strip()] = fs[4].strip()
routing_table = subprocess.check_output(
('netsh', 'interface', 'ipv6', 'show', 'route', 'verbose'),
stderr=subprocess.OUTPUT)
pname = 'Prefix' if platform.system()[10:11] == '5' else 'Destination Prefix'
stderr=subprocess.STDOUT)
# Before Vista
if platform.system()[10:11] == '5':
pname = 'Prefix'
ifname = lambda a : a
# From Vista later
else:
pname = 'Destination Prefix'
ifname = interface_dict.get
for line in routing_table.splitlines():
fs = line.split(':', 1)
test = fs[0].startswith
if test(pname):
prefix, prefix_len = fs[1].split('/', 1)
elif test('Interface'):
yield (fs[1].strip(),
utils.binFromIp(prefix),
yield (ifname(fs[1].strip()),
prefix,
int(prefix_len))
else:
def _iterRoutes(self):
with open('/proc/net/ipv6_route') as f:
......
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