How ghaziwali/hulios works
Purpose and entry points
Hulios is a Linux-only, eBPF-powered transparent Tor gateway. It redirects outbound TCP and DNS through embedded Arti Tor and a local Hickory resolver while enforcing leak-resistant routing at kernel boundaries. The workspace root is Cargo.toml; the primary executable is hulios/src/main.rs, with build-time eBPF integration in hulios/build.rs. Operational commands include start, stop, status, diagnose, and recovery.
Supervisor, configuration, and privilege boundary
The privileged supervisor initializes configuration, validates required privileges, manages lifecycle signals, installs kernel controls, and spawns the restricted worker process. It is the boundary between host-root operations and the unprivileged runtime.
• hulios/src/main.rs
• hulios/src/config.rs
• hulios/src/privileges.rs
• hulios/src/signals.rs
Persistent state and lifecycle orchestration
hulios-state owns the durable model of whether Hulios is active, snapshots preexisting system state, executes lifecycle transitions, and supports recovery after crashes. Start establishes protection before service operation; stop restores captured state; recover handles unclean or interrupted runs. Diagnostics, watchdog, time synchronization, and status expose and validate operational health.
• hulios-state/src/operations/start.rs
• hulios-state/src/operations/stop.rs
• hulios-state/src/operations/recover.rs
• hulios-state/src/snapshot.rs
• hulios-state/src/watchdog.rs
Kernel enforcement and routing boundary
The eBPF subsystem provides the non-bypassable traffic boundary: cgroup socket hooks steer traffic, DNS filtering handles query interception, socket marks support policy routing, and an LSM-oriented AF_PACKET blocker prevents raw packet socket bypasses. The privileged process loads these programs; policy routing and blackhole defaults remain fail-secure if the daemon dies.
• hulios-ebpf/src/main.rs
• hulios-ebpf/src/dns_filter.rs
• hulios-ebpf/src/sock_mark.rs
• hulios-ebpf/src/af_packet_block.rs
• hulios/src/ebpf.rs
DNS interception and resolver path
DNS traffic is detected and redirected to a localized resolver rather than relying on runtime resolv.conf changes. The DNS crate contains resolver behavior plus rebinding protections, making DNS a dedicated security boundary alongside TCP interception.
• hulios-dns/src/resolver.rs
• hulios-dns/src/detect.rs
• hulios-dns/src/rebinding.rs
Tor transport and worker-facing network services
The onion networking layer hosts the local SOCKS-facing path over embedded Arti. Isolation controls separate Tor stream behavior, while MSS handling adapts tunneled traffic. This layer receives traffic after kernel interception and provides the outbound Tor transport rather than delegating to an external Tor daemon.
• hulios-onionmasq/src/lib.rs
• hulios-onionmasq/src/socks.rs
• hulios-onionmasq/src/isolation.rs
• hulios-onionmasq/src/mss.rs
Host integration and runtime dependencies
Hulios targets Linux kernel 5.10+ with BPF syscall, BPF LSM, and cgroups v2 support; eBPF compilation requires clang/libelf and is wired through hulios-ebpf/build.rs. Network compatibility code integrates with systemd, NetworkManager, and IWD and detects conflicts. Tunnel and sysctl functionality support host network setup.
• hulios-netcompat/src/systemd.rs
• hulios-netcompat/src/network_manager.rs
• hulios-netcompat/src/iwd.rs
• hulios-tun/src/lib.rs
• packaging/hulios.service
Main entry points: src/main.rs Hulios supervisor · start.rs Start / stop / recover · src/main.rs eBPF programs · resolver.rs Local DNS resolver
Components 22
Privileged Supervisor
Host-root control plane.
- Hulios supervisor · Validates host readiness and manages the restricted worker.
hulios/src/main.rs - Configuration
hulios/src/config.rs - Privilege checks
hulios/src/privileges.rs - Lifecycle signals
hulios/src/signals.rs - eBPF loader · Loads kernel programs from the privileged boundary.
hulios/src/ebpf.rs
Lifecycle State
Durable activation and recovery.
- Start / stop / recover · Establishes protection before service operation and restores host state.
hulios-state/src/operations/start.rs - System snapshot · Captures preexisting host state for restoration.
hulios-state/src/snapshot.rs - Watchdog and status
hulios-state/src/watchdog.rs
Kernel Enforcement
Fail-secure traffic boundary.
- eBPF programs · Cgroup hooks, DNS interception, socket marks, and AF_PACKET blocking.
hulios-ebpf/src/main.rs - DNS filter
hulios-ebpf/src/dns_filter.rs - Socket marking · Marks sockets for policy routing.
hulios-ebpf/src/sock_mark.rs - AF_PACKET blocker · Prevents raw packet socket bypasses.
hulios-ebpf/src/af_packet_block.rs - Fail-secure policy routing · Blackhole defaults remain active if the daemon fails.
Restricted Network Worker
Local DNS and Tor services.
- Local DNS resolver · Applies DNS detection and rebinding protections.
hulios-dns/src/resolver.rs - DNS detection
hulios-dns/src/detect.rs - Rebinding protection
hulios-dns/src/rebinding.rs - Embedded Arti transport · Provides local SOCKS-facing outbound Tor transport.
hulios-onionmasq/src/lib.rs - SOCKS ingress
hulios-onionmasq/src/socks.rs - Stream isolation
hulios-onionmasq/src/isolation.rs
Host Integration
Linux and network-manager integration.
- Network compatibility · Coordinates systemd, NetworkManager, and IWD.
hulios-netcompat/src/systemd.rs - Tunnel setup
hulios-tun/src/lib.rs - systemd service
packaging/hulios.service
Connections 22
- Hulios supervisor → Configuration: loads
- Hulios supervisor → Privilege checks: validates
- Hulios supervisor → Lifecycle signals: handles
- Hulios supervisor → Start / stop / recover: orchestrates
- Start / stop / recover → System snapshot: captures / restores
- Start / stop / recover → Watchdog and status: reports health
- Hulios supervisor → eBPF loader: loads via
- eBPF loader → eBPF programs: attaches
- eBPF programs → DNS filter: includes
- eBPF programs → Socket marking: includes
- eBPF programs → AF_PACKET blocker: includes
- Socket marking → Fail-secure policy routing: drives
- Start / stop / recover → Fail-secure policy routing: installs
- DNS filter → Local DNS resolver: redirects DNS to
- Local DNS resolver → DNS detection: uses
- Local DNS resolver → Rebinding protection: enforces
- Fail-secure policy routing → SOCKS ingress: steers TCP to
- SOCKS ingress → Embedded Arti transport: forwards to
- Embedded Arti transport → Stream isolation: applies
- Hulios supervisor → Network compatibility: coordinates
- Start / stop / recover → Tunnel setup: configures
- systemd service → Hulios supervisor: starts