Class Main
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIndicates how the program has been deployed on a system. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final @NonNull StringThe name of the terminal command used to invoke the program when it has been installed on a Linux system via a package manager.private static final @NonNull Main.InstallationTypeThe way the program was actually installed on the system running it.private static final @NonNull StringThe file name of the JAR which contains the compiled program currently running.private static final org.apache.logging.log4j.Loggerstatic final @NonNull StringHuman-readable title of the application, as used in the name of the JAR file.private static final @NonNull ThreadPrints a farewell message to the console.private static @Nullable org.semver4j.SemverThe current version of the application.private static final @NonNull StringThe path to / name of thePropertiesfile which contains the version of the program, relative to theMainclass' resource folder.private static final @NonNull ReentrantReadWriteLockEnsures mutual exclusion when accessing theVERSION. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull org.semver4j.Semver(package private) static voidParses theConfigurationpassed to the program via the command-line parameters, downloads the IP lists specified, deduplicates the IP-address entries and saves the resulting collection to the configured target files.static voidsetLoggingLevel(org.apache.logging.log4j.Level logLevel, File logFile, boolean printToConsole) Configures Log4J to log to the console and to the file specified bylogFilePath.
-
Field Details
-
LOG
private static final org.apache.logging.log4j.Logger LOG -
NAME
-
VERSION
@Nullable private static @Nullable org.semver4j.Semver VERSIONThe current version of the application.
Access only through
getVersion()! -
VERSION_LOCK
Ensures mutual exclusion when accessing theVERSION. -
SHUTDOWN_HOOK
Prints a farewell message to the console. Intended to be used as a shutdown hook for when the JVM exits. -
VERSION_FILE_PATH
The path to / name of thePropertiesfile which contains the version of the program, relative to theMainclass' resource folder.- See Also:
-
INSTALLATION_TYPE
The way the program was actually installed on the system running it.
Can be overridden by setting the system property
ipguard.installation.typeto a validMain.InstallationTypelabel. -
JAR_NAME
The file name of the JAR which contains the compiled program currently running. If the actual file name could not be determined,
ipguard4j.jarwill be used instead.Can be overridden by setting the system property
ipguard.jar.name. Must not be blank. -
COMMAND
The name of the terminal command used to invoke the program when it has been installed on a Linux system via a package manager.
Defaults to
java -jar <JAR_NAME>(withJAR_NAMEinserted) forMain.InstallationType.JAR,ipguardforMain.InstallationType.NATIVE.
Can be overridden by setting the system property
ipguard.installation.commandto something else (must not be blank).
-
-
Constructor Details
-
Main
public Main()
-
-
Method Details
-
main
Parses theConfigurationpassed to the program via the command-line parameters, downloads the IP lists specified, deduplicates the IP-address entries and saves the resulting collection to the configured target files. -
getVersion
@NonNull public static @NonNull org.semver4j.Semver getVersion()- Returns:
- The
VERSIONof the program. - Implementation Note:
- Acquires the
VERSION_LOCK's read lock first, and if theVERSIONhas not yet been computed, acquires the write lock to compute it.
-
setLoggingLevel
public static void setLoggingLevel(org.apache.logging.log4j.Level logLevel, File logFile, boolean printToConsole) Configures Log4J to log to the console and to the file specified bylogFilePath. The log file will be created if it does not exist. Any pre-existing content will not be overwritten, but appended to.- Parameters:
logLevel- The new minimum logging level at (or above) which messages will be logged. Lower-level messages will be ignored.logFile- The directory and file name of the log file to append the log messages to.printToConsole- Whether the logged messages shall be output to the console.- Implementation Note:
- Partially generated by an LLM due to severe lack of knowledge and patience.
-