Use Npcap DLL on Windows when checking for uBridge version.

This commit is contained in:
grossmj 2017-09-01 16:22:43 +07:00
parent 7492899b95
commit ee486b32bd

View File

@ -129,12 +129,12 @@ class Hypervisor(UBridgeHypervisor):
return self._version return self._version
@asyncio.coroutine @asyncio.coroutine
def _check_ubridge_version(self): def _check_ubridge_version(self, env=None):
""" """
Checks if the ubridge executable version Checks if the ubridge executable version
""" """
try: try:
output = yield from subprocess_check_output(self._path, "-v", cwd=self._working_dir) output = yield from subprocess_check_output(self._path, "-v", cwd=self._working_dir, env=env)
match = re.search("ubridge version ([0-9a-z\.]+)", output) match = re.search("ubridge version ([0-9a-z\.]+)", output)
if match: if match:
self._version = match.group(1) self._version = match.group(1)
@ -151,13 +151,13 @@ class Hypervisor(UBridgeHypervisor):
Starts the uBridge hypervisor process. Starts the uBridge hypervisor process.
""" """
yield from self._check_ubridge_version()
env = os.environ.copy() env = os.environ.copy()
if sys.platform.startswith("win"): if sys.platform.startswith("win"):
# add the Npcap directory to $PATH to force uBridge to use npcap DLL instead of Winpcap (if installed) # add the Npcap directory to $PATH to force uBridge to use npcap DLL instead of Winpcap (if installed)
system_root = os.path.join(os.path.expandvars("%SystemRoot%"), "System32", "Npcap") system_root = os.path.join(os.path.expandvars("%SystemRoot%"), "System32", "Npcap")
if os.path.isdir(system_root): if os.path.isdir(system_root):
env["PATH"] = system_root + ';' + env["PATH"] env["PATH"] = system_root + ';' + env["PATH"]
yield from self._check_ubridge_version(env)
try: try:
command = self._build_command() command = self._build_command()
log.info("starting ubridge: {}".format(command)) log.info("starting ubridge: {}".format(command))