Class IpGuard

java.lang.Object
de.gustavblass.nginx.ipguard4j.cli.IpGuard
All Implemented Interfaces:
Callable<Integer>

public class IpGuard extends Object implements Callable<Integer>
The main class of the application. It is the entry point of the program and is responsible for parsing the command-line arguments and executing the appropriate actions.
  • Field Details

    • LOG

      private static final org.apache.logging.log4j.Logger LOG
    • mode

      private IpGuard.Mode mode
      Exactly one of the quasi-subcommands defined by IpGuard.Mode must be specified. It determines what exactly the application shall do.
      See Also:
    • logFile

      @Nullable private @Nullable File logFile
    • logLevel

      @Nullable private @Nullable LogLevel logLevel
  • Constructor Details

    • IpGuard

      public IpGuard()
  • Method Details

    • call

      @NonNull public @NonNull Integer call()

      Depending on the mode, does the following:

      Specified by:
      call in interface Callable<Integer>
      Returns:
      The ExitCode that indicates the success or failure of the selected operation.
    • handleLoggingArguments

      private int handleLoggingArguments()
      Enables or disables logging based on the command-line parameters passed to the program.
    • parseConfiguration

      @NonNull private @NonNull Configuration parseConfiguration() throws de.gustavblass.commons.exceptions.IllegalStateException, de.gustavblass.commons.exceptions.NotAFileException, IOException, de.gustavblass.commons.exceptions.IllegalArgumentException

      Creates a Configuration object from the YAML configuration file.

      Exits if the configuration file does not match the expected format or if the configuration file could not be read due to an input/output error.

      Returns:
      The Configuration representing the YAML file.
      Throws:
      de.gustavblass.commons.exceptions.IllegalStateException - If no configuration file has been specified.
      FileNotFoundException - If the configuration file does not exist.
      de.gustavblass.commons.exceptions.NotAFileException - If the configuration file is not a regular File.
      IOException - If the configuration file could not be read due to an input/output error.
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the configuration is semantically invalid.