diff --git a/README.md b/README.md index eafa184..f552d0e 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,144 @@ -# nsc (Network security control) -A kernel-space traffic routing engine featuring overlay network integration, Xray-core GeoDB compatibility, a network kill switch, and advanced policy-based routing. +# NSC -
+NSC (Network Security Control) is a Rust prototype for policy-based routing of +local IPv4 TCP and UDP traffic, with planned DNS and overlay proxy integration on +Linux. The routing contract is described in the +[v0.1 specification](doc/ROUTING_DEV.md) and its +[architecture overview](doc/HOW_WORKS_ROUTING.md). - - - +> **Project status:** NSC is not yet a usable traffic-routing or killswitch +> implementation. The current executable reads packets from a hard-coded TUN +> device and calls the packet-header parser. It does not install the specified +> OUTPUT → TC → TPROXY path, enforce routing policy, or relay application flows. - - - +## Current implementation - - - +| Area | Present in the repository | Status | +| --- | --- | --- | +| Packet handling | TUN read loop and raw packet-header parsing | Prototype sniffer only | +| Configuration | Basic TOML parsing for rules, proxies, and policy values | Not loaded by the running executable; full v0.1 validation is pending | +| Geodata | GeoIP2 MMDB and V2Ray geodata parsing components | Rule matching and routing integration are incomplete | +| FakeDNS | UDP/TCP DNS server and fake-address resolver components | Prototype; v0.1 DNS policy and publication contract is not implemented end to end | +| Interception and enforcement | No complete OUTPUT → TC → TPROXY backend or independent egress guard | Planned | +| Proxying and lifecycle | No integrated transparent relay, reload path, or boot-only service integration | Planned | - - - -
-
+The current executable must not be treated as a protected networking profile. +The component-level work does not yet provide an end-to-end routing guarantee. -**The current project spec**: [click](https://anthrill.namily.tech/how.html#nsc) +## Routing v0.1 configuration examples -**Routing documentation**: [Overview](doc/HOW_WORKS_ROUTING.md) · [Specification](doc/ROUTING_DEV.md) +These examples show the target configuration contract from +[specification §5](doc/ROUTING_DEV.md#5-configuration-contract). They are not +currently runnable profiles: the executable does not load a routing config, and +the parser does not yet support every field shown here. Replace +`192.0.2.53` with an IPv4 DNS resolver authorized for your host; it is a +documentation-only address. -Our resources: -- http://anthrill.i2p (about, docs, wiki) -- https://namily.tech (VPN, docs, wiki mirrors) -- https://git.namily.tech (forgejo, register-opened) +### REAL DNS by default -### Deprecated spec (expanded; this functionality will also be implemented) -The project is designed by the desire to transfer all the charms of routing and tun-in of modern VPN cores to Mesh networks. -Tun-in interface with marching on TOR/I2P similar to v2ray/xray +Ordinary DNS uses the configured upstream. No synthetic answers are requested. +```toml +[policy] +clearnet = "allowed" +dns_mode = "real" +[dns] +upstreams = ["udp://192.0.2.53:53"] +``` -## brief impl plan: -### client-side usage essentianls -1. [ ] TUN raw data (headers) parsing 50-70% done =) -2. [x] parse geoip2 (mmdb for now) thingies ( -3. [x] add v2ray protocols buffer support (geo{ip,site}.dat) -4. [ ] add full fakedns sniffer; 45-50% done -5. [ ] parse user's Config -6. [ ] impl routing logic based on client's Config -7. [ ] make this thing easy adn convenient to use -8. [ ] custom Tor/i2p profiles/Config presets (via proxies like 127.0.0.1:10808) +### Clearnet through a configured proxy -### inner infra -1. [ ] write as much tests as possible covering hopefully all logic -2. [ ] keep code readable and comprehensive -3. [ ] ideally review each others PRs after initial MVP stage -4. [ ] leave references/helpful comments on parts when code isn't obvious from the first glance +`allow-proxy` blocks direct clearnet access while permitting application traffic +through the configured proxy. The rule selects that proxy for clearnet names. + +```toml +[policy] +clearnet = "killswitched" +killswitch_mode = "allow-proxy" +dns_mode = "real" + +[dns] +upstreams = ["udp://192.0.2.53:53"] + +[[proxy]] +alias = "socks-exit" +url = "socks5://127.0.0.1:1080" + +[[rule]] +target = "clearnet" +action = "proxy" +proxy_name = "socks-exit" +``` + +### Full killswitch with FAKE DNS for `.i2p` + +Full mode blocks clearnet application destinations, including destinations that +would otherwise use a proxy. The `.i2p` rule explicitly selects FAKE DNS and the +configured i2pd SOCKS endpoint; other DNS remains REAL. + +```toml +[policy] +clearnet = "killswitched" +killswitch_mode = "full" +dns_mode = "real" + +[dns] +upstreams = ["udp://192.0.2.53:53"] + +[[proxy]] +alias = "i2pd" +url = "socks5://127.0.0.1:1080" # Use the SOCKS port configured in i2pd. + +[[rule]] +target = "suffix:i2p" +action = "proxy" +proxy_name = "i2pd" +dns_mode = "fake" +``` + +The examples follow the normative v0.1 defaults and constraints. In particular, +DNS mode is independent of transport action, overlay names are not sent to the +clearnet resolver, and a DNS answer alone does not authorize a connection. + +## Runtime and lifecycle contract + +The lifecycle below is specified for the future v0.1 runtime; it is not yet +implemented by the current executable: + +- Run one NSC process from system boot until reboot. The planned systemd unit uses + `Restart=no`. +- Apply configuration changes through SIGHUP. A successful reload keeps the + runtime identity and existing fake-address mappings; a failed reload leaves + the active policy unchanged. +- Do not stop or restart NSC during a live client session. Binary upgrades take + effect after the next system boot. +- After a crash, retain the independent firewall guard and recover by rebooting. + A reboot starts a new runtime epoch and clears in-memory fake-address mappings. + +See [specification §10](doc/ROUTING_DEV.md#10-lifecycle-publication-and-failure) +for the startup, readiness, reload, failure, and init requirements. + +## Backend and implementation work + +There is no published backend deployment descriptor yet. The +[descriptor contract](doc/ROUTING_DEV.md#112-deployment-descriptor) lists the +required kernel, hook, mark, route, listener, ABI, and resource-limit details; +implementation is tracked in [issue #8](https://git.namily.tech/Anthrill/NSC/issues/8). + +Related work: + +- [Complete the configuration schema](https://git.namily.tech/Anthrill/NSC/issues/1) + and [implement routing and killswitch decisions](https://git.namily.tech/Anthrill/NSC/issues/2). +- [Implement TC admission](https://git.namily.tech/Anthrill/NSC/issues/9) and the + [local OUTPUT → TC → TPROXY path](https://git.namily.tech/Anthrill/NSC/issues/10). +- Add [transparent listeners](https://git.namily.tech/Anthrill/NSC/issues/12), + [TCP relay](https://git.namily.tech/Anthrill/NSC/issues/13), + [UDP relay](https://git.namily.tech/Anthrill/NSC/issues/14), and + [HTTP proxy modes](https://git.namily.tech/Anthrill/NSC/issues/15). +- Integrate the [runtime startup path](https://git.namily.tech/Anthrill/NSC/issues/16), + [reload](https://git.namily.tech/Anthrill/NSC/issues/17), and + [boot-only packaging](https://git.namily.tech/Anthrill/NSC/issues/19). + +Browse [all open issues](https://git.namily.tech/Anthrill/NSC/issues) for the +current implementation plan.