agentleFS
shadowsocksshadowsocks/shadowsocks-rust/.cursor/rules/shadowsocks-rust-orientation.mdc

shadowsocks-rust / rules

Cursor rule11k starsChanged 8 months agoMITView on GitHub

shadowsocks-rust workspace orientation (binaries, crates, features, hot paths)

Trending

More talk lately.about the whole repository

Dec 2025: 5 mentionsJan 2026: 1 mentionFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 5 mentionsSep 2026: 10 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the shadowsocks/shadowsocks-rust repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about shadowsocks/shadowsocks-rust

The biggest 5 of 64 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 64

Talked about on GitHub, Bluesky, YouTube and Hacker News (64 times).

On GitHub · 50

45 more on GitHub

On Bluesky · 12

7 more on Bluesky

On YouTube · 1

On Hacker News · 1

The file

Files
shadowsocks-rust-orientation.mdc
---
description: shadowsocks-rust workspace orientation (binaries, crates, features, hot paths)
alwaysApply: true
---

# shadowsocks-rust orientation

## Toolchain

- **Edition**: 2024. **MSRV**: `1.91` (root + both crates; `clippy.toml` matches). Breaking bumps are semver-major for this repo.
- **Workspace**: root `shadowsocks-rust` + `crates/shadowsocks` + `crates/shadowsocks-service` (see root `Cargo.toml` `[workspace]`).

## Dependency direction

```
shadowsocks-rust (binaries, CLI, logging, allocators)
    └── shadowsocks-service (roles, config load, ACL, DNS helpers, local modes)
            └── shadowsocks (protocol, relay I/O, crypto facade)
                    └── shadowsocks-crypto (ciphers; optional ring / AEAD-2022, etc.)
```

- **Do not** make `shadowsocks` depend on `shadowsocks-service`. New shared logic belongs in `shadowsocks` or a small shared module, not the reverse.

## Root crate (`shadowsocks-rust`)

- **`bin/*.rs`**: thin `main` — build `clap` `Command`, delegate to `shadowsocks_rust::service::{local,server,manager,...}` (`src/service/*.rs`).
- **`src/lib.rs`**: `VERSION`, re-exports service entrypoints.
- **`src/config.rs`**, **`src/logging/*`**, **`src/daemonize/*`**, **`src/monitor/*`**, **`src/allocator/*`**: process-wide concerns (not protocol).
- **Features**: root features mostly **forward** to `shadowsocks-service/...` (e.g. `local` → `shadowsocks-service/local`, `local-tun` → `local-tun` + `ipnet`). Prefer enabling capability on the service crate when adding optional deps.

## `crates/shadowsocks` (core)

- **Role**: `ServerConfig`, relay primitives, SOCKS5 `Address`, manager wire protocol, `Context`, sockets (`net`), plugins.
- **High-signal paths**:
  - **TCP / stream tunneling**: `relay/tcprelay/` (`ProxyListener`, `ProxyClientStream`, proxy stream protocol under `proxy_stream/`).
  - **UDP**: `relay/udprelay/` (`ProxySocket`), **`net/udp.rs`** (socket wrapper, `batch_send` / `batch_recv`), **`net/sys/unix/*`** (Linux batching via `sendmmsg`/`recvmmsg`-style APIs).
  - **Manager**: `manager/`.
  - **DNS resolver hook**: `dns_resolver/`.

## `crates/shadowsocks-service`

- **Role**: runnable **local** (`sslocal`), **server** (`ssserver`), **manager** (`ssmanager`); loads JSON5 config; ACL; Hickory DNS integration; platform redir/tun/http.
- **Layout** (under `src/`):
  - **`local/`** — SOCKS4/5 (`local/socks/`), HTTP proxy (`local/http/`), transparent **redir** (`local/redir/`, per-OS `sys/` subdirs), **tunnel**, **TUN** (`local/tun/` — `smoltcp` user stack when `local-tun`), **fake-dns**, **online_config** (SIP008), **dns** relay, **net/tcp|udp** listeners, **loadbalancing** (`PingBalancer`), **`context.rs`** (`ServiceContext`).
  - **`server/`** — TCP/UDP relay servers (`tcprelay.rs`, `udprelay.rs`), `server.rs`, `context.rs`.
  - **`manager/`** — manager daemon.
  - **`acl/`** — ACL matching.
  - **`dns/`**, **`net/`** — shared service-layer DNS / flow / sockets.
  - **`config.rs`** — service config types and loading.
- **`local/context.rs`**: central handle for accept opts, balancer, ACL, DNS — most local features thread through here.

## Main binaries (feature-gated)

| Binary        | Feature     | Typical entry |
|---------------|-------------|----------------|
| `sslocal`     | `local`     | `src/service/local.rs` → `shadowsocks_service::run_local` |
| `ssserver`    | `server`    | `src/service/server.rs` |
| `ssmanager`   | `manager`   | `src/service/manager.rs` |
| `ssurl`       | `utility`   | own bin + optional `utility-url-outline` / `reqwest` |
| `ssservice`   | `service`   | wrapper for packaged multi-role |
| `sswinservice`| `winservice`| Windows service |

## Where to look (common tasks)

- **Local UDP association / performance**: `crates/shadowsocks-service/src/local/net/udp/association.rs` + core `crates/shadowsocks/src/net/udp.rs` + `crates/shadowsocks/src/net/sys/unix/*`.
- **TCP local accept / upstream**: `local/net/tcp/`, `relay/tcprelay/` (core).
- **TLS to local HTTP / DNS-over-TLS**: `shadowsocks-service` optional `tokio-rustls`, `rustls-native-certs`, Hickory features (`dns-over-tls`, etc.).
- **TUN / smoltcp**: `local/tun/*.rs` (device bridge, TCP manager thread, IP parsing); dep `smoltcp` with `medium-ip`, TCP/UDP sockets.

## Design notes

- **Async**: Tokio throughout service layer; core relay types are often used from async contexts.
- **Config**: JSON5 files + CLI; many structs under `shadowsocks`/`shadowsocks-service` `config` modules — search `Config` / `ServerConfig` before duplicating options.
- **Tests**: workspace integration tests in `tests/*.rs`; `crates/shadowsocks/tests/`; `#[cfg(test)]` modules beside sources.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.