summaryrefslogtreecommitdiffhomepage
path: root/src/platform/windows.rs
Commit message (Collapse)AuthorAgeFilesLines
* windows: remove unneeded ip checksum calculationdilluti0n2026-03-021-1/+1
|
* log: add debug!/info!/warn!/error! macros and refactor to use itdilluti0n2026-03-021-17/+16
|
* windows: print log when recv failshskimse2026-03-021-2/+3
|
* windows: fix buffer size to 65536hskimse2026-03-011-1/+1
| | | | This size is for windivert buffer, not internal pkt buffer capacity.
* windows: simplify packet handling with recv_loop macrohskimse2026-03-011-59/+28
| | | | | | | | | Replace generic spawn_recv with recv_loop macro that encapsulates the buffer allocation and receive loop. Divert handle now runs directly on the main thread, while sniff handle spawns a dedicated thread only when fake_autottl is enabled. This eliminates the mpsc channel, Event enum, and the race condition where concurrent open_handle calls during driver initialization could cause error 1058.
* windows: remove RUNNING flag and trap_exithskimse2026-03-011-30/+6
| | | | | | Non-daemon mode exits via process::exit(0) on Ctrl-C, and daemon mode is managed by SCM, so the RUNNING atomic flag and graceful shutdown loop are both unnecessary. Remove them along with the ctrlc handler.
* windows: exit immediately on Ctrl-C in non-daemon modedilluti0n2026-03-011-1/+4
| | | | | | | | | | In non-daemon mode, WinDivert driver closes all handles on process exit, so explicit cleanup is unnecessary. Call std::process::exit(0) directly from the Ctrl-C handler instead of relying on RUNNING flag and graceful shutdown loop. Also move trap_exit() call before spawn_recv() to ensure the handler is registered before any threads are spawned.
* Move cleanup/trap_exit/RUNNING to platform modulesdilluti0n2026-03-011-26/+24
| | | | | | | | - 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
* windows: spawn syn/ack filter only when `--fake-autottl` is enableddilluti0n2026-02-271-4/+7
|
* windows: add close WinDivert handles on thread exitdilluti0n2026-02-271-19/+21
| | | | | | Move handle lifecycle into spawn_recv so each handle is properly closed when RUNNING becomes false. Filter and flags are passed in instead of a pre-opened handle.
* windows: refactor thread spawnings to spawn_recv helperdilluti0n2026-02-271-29/+28
|
* windows: split WinDivert into separate recv/send/sniff handlesdilluti0n2026-02-271-40/+74
| | | | | | windows: add cleanup for SEND_HANDLE windows: fix every packet goes to send-only handle
* Refactor send_to_raw to remove in-place packet reparsingdilluti0n2026-02-261-1/+5
| | | | | | Pass destination address from PktView::daddr() at call site instead of re-extracting it from raw bytes inside send_to_raw. Windows side ignores the argument. Also add #[inline] to PktView accessor methods.
* windows: nit: swap service_run/service_run_1 naming conventiondilluti0n2026-02-261-4/+4
|
* windows: fix regression intorduced in b68753e8dilluti0n2026-02-161-5/+2
|
* windows: fix nit build failurev0.4.2dilluti0n2026-02-161-3/+3
|
* opt: decouple set_opt() from loggingdilluti0n2026-02-161-3/+7
| | | | | | | | | | | | | | | | | | | | | | 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()
* 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-151-0/+4
| | | | | 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.
* windows: do not recalculate tcp checksum when send_to_rawdilluti0n2026-01-161-3/+3
| | | | For --fake-badsum work; Anyway, it is already calculated
* Prevent infinite loop on packet injection/filteringdilluti0n2025-12-301-1/+3
| | | | | - linux: fix infinite NFQUEUE loop by marking injected packets - windows: by marking packet to impostor
* 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
|
* Refactor handle_packet to reuse external buffer for packet handlingdilluti0n2025-09-111-2/+5
| | | | This removes unnecessary allocations per packet handling.
* log: add splash! macro and centralize no-splash handlingdilluti0n2025-09-071-2/+4
| | | | | | | | | | | | | * 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
|
* Add license document and copyright notice headersdilluti0n2025-09-051-0/+17
|
* Tidy up LogLevel enum definitiondilluti0n2025-09-031-2/+2
| | | | | | * 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-031-1/+2
|
* Add prefix [INFO] or [WARNNING] on log messagesdilluti0n2025-08-311-1/+1
|
* 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.
* Decouple once_cell by replacing it with standard libDilluti0n2025-08-231-3/+2
|
* Simplify signal handling with global AtomicBoolDilluti0n2025-08-231-6/+4
| | | | | | | * 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 platform dependant main loops to platform::runhskim2025-08-221-0/+21
|
* refactor: add error propagation to send_to_rawdilluti0n2025-08-061-2/+4
| | | | | | | * Extracted: `handle_packet!` macro to deduplicate match logic in both Linux and Windows backend. * Changed: `send_to_raw()` to return Result and propagate errors with `anyhow!`.
* refactor: Unified all error types in the project to anyhow::Errordilluti0n2025-08-061-3/+3
| | | | | | | | Configured incompatible iptables errors to be propagated using map_err into the anyhow type * refactored: split_packet and handle_packet to return Result<> instead of Option<>
* minor: remove handle_msg rapperdilluti0n2025-08-061-4/+5
| | | | | | | modify to have a simmilar flow with windows build * change ordering * debug messages
* minor: move platform-specific codes to seperate filesdilluti0n2025-08-061-0/+38