Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ mime_guess = "*"
notify = "*"
parking_lot = "*"
percent-encoding = "*"
kcp-tokio = "0.4"
tracing-subscriber = { version = "*", features = ["env-filter"] }
quinn = { version = "*", default-features = false, features = ["log", "platform-verifier", "runtime-tokio", "rustls-aws-lc-rs"] }
rand = "*"
rand_core = "*"
Expand Down
103 changes: 102 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ All server protocols plus:
- **WebSocket** (Shadowsocks SIP003)
- **XTLS Reality**
- **XTLS Vision** (for VLESS)
- **KCP** (UDP-based ARQ transport via [kcp-tokio](https://github.com/leihuxi/rust-kcp))

### TUN/VPN Mode
- **TUN device support** - Layer 3 VPN for transparent proxying
Expand All @@ -39,7 +40,7 @@ All server protocols plus:

## Features

- **Multi-transport**: TCP or QUIC for all protocols
- **Multi-transport**: TCP, QUIC, or KCP for all protocols
- **TLS with SNI routing**: Route by Server Name Indication
- **Upstream proxy chaining**: Multi-hop chains with load balancing
- **Rule-based routing**: Route by IP/CIDR or hostname masks
Expand Down Expand Up @@ -261,6 +262,106 @@ See the [examples](./examples) directory for all examples.
user_id: b85798ef-e9dc-46a4-9a87-8da4499d36d0
```

### KCP + VLESS Server

KCP runs over UDP and provides ARQ (Automatic Repeat reQuest) reliability with lower latency
than TCP on lossy networks. Any TCP-based protocol can be wrapped with KCP transport.

```yaml
- address: 0.0.0.0:16823
transport: kcp
kcp_settings:
mode: fast # normal | fast | turbo | gaming | file_transfer
send_window: 128 # packets
recv_window: 128 # packets
mtu: 1400 # bytes
protocol:
type: vless
user_id: b85798ef-e9dc-46a4-9a87-8da4499d36d0
udp_enabled: true
```

### KCP + VLESS Client

```yaml
- address: 127.0.0.1:1080
protocol:
type: socks
rules:
- masks: "0.0.0.0/0"
action: allow
client_chain:
address: "server.example.com:16823"
transport: kcp
kcp_settings:
mode: fast
send_window: 128
recv_window: 128
mtu: 1400
protocol:
type: vless
user_id: b85798ef-e9dc-46a4-9a87-8da4499d36d0
```

### KCP + Reality Server

KCP can be combined with Reality to disguise traffic as a legitimate TLS handshake while
benefiting from KCP's UDP-based low-latency transport.

```yaml
- address: 0.0.0.0:8443
transport: kcp
kcp_settings:
mode: fast
mtu: 1400
protocol:
type: tls
reality_targets:
"www.example.com":
private_key: "YOUR_BASE64URL_PRIVATE_KEY"
short_ids: ["0123456789abcdef", ""]
dest: "www.example.com:443"
protocol:
type: vless
user_id: b85798ef-e9dc-46a4-9a87-8da4499d36d0
udp_enabled: true
```

### KCP + Reality Client

```yaml
- address: 127.0.0.1:1080
protocol:
type: socks
rules:
- masks: "0.0.0.0/0"
action: allow
client_chain:
address: "server.example.com:8443"
transport: kcp
kcp_settings:
mode: fast
mtu: 1400
protocol:
type: reality
public_key: "SERVER_PUBLIC_KEY"
short_id: "0123456789abcdef"
sni_hostname: "www.example.com"
protocol:
type: vless
user_id: b85798ef-e9dc-46a4-9a87-8da4499d36d0
```

#### KCP mode reference

| Mode | Update interval | Resend | NodeDelay | Use case |
|------|----------------|--------|-----------|----------|
| `normal` | 40 ms | 0 | yes | General purpose (default) |
| `fast` | 8 ms | 2 | yes | Low-latency proxying |
| `turbo` | 4 ms | 1 | no | Maximum throughput |
| `gaming` | 3 ms | 1 | no | Real-time / interactive |
| `file_transfer` | — | — | — | Reliable bulk transfer |

## Similar Projects

- [apernet/hysteria](https://github.com/apernet/hysteria)
Expand Down
6 changes: 5 additions & 1 deletion src/config/types/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::common::{
};
use super::server::WebsocketPingType;
use super::shadowsocks::ShadowsocksConfig;
use super::transport::{ClientQuicConfig, TcpConfig, Transport};
use super::transport::{ClientQuicConfig, KcpSettings, TcpConfig, Transport};

/// Configuration for h2mux (HTTP/2 multiplexing) on protocols that support it.
///
Expand Down Expand Up @@ -291,6 +291,8 @@ pub struct ClientConfig {
pub tcp_settings: Option<TcpConfig>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub quic_settings: Option<ClientQuicConfig>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub kcp_settings: Option<KcpSettings>,
}

impl Default for ClientConfig {
Expand All @@ -302,6 +304,7 @@ impl Default for ClientConfig {
transport: Transport::default(),
tcp_settings: None,
quic_settings: None,
kcp_settings: None,
}
}
}
Expand Down Expand Up @@ -525,6 +528,7 @@ mod tests {
transport: Transport::Tcp,
tcp_settings: None,
quic_settings: None,
kcp_settings: None,
}
}

Expand Down
Loading