日志输出路由表添加失败项

This commit is contained in:
ChsBuffer
2020-09-02 15:41:11 +08:00
parent fd8185b83e
commit 2705f5c160

View File

@@ -362,14 +362,7 @@ namespace Netch.Controllers
{
foreach (var address in ipNetworks)
{
try
{
RouteAction(action, address, routeType, metric);
}
catch
{
// ignored
}
RouteAction(action, address, routeType, metric);
}
}
@@ -396,12 +389,19 @@ namespace Netch.Controllers
throw new ArgumentOutOfRangeException(nameof(routeType), routeType, null);
}
return action switch
var result = action switch
{
Action.Create => NativeMethods.CreateRoute(ipNetwork.Network.ToString(), ipNetwork.Cidr, gateway, index, metric),
Action.Delete => NativeMethods.DeleteRoute(ipNetwork.Network.ToString(), ipNetwork.Cidr, gateway, index, metric),
_ => throw new ArgumentOutOfRangeException(nameof(action), action, null)
};
if (!result)
{
Logging.Warning($"{action} Route on {routeType} Adapter failed: {ipNetwork}/{ipNetwork.Cidr} metric {metric}");
}
return result;
}
}
}