Пример #1
0
 private bool TestDefaultOutboundAction(NET_FW_ACTION_ Action)
 {
     if (mFirewallPolicy.get_DefaultOutboundAction(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_PRIVATE) != Action)
     {
         return(false);
     }
     if (mFirewallPolicy.get_DefaultOutboundAction(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_DOMAIN) != Action)
     {
         return(false);
     }
     if (mFirewallPolicy.get_DefaultOutboundAction(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_PUBLIC) != Action)
     {
         return(false);
     }
     return(true);
 }
Пример #2
0
        public bool OutboundConnectionsAllowedOn(ProfileDto profileDto)
        {
            var profile = (NET_FW_PROFILE_TYPE2_)profileDto;
            var action  = firewallPolicy.get_DefaultOutboundAction(profile);

            return(action == NET_FW_ACTION_.NET_FW_ACTION_ALLOW);
        }
Пример #3
0
 public FirewallRule.Actions GetDefaultOutboundAction(FirewallRule.Profiles profileType)
 {
     if (NetFwPolicy.get_DefaultOutboundAction((NET_FW_PROFILE_TYPE2_)profileType) == NET_FW_ACTION_.NET_FW_ACTION_BLOCK)
     {
         return(FirewallRule.Actions.Block);
     }
     return(FirewallRule.Actions.Allow);
 }
Пример #4
0
        static void publicFirewall()
        {
            Type                  netFwPolicy2Type = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
            INetFwPolicy2         mgr = (INetFwPolicy2)Activator.CreateInstance(netFwPolicy2Type);
            NET_FW_PROFILE_TYPE2_ fwPublicProfileType = NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_PUBLIC;

            Console.WriteLine("Public Profile Type:");

            var firewallEnabled        = mgr.get_FirewallEnabled(fwPublicProfileType);
            var blockAllInboundTraffic = mgr.get_BlockAllInboundTraffic(fwPublicProfileType);
            var defaultInboundAction   = mgr.get_DefaultInboundAction(fwPublicProfileType);
            var defaultOutboundAction  = mgr.get_DefaultOutboundAction(fwPublicProfileType);

            Console.WriteLine($"Firewall Enabled: {firewallEnabled.ToString()}");
            Console.WriteLine($"Block All Inbound Traffic: {blockAllInboundTraffic.ToString()}");
            Console.WriteLine($"Default Inbound Action:{defaultInboundAction.ToString()}");
            Console.WriteLine($"Default Outbound Action:{defaultOutboundAction.ToString()}");
        }
Пример #5
0
        /* Returns default outbound action (Block|Allow) for profile */
        public String getCurOutboundAction(NET_FW_PROFILE_TYPE2_ profile)
        {
            var curAction  = "None";
            var curActions = new List <string>();
            var fwProfiles = Enum.GetValues(typeof(NET_FW_PROFILE_TYPE2_));

            updateCurrentProfile();
            foreach (NET_FW_PROFILE_TYPE2_ fwProfile in fwProfiles)
            {
                if ((profile & fwProfile) == fwProfile)
                {
                    curActions.Add(getActionName(fw.get_DefaultOutboundAction(fwProfile)));
                }
            }

            if (curActions.Count > 0)
            {
                curAction = String.Join(",", curActions);
            }
            return(curAction);
        }