Example #1
0
        /// <summary>
        /// Prints the list of packets handled inconsistently between the two firewalls.
        /// </summary>
        /// <param name="inconsistencies">List of inconsistencies.</param>
        public static void PrintInconsistentPackets(List <WindowsFirewallInconsistency> inconsistencies)
        {
            Console.WriteLine("Inconsistently-handled packets:");
            Console.WriteLine("-------------------------------------------------------------------------");
            Console.WriteLine("|  PID |     Src Address | Src Port | Dest Port | Protocol | Allowed By |");
            Console.WriteLine("-------------------------------------------------------------------------");
            for (int i = 0; i < inconsistencies.Count; i++)
            {
                WindowsFirewallInconsistency inconsistency = inconsistencies[i];
                Console.WriteLine(
                    $"| {i, 4} " +
                    $"| {inconsistency.Packet.SourceAddress?.ToString() ?? "Any", 15} " +
                    $"| {inconsistency.Packet.SourcePort?.ToString() ?? "Any", 8} " +
                    $"| {inconsistency.Packet.DestinationPort?.ToString() ?? "Any", 9} " +
                    $"| {(null == inconsistency.Packet.Protocol ? "Any" : NetworkProtocol.GetProtocolName((int)inconsistency.Packet.Protocol)), 8} " +
                    $"| {(inconsistency.Allowed.Item1 ? "First" : "Second"), 10} |");
            }

            Console.WriteLine("-------------------------------------------------------------------------");
        }