public ConfigureResponse Configure(ConfigureRequest request) { ToastHelper.PopToast("Configure"); if (request.FirewallEnabled) { FirewallHelper.Enable(); } else { FirewallHelper.Disable(); } return(new ConfigureResponse() { FirewallEnabled = FirewallHelper.IsEnabled() }); }
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 }); }
public void OnStart(string[] args) { try { ToastHelper.PopToast("Starting..."); Console.WriteLine("Starting API"); var api = Task.Run(delegate { API.Program.Main(args, new ApiCallbacks(), new ApiConfiguration()); }); Console.WriteLine("Starting Netfilter Listener"); var logHelper = Task.Run(delegate { netfilterLogHelper.Start(); }); Console.WriteLine("Starting UFW Listener"); var ufwLogHelperTask = Task.Run(delegate { ufwLogHelper.Start(); }); Task.Run(delegate { snmpClient.Start(); }); Task.WhenAll(api, logHelper, ufwLogHelperTask).Wait(); } catch (Exception e) { StringBuilder sb = new StringBuilder(); sb.AppendLine(e.Message); sb.AppendLine("\n\n"); sb.AppendLine(e.StackTrace); if (e.InnerException != null) { sb.AppendLine("\n\n\n\n"); sb.AppendLine(e.InnerException.Message); sb.AppendLine("\n\n"); sb.AppendLine(e.InnerException.StackTrace); } ExceptionHelper.WriteFile("Global", sb.ToString()); } }
public void DeleteRule(string id) { ToastHelper.PopToast("Delete rule"); FirewallHelper.DeleteRule(Convert.ToUInt32(id)); }