Class IpGuard
java.lang.Object
de.gustavblass.nginx.ipguard4j.cli.IpGuard
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classGroups the options that are only meaningful in combination withIpGuard.ConfigurationMode.configurationFile.private static classContains the different quasi-subcommands that are available to users. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.logging.log4j.Loggerprivate @Nullable Fileprivate @Nullable LogLevelprivate IpGuard.ModeExactly one of the quasi-subcommands defined byIpGuard.Modemust be specified. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull Integercall()Depending on themode, does the following:private intEnables or disables logging based on the command-line parameters passed to the program.private @NonNull ConfigurationCreates aConfigurationobject from the YAML configuration file.
-
Field Details
-
LOG
private static final org.apache.logging.log4j.Logger LOG -
mode
Exactly one of the quasi-subcommands defined byIpGuard.Modemust be specified. It determines what exactly the application shall do.- See Also:
-
logFile
-
logLevel
-
-
Constructor Details
-
IpGuard
public IpGuard()
-
-
Method Details
-
call
Depending on the
mode, does the following:IpGuard.Mode.configurationMode: The configuration file will be parsed and the IP lists specified in theConfigurationwill be downloaded, deduplicated and saved to the target files specified in the configuration.IpGuard.Mode.printYamlSchema: The YAML schema for configuration files will be printed to the console.IpGuard.Mode.printJsonSchema: The JSON schema for configuration files will be printed to the console.- example configuration file in YAML format will be printed to the console.
-
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.IllegalArgumentExceptionCreates a
Configurationobject 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 regularFile.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.
-