| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |
|
|
|
|
|
|
| |
- 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
|
| |
|
|
|
|
|
| |
Conditionally initialize rxring only when fake_autottl is enabled.
Extract poll_once() using libc::poll directly; fd=-1 trick eliminates
the need for conditional branching on optional rxring fd, as poll sets
revents=0 for negative fds per POSIX. Drop nix poll feature.
|
| |
|
|
|
|
|
|
| |
Extract nfqueue initialization (open, bind, set O_NONBLOCK) and rxring
initialization (cBPF filter, open) into separate functions. Inline
BorrowedFd scope as a let binding to eliminate floating
q_ready/rx_ready declarations. Move SYNACK_443_CBPF const into
open_rxring.
|
| |
|
|
|
|
|
|
| |
- Split next_packet into current_packet (read) and advance (release)
to avoid TOCTOU between kernel overwrite and packet processing
- Add current_frame helper to avoid duplicated pointer arithmetic
- Switch AF_PACKET socket to ETH_P_ALL for future IPv6 support
- Add FRAME_SIZE comment explaining 128B is sufficient for IP header
|
| | |
|
| |
|
|
|
|
|
| |
- Add rxring module with RxRing struct (new/next_packet unimplemented)
- Attach cBPF filter for TCP src port 443 SYN/ACK packets
- Multiplex nfqueue and rxring via poll in run loop
- Move fake_autottl SYN/ACK handling to pkt::put_hop
|
| | |
|
| |
|
|
|
|
| |
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.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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()
|
| |
|
|
|
|
|
|
|
| |
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
|
| | |
|
| | |
|
| |
|
|
| |
Fixes: https://github.com/dilluti0n/dpibreak/issues/16
|
| |
|
|
|
| |
Prevent multiple non-daemon dpibreak instances using flock(). Show
existing PID on conflict and maintain lock until process termination.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
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)
|
| |
|
|
|
| |
Closes: #2
Link: https://github.com/dilluti0n/dpibreak/issues/2
|
| |
|
|
|
|
|
| |
Split iptables and nftables rule management into dedicated modules.
Keep linux.rs focused on shared helpers and rule dispatch.
(cherry picked from commit 60c0011ca0cf5a463056fca17f2f747e762e19f9)
|
| |
|
|
| |
Introduce minimal iptables wrapper.
|
| |
|
|
|
| |
Move option parsing to opt.rs and packet handling to pkt.rs from
main.rs
|
| |
|
|
| |
Log runtime options on startup
|
| |
|
|
|
| |
- linux: fix infinite NFQUEUE loop by marking injected packets
- windows: by marking packet to impostor
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
Do not log errors if cleanup fails during startup.
Retain error logging for cleanup failures on shutdown.
|
| |
|
|
|
| |
nftables-rs didn’t fit use case, so it was decoupled, and logging was
improved.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
| |
This removes unnecessary allocations per packet handling.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* 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`.
|
| | |
|
| | |
|
| |
|
|
|
|
| |
* Remove: unused `Fatal` variant from `LogLevel`.
* Update: comment on `Error` to indicate it represents unrecoverable
errors.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
* Replace once_cell::Lazy with plain AtomicBool
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
| |
It was none readable before.. like (Err: No such file)
|
| |
|
|
|
|
|
| |
* 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!`.
|