aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.rs
Commit message (Collapse)AuthorAgeFilesLines
* Change splash message formatdilluti0n2026-07-151-1/+2
|
* windows: do not use paexit when there is no errordilluti0n2026-07-141-5/+3
| | | | | | | | loop on CTRL_CLOSE_EVENT handler causes pause occurs when the user closes the console by clicking the 'X' button, which degrades user experience. This change terminates program immediately if no error occurs.
* Use paexit on shutdowndilluti0n2026-07-081-1/+1
| | | | This makes windows users able to see the error message.
* log: add debug!/info!/warn!/error! macros and refactor to use itdilluti0n2026-03-021-5/+3
|
* Move cleanup/trap_exit/RUNNING to platform modulesdilluti0n2026-03-011-31/+1
| | | | | | | | - Remove global RUNNING, trap_exit, EnsureCleanup, MESSAGE_AT_RUN from main.rs - Move each into platform-specific modules (linux.rs, windows.rs) - Move MESSAGE_AT_RUN to platform.rs - Inline cleanup logic into run() instead of separate cleanup() fn - Remove service_run_1() indirection in windows.rs
* nit: rename main_0 to _1dilluti0n2026-02-261-2/+2
|
* Print version info log after daemonizedilluti0n2026-02-161-1/+1
|
* Log version information on startupdilluti0n2026-02-161-0/+1
|
* opt: decouple set_opt() from loggingdilluti0n2026-02-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | set_opt() was logging each option as it set them, which created a tight coupling between option initialization and log output timing. This was particularly problematic for daemon mode: daemonize must happen after set_opt() (to know whether -D was passed) but before logging (so output goes to the log file, not stdout). Split into set_opt() -> InitializedOpts and InitializedOpts::log(), using a typestate pattern to enforce at compile time that log() cannot be called before set_opt(). This lets each platform's bootstrap() handle daemonization between the two steps: let initialized = opt.set_opt()?; platform::bootstrap()?; // daemonize here if needed initialized.log(); // now safe to log Also: - Move daemonize_1() into platform::bootstrap() on both platforms - Make daemonize_1() / service_main() private to their platform modules - Fix the long-standing TODO about using log_println in daemonize()
* linux: repurpose bootstrap to do things before requiring cleanupdilluti0n2026-02-161-3/+1
|
* linux: extract PID_FILE constant for reusedilluti0n2026-02-151-3/+3
|
* Consolidate setup logic into run()dilluti0n2026-02-151-1/+3
| | | | | | | | | | | The bootstrap/run separation was unnecessary. Move all initialization (cleanup + nftables setup): into run() and skip bootstrap in daemon mode. We repurpose the bootstrap() function to only run in non-daemon mode for future foreground-only initialization. - Add OPT_DAEMON option to detect daemon mode - Move cleanup() and install_rules() from bootstrap() to run() - Make bootstrap() a no-op (only called in non-daemon mode)
* opt: refactor to detach parse_args and set_optdilluti0n2026-02-151-1/+5
|
* Refactor main.rs; modulize opt.rs and pkt.rsdilluti0n2026-01-161-208/+9
| | | | | Move option parsing to opt.rs and packet handling to pkt.rs from main.rs
* pkt: support overriding TCP checksum (badsum) in split_packet_0dilluti0n2026-01-161-2/+2
| | | | | | - Extend split_packet_0 to optionally override TCP checksum. - Compute L3 header length for IPv4/IPv6 and patch checksum field when requested. - Wire fake_clienthello to set checksum to 0 when fake_badsum() is enabled.
* Add option --fake-badsumdilluti0n2026-01-141-0/+4
|
* Fix option --fake did not do anythingdilluti0n2026-01-051-2/+8
| | | | Fake was enabled by default.....
* Normalize option handling and OPT_* namingdilluti0n2025-12-301-12/+23
| | | | Log runtime options on startup
* Add fake ClientHello injection runtime optionsdilluti0n2025-12-301-0/+13
| | | | | - Add --fake flag to enable fake ClientHello injection - Add --fake-ttl option to override TTL of fake packets
* Consolidate fake ClientHello and split packet logicdilluti0n2025-12-301-11/+23
| | | | Introduce send_segment abstraction
* Implement fake ClientHello injection with const TTLdilluti0n2025-12-301-40/+7
|
* linux: add option `--nft-command`dilluti0n2025-10-291-3/+12
|
* platform: windows: only divert clienthello packet to userspacedilluti0n2025-10-031-1/+1
|
* Refactor packet sending into split_packet_1 helperdilluti0n2025-09-151-9/+24
| | | | | | | * Extracted: repeated split/send/sleep logic from `handle_packet` into new `split_packet_1` function for clarity and reuse. * Simplifies: `handle_packet` by replacing manual steps with a single call.
* Refactor handle_packet to reuse external buffer for packet handlingdilluti0n2025-09-111-7/+5
| | | | This removes unnecessary allocations per packet handling.
* log: add splash! macro and centralize no-splash handlingdilluti0n2025-09-071-23/+13
| | | | | | | | | | | | | * Introduce: `splash!` macro in `log.rs` to print startup messages conditionally, based on `--no-splash` flag. * Move: `NO_SPLASH` management into `log.rs` with helper functions: (`set_no_splash`, `no_splash`). * Remove: old `splash()` function in `main.rs` and replace with `splash!` macro usage. * Set: default `LogLevel` according to build profile (Debug → Debug, Release → Warning). * Print: unified startup messages across Linux and Windows, including `MESSAGE_AT_RUN`.
* Update copyright notices to notice email instead of github linkdilluti0n2025-09-051-1/+1
|
* main: fix typo on splash message.dilluti0n2025-09-051-1/+1
|
* Update version and metadatas on Cargo.tomldilluti0n2025-09-051-2/+7
| | | | * Use: Cargo.toml inside on program
* Add license document and copyright notice headersdilluti0n2025-09-051-0/+17
|
* Add help message for flag --no-splashdilluti0n2025-09-051-0/+1
|
* Add splash message and option --no-splashdilluti0n2025-09-051-1/+18
|
* Add flag --loglevel to set loglevel on runtimedilluti0n2025-09-031-3/+10
| | | | | | | | | | | | | | | * Introduce: `DEFAULT_LOG_LEVEL` and `LOG_LEVEL_OVERRIDE` (OnceLock) in log.rs. * Add: `set_log_level()` and `current_log_level()`; gate defaults by `debug_assertions`. * Implement: `FromStr` for `LogLevel` with a proper error type (`ParseLogLevelError`). * Update: `log_println!` to respect `current_log_level()` and use `format_args!`. * Extend: CLI: `--loglevel <debug|info|warning|error>` and reflect it in `usage()`. * Replace: ad-hoc prints with `log_println!` and plumb parsed level into `set_log_level`.
* Tidy up LogLevel enum definitiondilluti0n2025-09-031-6/+8
| | | | | | * Remove: unused `Fatal` variant from `LogLevel`. * Update: comment on `Error` to indicate it represents unrecoverable errors.
* Use log.rs for conditional logging and centralized error reportingdilluti0n2025-09-031-3/+3
| | | | | | | | | * Set: `LOG_LEVEL` to `Debug` in debug builds and `Warning` in release builds via `#[cfg(debug_assertions)]`. * Replace: direct `println!` calls with `log_println!` for packet handling, warning messages, and argument parsing errors. * Ensures: consistent log formatting and respects the global log level configuration across the codebase.
* Refactor main to ensure cleanup via RAII guarddilluti0n2025-09-031-2/+31
| | | | | | | | | Introduce `EnsureCleanup` struct with a `Drop` implementation that calls `platform::cleanup()`. This guarantees cleanup is always performed after a successful bootstrap, regardless of how execution exits. Error handling is centralized in `main()`, where errors are logged once with their cause chain, and the process exits with the appropriate status code.
* Refactor prefixed logs to using log.rs, leaving Errors untoucheddilluti0n2025-09-031-0/+1
|
* Move is_client_hello to tls module for better readabilityDilluti0n2025-08-261-24/+1
|
* Fix typo on split_packet error messageDilluti0n2025-08-261-1/+1
|
* Make platform and TLS imports explicitDilluti0n2025-08-231-8/+8
| | | | | | | | * Remove: wildcard import from platform and top-level TLSMsg import. * Add: local use of TLSMsg inside is_client_hello(). * Add: local use of send_to_raw() inside handle_packet(). * Qualify: IS_U32_SUPPORTED, QUEUE_NUM, bootstrap(), run(), and cleanup() with platform::.
* Clean up is_client_hello() for clarityDilluti0n2025-08-231-12/+11
| | | | | | * Remove nested TLSMsg::new() invocation. * Introduce fragment variable for readability. * Simplify control flow by flattening record parsing.
* Simplify signal handling with global AtomicBoolDilluti0n2025-08-231-8/+10
| | | | | | | * Remove Arc<AtomicBool> indirection and introduce global RUNNING. * Rename plant_handler() to trap_exit() for clarity. * Update run() implementations on Linux and Windows to use RUNNING directly. * Drop unused imports in main.rs, linux.rs, and windows.rs.
* Wrap planting handler to plant_handlerdilluti0n2025-08-231-9/+12
|
* Clear output buffer before writing in split_packethskim2025-08-231-2/+1
| | | | | | | Previously split_packet used truncate() after writing, which could leave stale data from earlier writes. This patch calls clear() before builder.write() to ensure the buffer only contains the current packet contents.
* Add command-line argument parsing and switch config to OnceLockhskim2025-08-231-22/+56
| | | | | | | | | | | This change introduces basic CLI parsing for --delay-ms, --queue-num (Linux only), and -h/--help. A usage() function was added, and error/help output now goes to stdout for consistency. Global constants DELAY_MS and QUEUE_NUM are replaced with OnceLock-based initialization, with helper accessors delay_ms() and queue_num(). The Linux platform code is updated accordingly to use queue_num() instead of a constant.
* Deduplicate CLI argument parsinghskim2025-08-231-7/+22
| | | | | Extracted common args.next() + parse logic into take_value() to remove duplication in --delay-ms and --queue-num handling.
* Implement argument parserhskim2025-08-231-1/+21
|
* Wrap platform dependant main loops to platform::runhskim2025-08-221-66/+3
|
* Fix Message too long warning on send_to_rawdilluti0n2025-08-211-4/+1
|
* Move use derivativesdilluti0n2025-08-211-2/+5
|