Overview of HRNeo v3.17.0-1
mainHRNeo (v3.17.0-1) is a compact, single-threaded policy routing daemon written in pure C, specifically designed for Keenetic routers. It functions by intercepting hostnames and routing traffic based on identified IP addresses.
Core Functionality
HRNeo uses two primary channels to identify hostnames:
- DNS Channel: Intercepts DNS responses using
AF_PACKET SOCK_DGRAMcombined withL3-BPFfilters in the kernel. This allows it to work across various interface types (Ethernet, PPP, tunnels, etc.) to capture DNS traffic from LAN and VPN clients. - L7 Channel: When
l7CaptureEnabledis active, it uses a custom NFLOG client via raw netlink to perform passive copying of outgoing connections. It identifies hosts via TLS SNI, HTTP Host, or QUIC Initial SNI. For fragmented packets, it performs TCP reassembly or QUIC CRYPTO-walking (including HKDF + AES-128-CTR decryption) to extract host information.
Routing Mechanism
Once an IP address is extracted, HRNeo:
- Adds the IP to an
ipsetvia netlink. - Marks traffic in
iptables/manglefor policy routing. - Supports routing via Keenetic policies (using marks via the RCI API) or direct interface routing (
fwmark+ip rule+ip route). - Supports GeoIP/GeoSite data in
.dat(v2ray/xray) format using streaming protobuf parsing.