public static void DeleteRouteFill(NetRoute template, IEnumerable <string> rules, int?metric = null) { foreach (var rule in rules) { DeleteRouteFill(template, rule, metric); } }
public static bool DeleteRouteFill(NetRoute template, string rule, int?metric = null) { if (!TryParseIPNetwork(rule, out var network, out var cidr)) { Log.Warning("invalid rule {Rule}", rule); return(false); } return(DeleteRoute(template.FillTemplate(network, (byte)cidr, metric))); }
public static bool CreateRouteFill(NetRoute template, string rule, int?metric = null) { if (!TryParseIPNetwork(rule, out var network, out var cidr)) { Global.Logger.Warning($"invalid rule {rule}"); return(false); } return(CreateRoute(template.FillTemplate(network, (byte)cidr, metric))); }
public static bool DeleteRoute(NetRoute o) { Log.Verbose("DeleteRoute {InterNetwork} {Address} {Cidr} {Gateway} {Interface} {Metric}", AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric); return(RouteHelper.DeleteRoute(AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric)); }
public static bool CreateRoute(NetRoute o) { #if DEBUG_TUN Log.Verbose("CreateRoute {InterNetwork} {Address} {Cidr} {Gateway} {Interface} {Metric}", AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric); #endif return(RouteHelper.CreateRoute(AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric)); }
public static bool DeleteRoute(NetRoute o) { var Result = RouteHelper.DeleteRoute(AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric); #if DEBUG_TUN Log.Verbose("DeleteRoute {InterNetwork} {Address} {Cidr} {Gateway} {Interface} {Metric} Result: {}", AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric, Result); #endif return(Result); }
public static NetRoute[] Get() { var args = CommonString.Append(route, " ", show); var result = CommonProcess.Execute(ipFileLocation, args).Where(_ => !_.Contains(protoKernel)).ToArray(); var routes = new NetRoute[result.Length]; for (var i = 0; i < result.Length; i++) { var currentLine = result[i]; var currentLineData = currentLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); routes[i] = new NetRoute() { Default = currentLine.Contains(@default) ? true : false, Destination = currentLine.Contains(@default) ? @default : currentLineData[0], Gateway = Help.CaptureGroup(currentLine, "(via [0-9\\.]+)").Replace("via", "").Trim(), Device = Help.CaptureGroup(currentLine, "(dev [a-zA-Z0-9\\.]+)").Replace("dev", "").Trim() }; } return(routes); }
public static bool DeleteRoute(NetRoute o) { return(RouteHelper.DeleteRoute(AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric)); }