修复TUN/TAP启动时会被无关适配器的异常所中断导致启动失败

This commit is contained in:
ChsBuffer
2020-08-10 23:34:48 +08:00
parent e60f8e7c4a
commit e8fbde707b
2 changed files with 54 additions and 49 deletions

View File

@@ -92,8 +92,7 @@ namespace Netch.Controllers
RedirectStandardOutput = RedirectStd,
UseShellExecute = !RedirectStd,
WindowStyle = ProcessWindowStyle.Hidden
},
EnableRaisingEvents = true
}
};
}
@@ -111,11 +110,12 @@ namespace Netch.Controllers
{
// 初始化程序
InitInstance(argument);
Instance.EnableRaisingEvents = true;
if (RedirectStd)
{
// 清理日志
_logPath ??= Path.Combine(Global.NetchDir, $"logging\\{Name}.log");
if (_logFileStream == null && File.Exists(_logPath))
if (File.Exists(_logPath))
File.Delete(_logPath);
_logFileStream = new FileStream(_logPath, FileMode.Create, FileAccess.Write);
@@ -239,7 +239,7 @@ namespace Netch.Controllers
}
catch (Exception e)
{
Logging.Error($"写入 {Name} 日志错误:\n" + e.Message);
Logging.Warning($"写入 {Name} 日志错误:\n" + e.Message);
}
}
}