144 lines
5.6 KiB
Markdown
144 lines
5.6 KiB
Markdown
# 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.
|
|
|
|
## Routing v0.1 configuration examples
|
|
|
|
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.
|
|
|
|
### REAL DNS by default
|
|
|
|
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"]
|
|
```
|
|
|
|
### Clearnet through a configured proxy
|
|
|
|
`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.
|