impl(docs): routing protocol v0.1 spec
This commit is contained in:
parent
07f9ceb12f
commit
5696cea817
2 changed files with 717 additions and 8 deletions
|
|
@ -1,12 +1,40 @@
|
|||
# Basic NSC routing principles
|
||||
# NSC Routing Overview
|
||||
|
||||
NSC implements its own DNS server, which resolves domains according to the configured routing policies.
|
||||
NSC transparently routes local application traffic by domain/geosite, destination
|
||||
IP/geoip, and overlay namespace. The normative behavior is defined in the
|
||||
[NSC Routing Specification](ROUTING_DEV.md), including its
|
||||
[architecture diagram](ROUTING_DEV.md#22-architecture-diagram).
|
||||
|
||||
The current sniffing-based routing flow works as follows:
|
||||
The NSC DNS service is called FakeDNS, but its default mode is **REAL**: it returns
|
||||
answers from an authorized resolver without substituting synthetic addresses.
|
||||
Rules can explicitly select **FAKE** or **BLOCK** for matching names. This keeps
|
||||
ordinary DNS compatible with applications that reject synthetic answers.
|
||||
|
||||
* The user enters a domain in their browser, for example `http://reg.i2p`.
|
||||
* The NSC FakeDNS server responds with an address from the [RFC 2544](https://www.rfc-editor.org/info/rfc2544/) benchmarking address space (`198.18.0.0/15`) and stores the corresponding `domain:IP` mapping.
|
||||
* When the application attempts to connect to the assigned IP address, NSC intercepts the connection and looks up the original domain using the stored mapping.
|
||||
* NSC then establishes a connection to the appropriate overlay network proxy (mostly SOCKS) and forwards the intercepted traffic through it. Supported interception backends include TPROXY and eBPF.
|
||||
* Responses from the overlay network are forwarded back to the original application as if it were communicating directly with the resolved address.
|
||||
With a `.i2p -> FAKE + i2pd` routing rule, opening `http://example.i2p` works as follows:
|
||||
|
||||
1. The application sends an ordinary DNS query. FakeDNS recognizes the I2P namespace,
|
||||
allocates an address from `198.18.0.0/15`, and records the original domain.
|
||||
2. Before replying, FakeDNS publishes the mapping, I2P classification, and route
|
||||
hint to kernel-visible BPF maps. No SOCKS CONNECT is sent at DNS time.
|
||||
3. The application connects to the fake address and destination port. OUTPUT policy
|
||||
routing, TC ingress, and TPROXY deliver the flow to an NSC transparent listener.
|
||||
4. The daemon recovers `example.i2p`, checks the current policy and killswitch, and
|
||||
sends SOCKS5 CONNECT with the original domain and actual destination port.
|
||||
5. After proxy success, the daemon relays bytes in both directions. UDP uses a
|
||||
separate SOCKS5 UDP ASSOCIATE lifecycle. HTTP proxies use an explicit CONNECT
|
||||
or cleartext HTTP forward mode.
|
||||
|
||||
TC performs compact packet and flow checks; complex domain/geodata policy remains
|
||||
in userspace. TPROXY supplies local delivery, while the base payload relay runs
|
||||
in userspace. Kernel payload relay is an optional extension.
|
||||
|
||||
When the killswitch is enabled, **full** permits only overlay application
|
||||
destinations; **allow-proxy** additionally permits clearnet through proxies
|
||||
configured in NSC. Narrow trusted service exceptions cover required proxy/overlay
|
||||
transports and explicitly configured DNS upstreams, including in full mode.
|
||||
Overlay names are never sent to a public DNS upstream. A direct application
|
||||
exception must be explicit in a routing rule.
|
||||
|
||||
Mappings survive SIGHUP reloads. The supported lifecycle is one daemon process
|
||||
from system boot until reboot, with no live-session restart. After reboot the
|
||||
in-memory journal is discarded and allocation starts from scratch.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue