Exemplo n.º 1
0
 private static void CreateService()
 {
     if (service != null)
     {
         service.Dispose();
     }
     service = IPBanService.CreateService <IPBanService>();
     service.Start();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Dispose of an IPBanService created with CreateAndStartIPBanTestService
 /// </summary>
 /// <param name="service">Service to dispose</param>
 public static void DisposeIPBanTestService(IPBanService service)
 {
     if (service != null)
     {
         service.Firewall.Truncate();
         service.RunCycle().Sync();
         service.Dispose();
         IPBanService.UtcNow = default;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// IPBan main method
        /// </summary>
        /// <param name="args">Args</param>
        /// <returns>Task</returns>
        public static async Task Main(string[] args)
        {
            if (args.Length != 0 && (args[0].Equals("info", StringComparison.OrdinalIgnoreCase) ||
                                     args[0].Equals("-info", StringComparison.OrdinalIgnoreCase)))
            {
                Logger.Warn("System info: {0}", OSUtility.OSString());
                return;
            }

            IPBanService service = null;
            await IPBanServiceRunner.MainService(args, (CancellationToken cancelToken) =>
            {
                service = IPBanService.CreateService <IPBanService>();
                return(service.RunAsync(cancelToken));
            }, (CancellationToken cancelToken) =>
            {
                service?.Dispose();
                return(Task.CompletedTask);
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// IPBan main method
        /// </summary>
        /// <param name="args">Args</param>
        /// <returns>Task</returns>
        public static async Task Main(string[] args)
        {
            if (ProcessCommandLine(args))
            {
                return;
            }

            IPBanService service = null;
            await IPBanServiceRunner.MainService(args, (CancellationToken cancelToken) =>
            {
                service = IPBanService.CreateService <IPBanService>();
                Logger.Warn("IPBan is free software created and refined over many years.");
                Logger.Warn("Please consider upgrading to the pro version for more advanced functions, shared ban lists and much more.");
                Logger.Warn("Learn more at https://ipban.com");
                return(service.RunAsync(cancelToken));
            }, (CancellationToken cancelToken) =>
            {
                service?.Dispose();
                return(Task.CompletedTask);
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// IPBan main method
        /// </summary>
        /// <param name="args">Args</param>
        /// <returns>Task</returns>
        public static async Task Main(string[] args)
        {
            if (args.Length != 0 && (args[0].Equals("info", StringComparison.OrdinalIgnoreCase) ||
                                     args[0].Equals("-info", StringComparison.OrdinalIgnoreCase)))
            {
                Logger.Warn("System info: {0}", OSUtility.OSString());
                return;
            }

            IPBanService service = null;
            await IPBanServiceRunner.MainService(args, (CancellationToken cancelToken) =>
            {
                service = IPBanService.CreateService <IPBanService>();
                Logger.Warn("IPBan is free software created and refined over many years.");
                Logger.Warn("Please consider upgrading to the pro version for more advanced functions, shared ban lists and much more.");
                Logger.Warn("Learn more at https://ipban.com");
                return(service.RunAsync(cancelToken));
            }, (CancellationToken cancelToken) =>
            {
                service?.Dispose();
                return(Task.CompletedTask);
            });
        }