High-performance routing decision engine for DNS/IP-based rule matching.
Unix daemon that performs fast domain and IP lookups against routing rules. Accepts IPC requests via JSON over Unix socket.
- O(N) suffix domain matching (single-pass trie traversal)
- IPv4 CIDR matching
- 95% memory efficient (optimized Patricia trie)
- Atomic hot-reload of rules
- JSON IPC protocol
make
./build/xoptimizer -s /tmp/xoptimizer.sockTest connection:
echo '{"type":"ping"}' | socat - UNIX-CONNECT:/tmp/xoptimizer.sock
echo '{"type":"lookup","domain":"example.com"}' | socat - UNIX-CONNECT:/tmp/xoptimizer.sockOne entry per line:
example.com
1.2.3.0/24
PROXY: test.org
DIRECT: local.example
Lines starting with # are ignored.
JSON over Unix socket.
PING - Check service availability:
{"type":"ping"}Response: {"pong": true, "code": 0}
{"type":"lookup","domain":"example.com"}Response: {"action": "DIRECT", "code": 0}
{"type":"stats"}Response: {"domain_count": 100, "cidr_count": 50, "code": 0}
{"type":"reload"}make
sudo make install
sudo systemctl start xoptimizerSOCKET_PATH: Unix socket location (default:/run/xoptimizer/ipc.sock)RULES_FILE: Path to rules file (default:/etc/xoptimizer/rules.txt)ARENA_SIZE: Memory pool size (default: 32MB)
Edit include/optimizer.h to change defaults and recompile.
- Memory: ~56 bytes per trie node (vs 2080 with standard array-based approach)
- Lookup: O(N) single-pass traversal
- Startup: <100ms for 100K rules sudo systemctl daemon-reload sudo systemctl enable --now xoptimizer-rules-update.timer sudo systemctl status xoptimizer-rules-update.timer
## Service mode
A baseline `systemd` unit is provided in this repo:
- `xoptimizer.service`
For production, keep environment-specific overrides in your private infra repo.
### Minimal systemd setup
```bash
sudo cp xoptimizer.service /etc/systemd/system/xoptimizer.service
sudo systemctl daemon-reload
sudo systemctl enable --now xoptimizer
sudo systemctl status xoptimizer
Stable core daemon with hot-reloadable rules and an external updater.