summaryrefslogtreecommitdiffhomepage
path: root/src/platform
Commit message (Collapse)AuthorAgeFilesLines
* windows: fix nit build failurev0.4.2dilluti0n2026-02-161-3/+3
|
* linux: add TODO on daemonizedilluti0n2026-02-161-0/+1
|
* opt: decouple set_opt() from loggingdilluti0n2026-02-162-7/+12
| | | | | | | | | | | | | | | | | | | | | | 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: fix log file truncated when daemonize failsdilluti0n2026-02-161-3/+7
| | | | | | | | | 1. open without O_APPEND (offset = 0) and O_TRUNC (original bug) 2. dup file descripter with .try_clone() and feed it to daemonize 3. truncate file with .set_len(0) on child after daemonize.start() succed Fixes: https://github.com/dilluti0n/dpibreak/issues/17
* linux: exit if not rootdilluti0n2026-02-161-1/+9
|
* linux: repurpose bootstrap to do things before requiring cleanupdilluti0n2026-02-161-4/+10
|
* linux: modify PID_FILE and log pathdilluti0n2026-02-161-2/+3
| | | | Fixes: https://github.com/dilluti0n/dpibreak/issues/16
* linux: add PID file locking for single instance enforcementdilluti0n2026-02-151-6/+24
| | | | | Prevent multiple non-daemon dpibreak instances using flock(). Show existing PID on conflict and maintain lock until process termination.
* linux: extract PID_FILE constant for reusedilluti0n2026-02-151-3/+3
|
* Consolidate setup logic into run()dilluti0n2026-02-151-2/+7
| | | | | | | | | | | 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/+2
|
* windows: implement windows servicedilluti0n2026-02-151-3/+42
| | | | | | | | | Revert lock_handle() send_to_raw cannot get a mutex since lock is not released per iteration. commit e08b57d281d8368dc02f06e3b6cd43edf88b2438
* linux: implement daemonizedilluti0n2026-02-152-0/+40
| | | | | Closes: #2 Link: https://github.com/dilluti0n/dpibreak/issues/2
* windows: extend WinDivert filter for --fake-autottldilluti0n2026-01-231-6/+18
| | | | | | | Build WinDivert filter at runtime: - Default: outbound TLS ClientHello packets - --fake-autottl: also capture inbound SYN/ACK from tcp sport 443 Keep !impostor to avoid recapture.
* linux: iptables: implement SYN/ACK capture on --fake-autottldilluti0n2026-01-231-0/+19
| | | | | | - Add mangle/INPUT jump to DPIBREAK - Queue tcp sport 443 SYN/ACK packets (NFQUEUE --queue-bypass) - Cleanup removes INPUT jump as well
* linux: nftables: queue SYN/ACK on --fake-autottldilluti0n2026-01-231-0/+59
| | | | - simplify nftables rules by removing DPIBREAK chain
* linux: refactor rules backend into iptables/nftables modulesdilluti0n2026-01-233-301/+310
| | | | | | | Split iptables and nftables rule management into dedicated modules. Keep linux.rs focused on shared helpers and rule dispatch. (cherry picked from commit 60c0011ca0cf5a463056fca17f2f747e762e19f9)
* linux: drop iptables crate (regex dep) to reduce binary sizedilluti0n2026-01-181-23/+75
| | | | Introduce minimal iptables wrapper.
* Refactor main.rs; modulize opt.rs and pkt.rsdilluti0n2026-01-161-20/+9
| | | | | Move option parsing to opt.rs and packet handling to pkt.rs from main.rs
* windows: do not recalculate tcp checksum when send_to_rawdilluti0n2026-01-161-3/+3
| | | | For --fake-badsum work; Anyway, it is already calculated
* Normalize option handling and OPT_* namingdilluti0n2025-12-301-4/+4
| | | | Log runtime options on startup
* Prevent infinite loop on packet injection/filteringdilluti0n2025-12-302-5/+42
| | | | | - linux: fix infinite NFQUEUE loop by marking injected packets - windows: by marking packet to impostor
* linux: extract process execution into `exec_process` helperdilluti0n2025-12-291-17/+29
| | | | | | | | Introduce exec_process() to handle external command execution, stdin piping, and error reporting. Now cleanup() and apply_nft_rules() call exec_process() to call modprobe, nft respectively. This improves error handling for cleanup xt_u32.
* linux: ignore cleanup errors at startupdilluti0n2025-12-221-7/+3
| | | | | Do not log errors if cleanup fails during startup. Retain error logging for cleanup failures on shutdown.
* linux: switch to apply_nft_rules() from nftables-rs for rule settingdilluti0n2025-10-291-18/+13
| | | | | nftables-rs didn’t fit use case, so it was decoupled, and logging was improved.
* linux: implement apply_nft_rules() to log output sanelydilluti0n2025-10-291-0/+30
|
* linux: add option `--nft-command`dilluti0n2025-10-291-7/+11
|
* windows: avoid ERR_INVALID_NAME when uninstalling WinDivertdilluti0n2025-10-061-2/+9
| | | | | | | `CloseAction::Uninstall` triggers ERROR_INVALID_NAME (0x8007007B) on Windows, likely due to the crate passing a non–NUL-terminated "WinDivert" string to `OpenServiceA`. For now, skip uninstallation and just close the handle normally. Added a FIXME comment with details.
* platform: windows: close handle and uninstall driver sanelydilluti0n2025-10-061-9/+19
|
* platform: windows: only divert clienthello packet to userspacedilluti0n2025-10-031-1/+3
|
* platform: linux: filter only TLS ClientHello packets on nftablesdilluti0n2025-10-031-0/+21
| | | | | | | | Add additional nftables match expressions to detect TLS records (ContentType 0x16 = Handshake): and specifically ClientHello (HandshakeType 0x01):. Packets matching this pattern are queued to NFQUEUE. Mark xt_u32 as supported when nftables filtering is successfully applied.
* platform: linux: add nftables support with iptables fallbackdilluti0n2025-10-031-11/+112
| | | | | | | | | | Introduce nftables rules under a dedicated "dpibreak" table and chain. Traffic on TCP port 443 is queued using NFQUEUE. If nftables is not supported, fall back to the existing iptables-based rules for both IPv4 and IPv6. Also update cleanup logic to remove nftables table if used, or iptables rules otherwise.
* platform: linux: split iptables helpers on bootstrap/cleanupdilluti0n2025-09-271-14/+25
|
* Refactor handle_packet to reuse external buffer for packet handlingdilluti0n2025-09-112-2/+9
| | | | This removes unnecessary allocations per packet handling.
* log: add splash! macro and centralize no-splash handlingdilluti0n2025-09-072-3/+7
| | | | | | | | | | | | | * 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-052-2/+2
|
* Add license document and copyright notice headersdilluti0n2025-09-052-0/+34
|
* Tidy up LogLevel enum definitiondilluti0n2025-09-032-12/+12
| | | | | | * Remove: unused `Fatal` variant from `LogLevel`. * Update: comment on `Error` to indicate it represents unrecoverable errors.
* Refactor prefixed logs to using log.rs, leaving Errors untoucheddilluti0n2025-09-032-10/+12
|
* Add prefix [INFO] or [WARNNING] on log messagesdilluti0n2025-08-312-10/+10
|
* platform: windows: log WinDivert handle creationdilluti0n2025-08-311-5/+7
| | | | | | Define the TCP:443 outbound filter as a constant and reuse it in WinDivert::network. Add a log message when the handle is successfully constructed for better visibility during runtime.
* platform: linux: add verbose messages on bootstrapdilluti0n2025-08-311-3/+19
|
* platform: linux: unhardcode chain name DPIBREAKdilluti0n2025-08-311-7/+11
|
* Decouple once_cell by replacing it with standard libDilluti0n2025-08-231-3/+2
|
* platform: linux: decouple once_cellDilluti0n2025-08-231-6/+3
| | | | * Replace once_cell::Lazy with plain AtomicBool
* platform: linux: use standard library instead of once_cell on socketDilluti0n2025-08-231-3/+4
|
* platform: linux: make iptables helpers privateDilluti0n2025-08-231-5/+5
|
* Simplify signal handling with global AtomicBoolDilluti0n2025-08-232-9/+8
| | | | | | | * 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.
* Add command-line argument parsing and switch config to OnceLockhskim2025-08-231-4/+9
| | | | | | | | | | | 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.
* Wrap platform dependant main loops to platform::runhskim2025-08-222-0/+74
|