Exemplo n.º 1
0
        public static async Task InitIpWhite(IAdminSecurityApplication ipAddressApplication)
        {
            var ipFirewall = IpFirewallHelper.GetIpFirewall();
            var list2      = await ipAddressApplication.GetIpAllowAll();

            ipFirewall.SetIpAllowList(list2.Select(q => q.Ip).ToList());
        }
Exemplo n.º 2
0
        public static async Task InitIpBlack(IAdminSecurityApplication ipAddressApplication)
        {
            var ipFirewall = IpFirewallHelper.GetIpFirewall();
            var list       = await ipAddressApplication.GetIpBanAll();

            ipFirewall.SetIpBanList(list.Select(q => q.Ip).ToList());
        }
Exemplo n.º 3
0
        public static async Task Init()
        {
            IAdminSecurityApplication ipAddressApplication = MyIoc.Create <IAdminSecurityApplication>();
            var useIpType = await ipAddressApplication.GetUseIpType();

            var ipFirewall = IpFirewallHelper.GetIpFirewall();
            var list       = await ipAddressApplication.GetIpBanAll();

            ipFirewall.SetIpBanList(list.Select(q => q.Ip).ToList());
            var list2 = await ipAddressApplication.GetIpAllowAll();

            ipFirewall.SetIpAllowList(list2.Select(q => q.Ip).ToList());

            if (useIpType == 1)
            {
                ipFirewall.UseIpBanList();
            }
            else if (useIpType == 2)
            {
                ipFirewall.UseIpAllowList();
            }
            else
            {
                ipFirewall.CloseFirewall();
            }
        }
        public async Task ResetIpFilter()
        {
            var type = await GetUseIpType();

            IpFirewallHelper ipFirewallHelper = IpFirewallHelper.GetIpFirewall();

            if (type == 0)
            {
                ipFirewallHelper.CloseFirewall();
            }
            else if (type == 1)
            {
                ipFirewallHelper.UseIpAllowList();
                var all = await GetIpAllowAll();

                ipFirewallHelper.SetIpAllowList(all.Select(q => q.Ip).ToList());
                all = null;
            }
            else if (type == 2)
            {
                ipFirewallHelper.UseIpBanList();
                var all = await GetIpBanAll();

                ipFirewallHelper.SetIpBanList(all.Select(q => q.Ip).ToList());
                all = null;
            }
        }
Exemplo n.º 5
0
        public static void SetFirewallType(int useIpType)
        {
            var ipFirewall = IpFirewallHelper.GetIpFirewall();

            if (useIpType == 1)
            {
                ipFirewall.UseIpBanList();
            }
            else if (useIpType == 2)
            {
                ipFirewall.UseIpAllowList();
            }
            else
            {
                ipFirewall.CloseFirewall();
            }
        }