Commit Graph
43 Commits
Author SHA1 Message Date
kor-elf 4bfa7ffc1b Update IcmpInRate field for improved readability
- Changed rate format from "1/s" to "1/second" in `defaultIp4` function.
2025-11-01 11:32:13 +05:00
kor-elf e42ddded71 Add port-based traffic control support to firewall configuration
- Introduced `Ports` struct with customizable fields for numbers, directions, protocols, actions, and rate limiting.
- Added methods to convert port configurations into `InPorts` and `OutPorts`.
- Updated `firewall` settings to include port-related configurations and extended validation.
- Enhanced input and output reload methods to process port-based rules for better granularity.
- Updated `firewall.toml` with port settings, including examples and documentation.
2025-11-01 10:58:00 +05:00
kor-elf 7abdd78ad5 Add IPv6 support to firewall configuration
- Introduced `IP6` struct with `enable` and `icmp_strict` options.
- Extended `firewall.toml` with new IPv6-related settings and documentation.
- Updated input reload methods to include IPv6 rules and ICMPv6 handling.
- Added strict ICMPv6 mode with granular rule definitions.
- Incorporated IPv6 support in settings validation and configuration logic.
2025-10-29 22:27:08 +05:00
kor-elf 165b6f8d79 Add centralized validation for firewall and daemon configurations
- Introduced `validate` package for centralized configuration validation.
- Added validation for paths, filenames, and specific extensions (e.g., `.toml`, `.pid`, `.log`).
- Enhanced `firewall` settings with validation logic (e.g., `table_name`, `chain_input_name`, `saves_rules_path`, `icmp_in_rate`, `input_drop`).
- Updated `daemon` PID file handling for additional checks on file type and content.
- Improved error handling and validation coverage for settings initialization.
2025-10-29 21:55:52 +05:00
kor-elf 10e13be291 Add centralized firewall chain management and default policy configuration
- Consolidated chain creation and management into a `chain` package for improved structure.
- Introduced default policies (`default_allow_input`, `default_allow_output`, `default_allow_forward`) for input, output, and forward traffic control.
- Added support for policy-specific drop behaviors (`input_drop`, `output_drop`, `forward_drop`) to firewall configuration.
- Updated reload methods to utilize the centralized `chain` management interface.
- Enhanced `firewall.toml` with new policy options and improved documentation.
- Refactored related code to streamline chain handling and configuration logic.
2025-10-29 00:39:55 +05:00
kor-elf dde619f6be Add ICMP traffic handling in firewall configuration
- Introduced `icmp_in`, `icmp_in_rate`, `icmp_out`, `icmp_out_rate`, and `icmp_timestamp_drop` options for ICMP traffic control.
- Added rules for managing incoming and outgoing ICMP traffic based on configuration settings.
- Updated `firewall.toml` with ICMP-related options and documentation.
- Enhanced input and output reload methods to include ICMP traffic handling.
2025-10-28 20:54:39 +05:00
kor-elf 52d5df5ca8 Add packet filtering for invalid and out-of-order packets
- Introduced `packet_filter` option to enable dropping invalid and out-of-order packets.
- Added new nftables chains and rules to handle invalid state and TCP flag anomalies.
- Updated `firewall.toml` with `packet_filter` configuration and documentation.
- Enhanced firewall initialization to include packet filtering logic.
2025-10-27 22:40:02 +05:00
kor-elf 6b9af27090 Add DNS traffic handling with strict nftables rules
- Introduced `dns_strict` and `dns_strict_ns` options for enhanced DNS traffic control.
- Added parsing of `/etc/resolv.conf` to retrieve and process nameserver addresses.
- Updated firewall configuration to apply specific rules for DNS traffic.
- Enhanced `firewall.toml` with new options for DNS strict mode and documentation.
2025-10-27 20:54:31 +05:00
kor-elf 2ada717857 Refactor firewall options into a dedicated struct
- Extracted `SavesRules` and `SavesRulesPath` into `options` struct for improved organization.
- Updated `firewall` settings to utilize the new `options` struct.
- Modified `firewall.toml` configuration to reflect the structural changes.
- Adjusted related methods and functions to handle the new structure.
2025-10-27 19:20:27 +05:00
kor-elf a9892bdb7f Add fallback to clear firewall rules on reload failure
- Updated `daemon.go` to invoke `d.firewall.ClearRules()` if `d.firewall.Reload()` fails, ensuring a clean state.
2025-10-27 00:01:08 +05:00
kor-elf 5b55ae506a Fix import formatting in start.go to improve code readability and maintain consistency. 2025-10-26 23:30:06 +05:00
kor-elf c30b8043c3 Correct import order in main.go for improved readability and adherence to Go conventions. 2025-10-26 23:28:44 +05:00
kor-elf 3fa3c2bc88 Wrap file.Close() in a deferred function to handle error suppression during PID file operations. 2025-10-26 23:28:13 +05:00
kor-elf 72e76c660e Add default policies and enhanced nftables chain handling in firewall
- Introduced default input, output, and forward policies for firewall management.
- Enhanced chain configuration with specific naming for input, output, and forward chains.
- Updated `firewall.toml` with policy settings and chain name configurations.
- Refactored `firewall` package to include reload and configuration synchronization for policies.
2025-10-26 23:26:11 +05:00
kor-elf 7f882fa3ae Update import paths to use fully qualified module name
- Replaced local import paths with fully qualified paths prefixed by `git.kor-elf.net`.
- Updated `go.mod` module declaration to match the new module name.
2025-10-26 19:58:22 +05:00
kor-elf 729953cc17 Add firewall package with nftables support and configuration handling
- Introduced `firewall` package with `API` interface for managing nftables rules.
- Added `Reload`, `ClearRules`, and `SavesRules` methods for rule management.
- Implemented configuration parsing for firewall settings using `firewall.toml`.
- Updated `internal/setting` with default firewall configurations.
- Integrated `go-nftables-client` for low-level manipulation of nftables.
2025-10-26 00:20:41 +05:00
kor-elf 3d1d4f5200 Add testing mode and firewall configuration to daemon
- Introduced `testing` and `testing_interval` options in configuration for test mode management.
- Added support for firewall configuration and integration via `firewall` package.
- Updated daemon lifecycle to handle testing mode and test interval expiration.
- Extended `kor-elf-shield.toml` with new configuration options and documentation.
2025-10-26 00:19:44 +05:00
kor-elf 2a884b24b9 Refactor runDaemon to pass context and improve logger cleanup
- Updated `runDaemon` to accept and propagate context for better lifecycle management.
- Wrapped logger `Sync` call in a function to handle errors gracefully.
2025-10-25 20:40:35 +05:00
kor-elf 6a89550737 Validate logger in pidfile and improve PID-related log messages
- Ensure `logger` is not nil during PID file initialization.
- Standardize usage of "PID" in log messages for consistency and clarity.
2025-10-25 20:38:41 +05:00
kor-elf 927bd8162d Add daemon package with support for start command
- Introduced `Daemon` interface and default implementation for process management.
- Added `start` CLI command to initialize and run the daemon.
- Integrated PID file handling using `pidfile` package for ensuring single process execution.
- Updated main application to register `start` command.
2025-10-13 20:44:59 +05:00
kor-elf a07357cdd1 Add pidfile package to manage daemon PID files
- Introduced `PidFile` interface with methods for PID file validation, creation, and removal.
- Implemented `EnsureNoOtherProcess` to handle PID file conflicts and outdated entries.
- Added structured logger support for better observability in PID file operations.
2025-10-13 20:42:48 +05:00
kor-elf 23aaeb0dbc Remove unused debug log statement from Config.Log.Level in main.go. 2025-10-13 20:42:03 +05:00
kor-elf a7b88ff4fe Add pid_file configuration and validation in setting package
- Introduced `pid_file` field in configuration with default path.
- Implemented validation for `pid_file` in `ToDaemonOptions` with localized error handling.
- Updated `kor-elf-shield.toml` to include `pid_file` documentation.
2025-10-13 20:41:30 +05:00
kor-elf 932670e36d Refactor EnsureDir to use mkdirAllWithChmod for improved permission handling and directory creation 2025-10-13 20:40:28 +05:00
kor-elf e5ae14d855 Add Fatal method to Logger interface and implement os.Exit(1) behavior
- Introduced `Fatal` method for structured logging with immediate program exit.
- Updated `falseLogger` to implement `Fatal` method.
- Added `zap.AddCallerSkip(1)` for accurate caller information in logs.
- Adjusted `LoggerOptions` argument in `NewLogger` for consistency.
2025-10-13 20:39:20 +05:00
kor-elf 2ffad8584a Add falseLogger as a no-op logger implementation. 2025-10-12 17:21:49 +05:00
kor-elf 1ef42ce3ba Add Logger interface and implementation using zap for structured logging 2025-10-12 17:21:25 +05:00
kor-elf cdfe8b483f Refactor setting.Config accessors to direct field access for clarity and consistency in main.go. 2025-10-12 16:07:24 +05:00
kor-elf cd9497a66e Add log configuration structure and utilities to manage logging settings.
- Includes support for log levels, encodings, paths, and error paths.
- Implements validation for paths and integration with `LoggerOptions`.
2025-10-12 16:06:50 +05:00
kor-elf 89d5ac5300 Introduce LoggerOptions to configure logging with enhanced error handling. 2025-10-12 16:05:33 +05:00
kor-elf ce670cefaf Add FileHasWritePermissions utility to check file write permissions with localized error handling. 2025-10-12 16:04:36 +05:00
kor-elf 2847478ffb Add EnsureDir utility to create directories with appropriate permissions and error localization. 2025-10-12 16:04:15 +05:00
kor-elf 187fc9dc4b Add logging configuration to kor-elf-shield.toml file with detailed settings and documentation 2025-10-12 16:03:39 +05:00
kor-elf ceced8683a Improve error localization by adding translations for "Command error" in supported languages and updating error message formatting in main.go. 2025-10-08 00:14:25 +05:00
kor-elf 9ec9742923 Replace error handling return statements with os.Exit(1) to ensure proper termination on initialization failures. 2025-10-08 00:05:07 +05:00
kor-elf 2516bea30a Introduce main.go as the program entry point; initialize settings, localization, and main application logic. 2025-10-07 23:57:24 +05:00
kor-elf 4afecc70f8 Introduce cmd package with main application logic and signal handling functionality. 2025-10-07 23:56:52 +05:00
kor-elf d332e19d0e Added a settings file that will be copied during program installation. 2025-10-07 22:53:36 +05:00
kor-elf 47113a5166 Introduce setting package for configuration management. 2025-10-07 22:43:45 +05:00
kor-elf a0d3f0235e Improve i18n initialization and dynamic locale loading; handle errors in language changes. 2025-10-07 22:39:17 +05:00
kor-elf d6b223b2c2 Refactor translation module to i18n; adjust localization structure and improve language change handling. 2025-10-06 22:02:13 +05:00
kor-elf 0e5997c066 Add translation module with language support and localization functionality. 2025-09-16 00:23:41 +05:00
kor-elf 483d608e57 Add MIT License. 2025-09-15 22:56:16 +05:00