# hynetworks/hysteria architecture

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

- Interactive diagram: https://gitdiagram.com/hynetworks/hysteria
- Repository: https://github.com/hynetworks/hysteria

## Overview

Hysteria 2 is a censorship-resistant proxy. A client command loads configuration, establishes a QUIC-based core connection, and exposes it through proxy, forwarding, or tunnel modes; a server accepts sessions and provides proxying and related services. The README documents SOCKS5, HTTP, TCP/UDP forwarding, Linux TProxy, TUN, and customized QUIC. Authentication, access control, traffic logging, congestion control, masquerading, and NAT traversal are additional capabilities. Several domain branches are represented from documentation and the file tree; their internal wiring was not sampled, so unsupported links are omitted.

Main entry points: [`app/cmd/client.go`](https://github.com/hynetworks/hysteria/blob/master/app/cmd/client.go) (Client CLI), [`core/server/server.go`](https://github.com/hynetworks/hysteria/blob/master/core/server/server.go) (Server Session), [`core/client/client.go`](https://github.com/hynetworks/hysteria/blob/master/core/client/client.go) (Client Session), [`app/cmd/server.go`](https://github.com/hynetworks/hysteria/blob/master/app/cmd/server.go) (Server CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_client_cmd["Client CLI<br/>[client.go]"]
  node_server_cmd["Server CLI<br/>[server.go]"]
  node_url_config["Share URLs<br/>[url.go]"]
end

subgraph group_core["QUIC Core"]
  node_client_core["Client Session<br/>[client.go]"]
  node_server_core["Server Session<br/>[server.go]"]
  node_udp_core["UDP Sessions<br/>[udp.go]"]
  node_congestion["Congestion Control<br/>[bbr_sender.go]"]
  node_protocol["Proxy Protocol<br/>[proxy.go]"]
end

subgraph group_extras["Proxy Extensions"]
  node_outbounds["Outbound Routing<br/>[ob_direct.go]"]
  node_acl["Access Rules<br/>[compile.go]"]
  node_auth["Authentication<br/>[http.go]"]
  node_traffic_log["Traffic Logging<br/>[http.go]"]
  node_masq["Masquerade<br/>[server.go]"]
  node_realm["NAT Traversal<br/>[client.go]"]
  node_obfs["Obfuscation<br/>[conn.go]"]
  node_speedtest["Speed Test<br/>[server.go]"]
end

subgraph group_net["Network Modes"]
  node_http_proxy["HTTP Proxy<br/>[server.go]"]
  node_socks_proxy["SOCKS5 Proxy<br/>[server.go]"]
  node_tun["TUN Interface<br/>[server.go]"]
  node_forward["TCP/UDP Forwarding"]
  node_tproxy["Linux TProxy"]
  node_redirect["TCP Redirect"]
end

node_user(("Operator"))

node_user -->|"configures"| node_client_cmd
node_user -->|"configures"| node_server_cmd
node_client_cmd -->|"creates client"| node_client_core
node_client_cmd -->|"configures"| node_tun
node_http_proxy -->|"dials through"| node_client_core
node_socks_proxy -->|"dials through"| node_client_core
node_client_core -->|"selects controller"| node_congestion
node_server_core -->|"starts sessions"| node_udp_core
node_server_cmd -->|"configures traversal"| node_realm
node_client_cmd -->|"accepts share links"| node_url_config
node_client_cmd -.->|"offers mode"| node_http_proxy
node_client_cmd -.->|"offers mode"| node_socks_proxy
node_client_cmd -.->|"offers mode"| node_forward
node_client_cmd -.->|"offers mode"| node_tproxy
node_client_cmd -.->|"offers mode"| node_redirect
node_server_cmd -.->|"runs server"| node_server_core
node_server_core -.->|"routes traffic"| node_outbounds
node_server_core -.->|"handles proxy protocol"| node_protocol
node_server_core -.->|"authenticates users"| node_auth
node_server_core -.->|"checks access"| node_acl
node_server_core -.->|"logs traffic"| node_traffic_log
node_server_cmd -.->|"configures disguise"| node_masq
node_client_core -.->|"supports obfuscation"| node_obfs
node_server_core -.->|"supports testing"| node_speedtest

click node_client_cmd "https://github.com/hynetworks/hysteria/blob/master/app/cmd/client.go"
click node_server_cmd "https://github.com/hynetworks/hysteria/blob/master/app/cmd/server.go"
click node_http_proxy "https://github.com/hynetworks/hysteria/blob/master/app/internal/http/server.go"
click node_socks_proxy "https://github.com/hynetworks/hysteria/blob/master/app/internal/socks5/server.go"
click node_tun "https://github.com/hynetworks/hysteria/blob/master/app/internal/tun/server.go"
click node_url_config "https://github.com/hynetworks/hysteria/blob/master/app/internal/url/url.go"
click node_client_core "https://github.com/hynetworks/hysteria/blob/master/core/client/client.go"
click node_server_core "https://github.com/hynetworks/hysteria/blob/master/core/server/server.go"
click node_udp_core "https://github.com/hynetworks/hysteria/blob/master/core/server/udp.go"
click node_congestion "https://github.com/hynetworks/hysteria/blob/master/core/internal/congestion/bbr/bbr_sender.go"
click node_protocol "https://github.com/hynetworks/hysteria/blob/master/core/internal/protocol/proxy.go"
click node_outbounds "https://github.com/hynetworks/hysteria/blob/master/extras/outbounds/ob_direct.go"
click node_acl "https://github.com/hynetworks/hysteria/blob/master/extras/outbounds/acl/compile.go"
click node_auth "https://github.com/hynetworks/hysteria/blob/master/extras/auth/http.go"
click node_traffic_log "https://github.com/hynetworks/hysteria/blob/master/extras/trafficlogger/http.go"
click node_masq "https://github.com/hynetworks/hysteria/blob/master/extras/masq/server.go"
click node_realm "https://github.com/hynetworks/hysteria/blob/master/extras/realm/client.go"
click node_obfs "https://github.com/hynetworks/hysteria/blob/master/extras/obfs/conn.go"
click node_speedtest "https://github.com/hynetworks/hysteria/blob/master/extras/outbounds/speedtest/server.go"
click node_forward "https://github.com/hynetworks/hysteria/tree/master/app/internal/forwarding"
click node_tproxy "https://github.com/hynetworks/hysteria/tree/master/app/internal/tproxy"
click node_redirect "https://github.com/hynetworks/hysteria/tree/master/app/internal/redirect"

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_client_cmd,node_server_cmd,node_url_config toneBlue
class node_client_core,node_server_core,node_udp_core,node_congestion,node_protocol toneAmber
class node_outbounds,node_acl,node_auth,node_traffic_log,node_masq,node_realm,node_obfs,node_speedtest toneMint
class node_http_proxy,node_socks_proxy,node_tun,node_forward,node_tproxy,node_redirect toneRose
class node_user toneIndigo
```

## Components

### Application

- [Client CLI](https://github.com/hynetworks/hysteria/blob/master/app/cmd/client.go): `app/cmd/client.go`
- [Server CLI](https://github.com/hynetworks/hysteria/blob/master/app/cmd/server.go): `app/cmd/server.go`
- [Share URLs](https://github.com/hynetworks/hysteria/blob/master/app/internal/url/url.go): `app/internal/url/url.go`

### QUIC Core

- [Client Session](https://github.com/hynetworks/hysteria/blob/master/core/client/client.go): `core/client/client.go`
- [Server Session](https://github.com/hynetworks/hysteria/blob/master/core/server/server.go): `core/server/server.go`
- [UDP Sessions](https://github.com/hynetworks/hysteria/blob/master/core/server/udp.go): `core/server/udp.go`
- [Congestion Control](https://github.com/hynetworks/hysteria/blob/master/core/internal/congestion/bbr/bbr_sender.go): `core/internal/congestion/bbr/bbr_sender.go`
- [Proxy Protocol](https://github.com/hynetworks/hysteria/blob/master/core/internal/protocol/proxy.go): `core/internal/protocol/proxy.go`

### Proxy Extensions

- [Outbound Routing](https://github.com/hynetworks/hysteria/blob/master/extras/outbounds/ob_direct.go): `extras/outbounds/ob_direct.go`
- [Access Rules](https://github.com/hynetworks/hysteria/blob/master/extras/outbounds/acl/compile.go): `extras/outbounds/acl/compile.go`
- [Authentication](https://github.com/hynetworks/hysteria/blob/master/extras/auth/http.go): `extras/auth/http.go`
- [Traffic Logging](https://github.com/hynetworks/hysteria/blob/master/extras/trafficlogger/http.go): `extras/trafficlogger/http.go`
- [Masquerade](https://github.com/hynetworks/hysteria/blob/master/extras/masq/server.go): `extras/masq/server.go`
- [NAT Traversal](https://github.com/hynetworks/hysteria/blob/master/extras/realm/client.go): `extras/realm/client.go`
- [Obfuscation](https://github.com/hynetworks/hysteria/blob/master/extras/obfs/conn.go): `extras/obfs/conn.go`
- [Speed Test](https://github.com/hynetworks/hysteria/blob/master/extras/outbounds/speedtest/server.go): `extras/outbounds/speedtest/server.go`

### Network Modes

- [HTTP Proxy](https://github.com/hynetworks/hysteria/blob/master/app/internal/http/server.go): `app/internal/http/server.go`
- [SOCKS5 Proxy](https://github.com/hynetworks/hysteria/blob/master/app/internal/socks5/server.go): `app/internal/socks5/server.go`
- [TUN Interface](https://github.com/hynetworks/hysteria/blob/master/app/internal/tun/server.go): `app/internal/tun/server.go`
- [TCP/UDP Forwarding](https://github.com/hynetworks/hysteria/tree/master/app/internal/forwarding): `app/internal/forwarding`
- [Linux TProxy](https://github.com/hynetworks/hysteria/tree/master/app/internal/tproxy): `app/internal/tproxy`
- [TCP Redirect](https://github.com/hynetworks/hysteria/tree/master/app/internal/redirect): `app/internal/redirect`

### Other components

- **Operator**

## Connections

- Operator → Client CLI: configures
- Operator → Server CLI: configures
- Client CLI → Client Session: creates client (evidence: `app/cmd/client.go`)
- Client CLI → TUN Interface: configures (evidence: `app/cmd/client.go`)
- HTTP Proxy → Client Session: dials through (evidence: `app/internal/http/server.go`)
- SOCKS5 Proxy → Client Session: dials through (evidence: `app/internal/socks5/server.go`)
- Client Session → Congestion Control: selects controller (evidence: `core/client/client.go`)
- Server Session → UDP Sessions: starts sessions (evidence: `core/server/server.go`)
- Server CLI → NAT Traversal: configures traversal (evidence: `app/cmd/server.go`)
- Client CLI → Share URLs: accepts share links (evidence: `app/cmd/client.go`)
- Client CLI → HTTP Proxy: offers mode
- Client CLI → SOCKS5 Proxy: offers mode
- Client CLI → TCP/UDP Forwarding: offers mode
- Client CLI → Linux TProxy: offers mode
- Client CLI → TCP Redirect: offers mode
- Server CLI → Server Session: runs server
- Server Session → Outbound Routing: routes traffic
- Server Session → Proxy Protocol: handles proxy protocol
- Server Session → Authentication: authenticates users
- Server Session → Access Rules: checks access
- Server Session → Traffic Logging: logs traffic
- Server CLI → Masquerade: configures disguise
- Client Session → Obfuscation: supports obfuscation
- Server Session → Speed Test: supports testing
