summaryrefslogtreecommitdiffhomepage
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* windows: use paexit instead std::process::exitdilluti0n2026-07-132-7/+9
| | | | See error message
* windows: fix nit build failuredilluti0n2026-07-132-3/+3
|
* linux: rxring: fix lifetime issue for Pkt::net()dilluti0n2026-07-101-2/+2
| | | | Result should be unusable after Pkt is dropped, not rx is dropped.
* linux: rxring: fix tp_snaplen treated as the L3 length instead L2dilluti0n2026-07-102-14/+56
| | | | | | | | | While solving it, introduced Pkt abstraction so that advance() is automatically executed upon dropping it. This change still allows access to mmapped pointers within the Pkt.net() and enables the addition of other slice fields (such as mac) later.
* linux: rxring: guard div0 as EINVALdilluti0n2026-07-091-0/+3
|
* linux: rxring: fix u32 overflow on ring_size initdilluti0n2026-07-091-1/+1
|
* linux: rxring: fix possable memory ordering issuedilluti0n2026-07-091-15/+25
|
* linux: nit: move const inside to functiondilluti0n2026-07-091-2/+2
|
* linux: rules: abort if any rule is failed to installdilluti0n2026-07-081-5/+10
|
* linux: move firewall rule handling to mod ruledilluti0n2026-07-086-218/+211
|
* linux: fix iptables not cleanup on startupdilluti0n2026-07-082-31/+65
| | | | | | | | | cleanup_rules() relies on the global flag IS_NFT_NOT_SUPPORTED, which is always False before install_rule is called. Fixed it to always attempt cleanup for ipt/ip6/nft at startup. At the same time, implement Drop so that firewall cleanup occurs when dies due to ?.
* Use paexit on shutdowndilluti0n2026-07-081-1/+1
| | | | This makes windows users able to see the error message.
* Move platform-dependant codes to mod platformdilluti0n2026-07-085-46/+43
|
* opt: nit refinedilluti0n2026-07-081-14/+14
|
* linux: use syscall! macro on open_signalfd()dilluti0n2026-07-071-9/+5
| | | | | | It would be better if libc_s did not provide signalfd. The open_signalfd() function itself has issues, such as sigprocmask being applied elsewhere before opening it.
* Merge branch 'linux-cleanup'dilluti0n2026-07-073-104/+159
|\ | | | | | | | | Drop nix and add libc_s wrappers (with nix::fcntl like setsockopt abstraction).
| * linux: do not panic when failed to set IPV6_HDRINCLdilluti0n2026-07-071-1/+4
| | | | | | | | | | This is likely new feature in kernel. (mayby 5.6 or something near there)
| * linux: rxring: make tp_* series configurabledilluti0n2026-07-072-19/+23
| |
| * linux: implement socket and mmap wrapper for rxringdilluti0n2026-07-072-32/+39
| | | | | | | | | | | | | | Here mmap/munmap wrapper remain unsafe since mmap returns a pointer causes a memory leak when munmap is not called while dropping, and munmap has strict rule (PAGE_SIZE aligned) for addr defined on munmap(2).
| * linux: libc_s: add syscall! macro to reduce redundant error handlingdilluti0n2026-07-061-29/+15
| |
| * linux: add PACKET_RX_RING to libc_s::setsockopt apstractiondilluti0n2026-07-062-30/+27
| | | | | | | | | | | | | | | | | | The existing implementation was unsafe because UB could occur if a user-space pointer referenced by the struct sock_fprog was incorrectly passed. Rust safe model allows pointer creation and makes dereferencing unsafe. In this case, dereferencing happenes in kernel-space, Rust cannot guarantee this. So it must be handled separately.
| * linux: add safe abstraction for setsockopt(SO_ATTACH_FILTER)dilluti0n2026-07-062-12/+32
| | | | | | | | | | | | Treating optval as just a &[u8] in setsockopt() is not appropriate for usage patterns where a struct is put into optval. Rust treats casting a struct to &[u8] as unsafe.
| * linux: move poll_s() to mod libc_sdilluti0n2026-07-062-13/+11
| |
| * nit: remove unused crate::dilluti0n2026-07-061-2/+2
| |
| * nit: move use libc::sock_filter to inside open_rxring()dilluti0n2026-07-061-4/+2
| |
| * linux: drop nix, add wrapper libc_s insteaddilluti0n2026-07-062-8/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | When I updated nix to 0.31, `nix::fcntl::flock` became deprecated and unusable. At first I try to refactor `lock_pid_file()` to use the `lock` method of the `nix::fcntl::Flock` struct, but a situation arose where `set_len(0)` could not be called due to ownership issues. Linux system calls are fundamentally simple, stable, and backward compatible. Therefore, a compat layer is not necessary. Anticipating that this might happen again, this commit introduce the `libc_s`, which handles simple error processing for unsafe ffis in libc syscall bindings.
* | pkt: fix infer_hops againdilluti0n2026-06-291-1/+1
| |
* | opt: fix help messagesdilluti0n2026-06-291-15/+14
|/
* linux: inline poll_once and lift fds init outside the loopdilluti0n2026-06-291-41/+31
| | | | | | Keeping poll_once() separate just caused more headaches. It was also rebuilding the fds array every single time. Since poll() only overwrites revents, doing that on every loop was totally unnecessary.
* linux: drop ctrlc crate and use signalfd insteaddilluti0n2026-06-291-24/+44
| | | | | | This integrates well with the main poll loop and removes the global AtomicBool RUNNING, which previously did nothing but detect interrupts before entering the loop.
* windows: wait for keypress before exit on --helpdilluti0n2026-04-161-1/+16
| | | | | | UAC elevation spawns a new console that closes when the process exits, cutting off --help output and error messages. Add a pause on Windows-only exit paths via _getch().
* linux: drain rxring before nfqueue in poll loopdilluti0n2026-04-081-7/+7
| | | | | | | | When both fds are ready in the same wakeup, the SYN/ACK that triggered rx_ready is causally prior to the ClientHello waiting in the nfqueue. Process the rxring first so HopTab is populated before handle_packet runs find_hop, reducing the race window for HopLookupError::NotFound under load.
* opt: fix -D deprecation warning conditiondilluti0n2026-04-051-1/+1
| | | | | Previously checked `argv == "--loglevel"` by mistake, copied from the --loglevel deprecation pattern. Now correctly checks `argv == "-D"`.
* Add shopt -t, -a for --fake-ttl, --fake-autottl, respectivelydilluti0n2026-04-052-8/+8
|
* Add short option -d for --daemon, deprecating -D.dilluti0n2026-04-051-3/+9
|
* opt: add shopt for --segment-order and descriptiondilluti0n2026-04-051-2/+3
|
* pkt: implement segment-order aware send_splitdilluti0n2026-04-052-28/+43
| | | | | | Replace hardcoded [0,1] split with send_split accepting &[Segment]. Segments exceeding payload length are warned and skipped. Add Segment type to opt.rs with Display/Debug showing [start,end) notation.
* opt: implement SegmentOrder::new and Displaydilluti0n2026-04-051-4/+49
| | | | | | Parse comma-separated split points into sorted segment ranges as (start, end): pairs. Display shows original input with computed ranges, e.g. "5,1,0,3 ([5,end), [1,3), [0,1), [3,5))".
* opt: add SegmentOrder type and --segment-order optiondilluti0n2026-04-051-13/+47
| | | | | | | SegmentOrder parses a comma-separated list of u32 split points, sorts them, and precomputes segment ranges as (start, end) pairs for use in send_split. The original input string is retained for Display. Parsing logic is unimplemented and will follow in the next commit.
* linux: rxring: nit: add SPDX headerdilluti0n2026-03-151-0/+3
|
* linux: add IPv6 SYN/ACK BPF filter and increase rxring frame sizedilluti0n2026-03-062-20/+25
| | | | | | | | | | | | | | Previous BPF filter only matched IPv4 due to tcpdump failing to generate a correct combined IPv4/IPv6 filter. Replaced with manually split filter that handles both ip and ip6 paths. Also increase FRAME_SIZE from 128 to 256 to resolve this error: [WARNING] put_hop: IPv6 Packet Error: Not enough data to decode 'IPv6 packet'. 80 byte(s) would be required, but only 62 byte(s) are available based on the slice length. tpacket_hdr(~66) + eth(14) + ipv6(40) + tcp+options(60) = ~180 bytes, which exceeded the previous 128-byte limit.
* linux: iptables: nit: fix compiler warningdilluti0n2026-03-021-1/+0
|
* linux: iptables: fix SYN/ACK rules installed on iptablesdilluti0n2026-03-021-19/+0
|
* windows: remove unneeded ip checksum calculationdilluti0n2026-03-021-1/+1
|
* log: add debug!/info!/warn!/error! macros and refactor to use itdilluti0n2026-03-0210-92/+93
|
* log: add short form log macroshskimse2026-03-021-0/+5
|
* 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.