Esempio n. 1
0
        public SetRulesResponse UpdateRules(SetRulesRequest rules)
        {
            ToastHelper.PopToast("Update rules");

            var rulesToApply = rules.GenericRequest;

            if (rulesToApply.Count <= 0)
            {
                return(new SetRulesResponse()
                {
                    Success = false
                });
            }

            List <Rule> domainRules = rulesToApply.Select(x => (Rule)(new WindowsRuleAdapter(x).NativeType)).ToList();

            foreach (var rule in domainRules)
            {
                FirewallHelper.NewRule(rule);
            }

            return(new SetRulesResponse()
            {
                Success = true
            });
        }
Esempio n. 2
0
        public SetRuleResponse NewRule(SetRuleRequest dtoRule)
        {
            ToastHelper.PopToast("New rule");

            Rule domainRule;

            if (dtoRule.WindowsRequst != null)
            {
                domainRule = dtoRule.WindowsRequst;
            }
            else if (dtoRule.GenericRequest != null)
            {
                domainRule = (Rule)(new WindowsRuleAdapter(dtoRule.GenericRequest).NativeType);
            }
            else
            {
                return(new SetRuleResponse()
                {
                    Success = false
                });
            }

            FirewallHelper.NewRule(domainRule);
            return(new SetRuleResponse()
            {
                Success = true
            });
        }
Esempio n. 3
0
        public SetRuleResponse NewRule(SetRuleRequest rule)
        {
            ToastHelper.PopToast("New rule");

            Linux.Models.Rule newEntry = null;

            if (rule.GenericRequest != null)
            {
                newEntry = (Linux.Models.Rule)(new LinuxRuleAdapter(rule.GenericRequest).NativeType);
            }
            else if (rule.UfwRequest != null)
            {
                newEntry = rule.UfwRequest;
            }

            //var st = Mapper.Map<FirewallAPI.Rule>(newEntry);
            FirewallHelper.NewRule(newEntry);
            return(new SetRuleResponse()
            {
                Success = true
            });
        }