# jsvjxgy/tfrpc architecture

> Architecture diagram of the GitHub repository jsvjxgy/tfrpc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jsvjxgy/tfrpc
- Repository: https://github.com/jsvjxgy/tfrpc

## Overview

tfrpc is a pure-C frp client that reads TOML configuration, connects to an frps server, registers configured proxies, and relays traffic between local services and server-side work connections. The runtime spans control messaging, transport selection, TLS, and per-proxy compression/encryption. README documentation establishes the product workflow and supported capabilities; source excerpts show connection-layer integrations. Some orchestration details are unsampled, so those links are omitted rather than inferred.

Main entry points: [`src/tconn.c`](https://github.com/jsvjxgy/tfrpc/blob/main/src/tconn.c) (Connection abstraction), [`src/control.c`](https://github.com/jsvjxgy/tfrpc/blob/main/src/control.c) (Control channel), [`src/quic.c`](https://github.com/jsvjxgy/tfrpc/blob/main/src/quic.c) (QUIC transport), [`src/tls.c`](https://github.com/jsvjxgy/tfrpc/blob/main/src/tls.c) (TLS handshake)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client workflow"]
  node_config["Configuration<br/>[config.c]"]
  node_entry["Client process<br/>[main.c]"]
  node_control["Control channel<br/>[control.c]"]
end

subgraph group_transport["Transport and protocol"]
  node_protocol["Message protocol<br/>[proto.c]"]
  node_v2["Wire v2<br/>[v2.c]"]
  node_connection["Connection abstraction<br/>[tconn.c]"]
  node_tcp["TCP sockets<br/>[net.c]"]
  node_kcp["KCP transport<br/>[kcpconn.c]"]
  node_quic["QUIC transport<br/>[quic.c]"]
  node_yamux["Yamux streams<br/>[yamux.c]"]
end

subgraph group_security["Security and codecs"]
  node_tls["TLS handshake<br/>[tls.c]"]
  node_certs["Certificate checks<br/>[x509.c]"]
  node_keyexchange["Key exchange<br/>[x25519.c]"]
  node_crypto["Crypto primitives<br/>[crypto.c]"]
  node_compression["Snappy codec<br/>[snappy.c]"]
end

subgraph group_relay["Proxy relay"]
  node_work["Work connections<br/>[workconn.c]"]
end

node_operator(("Operator"))
node_local(("Local services"))
node_frps(("frps server"))

node_operator -->|"provides settings"| node_config
node_operator -->|"starts client"| node_entry
node_entry -->|"connects to"| node_frps
node_frps -->|"accepts control"| node_control
node_control -->|"exchanges messages"| node_protocol
node_control -.->|"coordinates proxies"| node_work
node_work -->|"relays traffic"| node_local
node_work -->|"opens work connection"| node_frps
node_connection -->|"wraps transport"| node_tls
node_connection -->|"reads and writes"| node_kcp
node_connection -.->|"uses streams"| node_quic
node_connection -->|"uses streams"| node_yamux
node_connection -->|"compresses data"| node_compression
node_connection -->|"encrypts data"| node_crypto
node_tls -->|"derives shared key"| node_keyexchange
node_tls -->|"verifies certificates"| node_certs
node_quic -->|"checks certificates"| node_certs
node_quic -->|"uses key agreement"| node_keyexchange
node_control -.->|"uses v2 framing"| node_v2
node_control -.->|"uses connection layer"| node_connection
node_connection -.->|"uses sockets"| node_tcp

click node_config "https://github.com/jsvjxgy/tfrpc/blob/main/src/config.c"
click node_entry "https://github.com/jsvjxgy/tfrpc/blob/main/src/main.c"
click node_control "https://github.com/jsvjxgy/tfrpc/blob/main/src/control.c"
click node_work "https://github.com/jsvjxgy/tfrpc/blob/main/src/workconn.c"
click node_protocol "https://github.com/jsvjxgy/tfrpc/blob/main/src/proto.c"
click node_v2 "https://github.com/jsvjxgy/tfrpc/blob/main/src/v2.c"
click node_connection "https://github.com/jsvjxgy/tfrpc/blob/main/src/tconn.c"
click node_tcp "https://github.com/jsvjxgy/tfrpc/blob/main/src/net.c"
click node_kcp "https://github.com/jsvjxgy/tfrpc/blob/main/src/kcpconn.c"
click node_quic "https://github.com/jsvjxgy/tfrpc/blob/main/src/quic.c"
click node_yamux "https://github.com/jsvjxgy/tfrpc/blob/main/src/yamux.c"
click node_tls "https://github.com/jsvjxgy/tfrpc/blob/main/src/tls.c"
click node_certs "https://github.com/jsvjxgy/tfrpc/blob/main/src/x509.c"
click node_keyexchange "https://github.com/jsvjxgy/tfrpc/blob/main/src/x25519.c"
click node_crypto "https://github.com/jsvjxgy/tfrpc/blob/main/src/crypto.c"
click node_compression "https://github.com/jsvjxgy/tfrpc/blob/main/src/snappy.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config,node_entry,node_control toneBlue
class node_protocol,node_v2,node_connection,node_tcp,node_kcp,node_quic,node_yamux toneAmber
class node_tls,node_certs,node_keyexchange,node_crypto,node_compression,node_frps toneMint
class node_work toneRose
class node_operator,node_local toneIndigo
```

## Components

### Client workflow

- [Configuration](https://github.com/jsvjxgy/tfrpc/blob/main/src/config.c): `src/config.c`
- [Client process](https://github.com/jsvjxgy/tfrpc/blob/main/src/main.c): `src/main.c`
- [Control channel](https://github.com/jsvjxgy/tfrpc/blob/main/src/control.c): `src/control.c`

### Transport and protocol

- [Message protocol](https://github.com/jsvjxgy/tfrpc/blob/main/src/proto.c): `src/proto.c`
- [Wire v2](https://github.com/jsvjxgy/tfrpc/blob/main/src/v2.c): `src/v2.c`
- [Connection abstraction](https://github.com/jsvjxgy/tfrpc/blob/main/src/tconn.c): `src/tconn.c`
- [TCP sockets](https://github.com/jsvjxgy/tfrpc/blob/main/src/net.c): `src/net.c`
- [KCP transport](https://github.com/jsvjxgy/tfrpc/blob/main/src/kcpconn.c): `src/kcpconn.c`
- [QUIC transport](https://github.com/jsvjxgy/tfrpc/blob/main/src/quic.c): `src/quic.c`
- [Yamux streams](https://github.com/jsvjxgy/tfrpc/blob/main/src/yamux.c): `src/yamux.c`

### Security and codecs

- [TLS handshake](https://github.com/jsvjxgy/tfrpc/blob/main/src/tls.c): `src/tls.c`
- [Certificate checks](https://github.com/jsvjxgy/tfrpc/blob/main/src/x509.c): `src/x509.c`
- [Key exchange](https://github.com/jsvjxgy/tfrpc/blob/main/src/x25519.c): `src/x25519.c`
- [Crypto primitives](https://github.com/jsvjxgy/tfrpc/blob/main/src/crypto.c): `src/crypto.c`
- [Snappy codec](https://github.com/jsvjxgy/tfrpc/blob/main/src/snappy.c): `src/snappy.c`

### Proxy relay

- [Work connections](https://github.com/jsvjxgy/tfrpc/blob/main/src/workconn.c): `src/workconn.c`

### Other components

- **Operator**
- **Local services**
- **frps server**

## Connections

- Operator → Configuration: provides settings (evidence: `README.md`)
- Operator → Client process: starts client (evidence: `README.md`)
- Client process → frps server: connects to (evidence: `README.md`)
- frps server → Control channel: accepts control (evidence: `README.md`)
- Control channel → Message protocol: exchanges messages (evidence: `README.md`)
- Control channel → Work connections: coordinates proxies
- Work connections → Local services: relays traffic (evidence: `README.md`)
- Work connections → frps server: opens work connection (evidence: `README.md`)
- Connection abstraction → TLS handshake: wraps transport (evidence: `src/tconn.c`)
- Connection abstraction → KCP transport: reads and writes (evidence: `src/tconn.c`)
- Connection abstraction → QUIC transport: uses streams
- Connection abstraction → Yamux streams: uses streams (evidence: `src/tconn.c`)
- Connection abstraction → Snappy codec: compresses data (evidence: `src/tconn.c`)
- Connection abstraction → Crypto primitives: encrypts data (evidence: `src/tconn.c`)
- TLS handshake → Key exchange: derives shared key (evidence: `src/tls.c`)
- TLS handshake → Certificate checks: verifies certificates (evidence: `src/tls.c`)
- QUIC transport → Certificate checks: checks certificates (evidence: `src/quic.c`)
- QUIC transport → Key exchange: uses key agreement (evidence: `src/quic.c`)
- Control channel → Wire v2: uses v2 framing
- Control channel → Connection abstraction: uses connection layer
- Connection abstraction → TCP sockets: uses sockets
