# leassaryn/myssh architecture

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

- Interactive diagram: https://gitdiagram.com/leassaryn/myssh
- Repository: https://github.com/leassaryn/myssh

## Overview

myssh is a multi-protocol SSH tunnel engine that exposes a local SOCKS5/HTTP proxy, with an optional web dashboard for managing profiles and observing operation. The main workflow is configuration and start, SSH connection over a selected transport, then local proxy traffic forwarded through the tunnel; optional DNS and geolocation routing influence egress. The graph also preserves documented transport families, probes, traffic statistics, and dashboard storage. Several subsystem links rely on README descriptions because their implementation files were not excerpted.

Main entry points: [`ssh_client.go`](https://github.com/leassaryn/myssh/blob/main/ssh_client.go) (SSH client), [`engine.go`](https://github.com/leassaryn/myssh/blob/main/engine.go) (Engine lifecycle), [`unified_outbound.go`](https://github.com/leassaryn/myssh/blob/main/unified_outbound.go) (Unified outbound), [`web/web.go`](https://github.com/leassaryn/myssh/blob/main/web/web.go) (Web API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Engine lifecycle"]
  node_cli["CLI entry<br/>[main.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_engine["Engine lifecycle<br/>[engine.go]"]
  node_callbacks["Engine callbacks<br/>[engine_callback.go]"]
end

subgraph group_proxy["Proxy data plane"]
  node_socks["SOCKS5 ingress<br/>[socks5.go]"]
  node_socks_server["SOCKS server<br/>[socks_server.go]"]
  node_outbound["Unified outbound"]
  node_relay["TCP and UDP relay<br/>[relay.go]"]
  node_traffic["Traffic statistics<br/>[traffic_stats.go]"]
end

subgraph group_transport["Tunnel transports"]
  node_ssh["SSH client<br/>[ssh_client.go]"]
  node_http_transports["HTTP transports<br/>[tunnel_h2.go]"]
  node_stream_transports["Stream transports<br/>[tunnel_raw.go]"]
  node_datagram_transports["Datagram transports"]
  node_kcptun["KCP transport<br/>[tunnel_kcptun.go]"]
end

subgraph group_routing["DNS and routing"]
  node_dns["DNS resolver<br/>[dns.go]"]
  node_dns_cache["DNS cache<br/>[dns_cache.go]"]
  node_geo["Geo data<br/>[geo_download.go]"]
  node_geo_router["Geo routing<br/>[georouter.go]"]
  node_ipv6["IPv6 egress<br/>[ipv6_egress.go]"]
end

subgraph group_management["Management and observability"]
  node_probe["Latency and speed probes<br/>[probe.go]"]
  node_web_ui["Web dashboard<br/>[script.js]"]
  node_web_api["Web API<br/>[web.go]"]
  node_profiles[("Profile database<br/>[db.go]")]
end

node_external_user(("User or host app"))
node_remote_ssh(("SSH endpoint"))

node_external_user -->|"starts"| node_cli
node_cli -->|"loads"| node_config
node_cli -->|"starts"| node_engine
node_engine -->|"starts"| node_socks_server
node_engine -->|"connects"| node_ssh
node_engine -->|"starts"| node_dns
node_engine -->|"emits events"| node_callbacks
node_socks -.->|"dispatches"| node_outbound
node_outbound -.->|"forwards traffic"| node_ssh
node_outbound -.->|"selects route"| node_geo_router
node_outbound -.->|"relays"| node_relay
node_socks -.->|"records usage"| node_traffic
node_ssh -->|"opens session"| node_remote_ssh
node_ssh -->|"uses transport"| node_http_transports
node_ssh -->|"uses transport"| node_stream_transports
node_ssh -->|"uses transport"| node_datagram_transports
node_ssh -->|"uses transport"| node_kcptun
node_dns -.->|"uses cache"| node_dns_cache
node_geo -.->|"provides rules"| node_geo_router
node_ipv6 -.->|"supports egress"| node_outbound
node_external_user -->|"manages proxy"| node_web_ui
node_web_ui -->|"calls API"| node_web_api
node_web_api -->|"reads profiles"| node_profiles
node_web_api -->|"starts or stops"| node_engine
node_web_api -->|"reads statistics"| node_traffic
node_external_user -.->|"requests probes"| node_probe

click node_cli "https://github.com/leassaryn/myssh/blob/main/cmd/main.go"
click node_config "https://github.com/leassaryn/myssh/blob/main/config.go"
click node_engine "https://github.com/leassaryn/myssh/blob/main/engine.go"
click node_callbacks "https://github.com/leassaryn/myssh/blob/main/engine_callback.go"
click node_socks "https://github.com/leassaryn/myssh/blob/main/socks5.go"
click node_socks_server "https://github.com/leassaryn/myssh/blob/main/socks_server.go"
click node_outbound "https://github.com/leassaryn/myssh/blob/main/unified_outbound.go"
click node_relay "https://github.com/leassaryn/myssh/blob/main/relay.go"
click node_traffic "https://github.com/leassaryn/myssh/blob/main/traffic_stats.go"
click node_ssh "https://github.com/leassaryn/myssh/blob/main/ssh_client.go"
click node_http_transports "https://github.com/leassaryn/myssh/blob/main/tunnel_h2.go"
click node_stream_transports "https://github.com/leassaryn/myssh/blob/main/tunnel_raw.go"
click node_datagram_transports "https://github.com/leassaryn/myssh/blob/main/tunnel_udp_custom.go"
click node_kcptun "https://github.com/leassaryn/myssh/blob/main/tunnel_kcptun.go"
click node_dns "https://github.com/leassaryn/myssh/blob/main/dns.go"
click node_dns_cache "https://github.com/leassaryn/myssh/blob/main/dns_cache.go"
click node_geo "https://github.com/leassaryn/myssh/blob/main/geo_download.go"
click node_geo_router "https://github.com/leassaryn/myssh/blob/main/georouter.go"
click node_ipv6 "https://github.com/leassaryn/myssh/blob/main/ipv6_egress.go"
click node_probe "https://github.com/leassaryn/myssh/blob/main/probe.go"
click node_web_ui "https://github.com/leassaryn/myssh/blob/main/web/html/static/script.js"
click node_web_api "https://github.com/leassaryn/myssh/blob/main/web/web.go"
click node_profiles "https://github.com/leassaryn/myssh/blob/main/web/db.go"

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_cli,node_config,node_engine,node_callbacks,node_external_user toneBlue
class node_socks,node_socks_server,node_outbound,node_relay,node_traffic toneAmber
class node_ssh,node_http_transports,node_stream_transports,node_datagram_transports,node_kcptun toneMint
class node_dns,node_dns_cache,node_geo,node_geo_router,node_ipv6 toneRose
class node_probe,node_web_ui,node_web_api,node_profiles,node_remote_ssh toneIndigo
```

## Components

### Engine lifecycle

- [CLI entry](https://github.com/leassaryn/myssh/blob/main/cmd/main.go): `cmd/main.go`
- [Configuration](https://github.com/leassaryn/myssh/blob/main/config.go): `config.go`
- [Engine lifecycle](https://github.com/leassaryn/myssh/blob/main/engine.go): `engine.go`
- [Engine callbacks](https://github.com/leassaryn/myssh/blob/main/engine_callback.go): `engine_callback.go`

### Proxy data plane

- [SOCKS5 ingress](https://github.com/leassaryn/myssh/blob/main/socks5.go): `socks5.go`
- [SOCKS server](https://github.com/leassaryn/myssh/blob/main/socks_server.go): `socks_server.go`
- [Unified outbound](https://github.com/leassaryn/myssh/blob/main/unified_outbound.go): `unified_outbound.go`
- [TCP and UDP relay](https://github.com/leassaryn/myssh/blob/main/relay.go): `relay.go`
- [Traffic statistics](https://github.com/leassaryn/myssh/blob/main/traffic_stats.go): `traffic_stats.go`

### Tunnel transports

- [SSH client](https://github.com/leassaryn/myssh/blob/main/ssh_client.go): `ssh_client.go`
- [HTTP transports](https://github.com/leassaryn/myssh/blob/main/tunnel_h2.go): `tunnel_h2.go`
- [Stream transports](https://github.com/leassaryn/myssh/blob/main/tunnel_raw.go): `tunnel_raw.go`
- [Datagram transports](https://github.com/leassaryn/myssh/blob/main/tunnel_udp_custom.go): `tunnel_udp_custom.go`
- [KCP transport](https://github.com/leassaryn/myssh/blob/main/tunnel_kcptun.go): `tunnel_kcptun.go`

### DNS and routing

- [DNS resolver](https://github.com/leassaryn/myssh/blob/main/dns.go): `dns.go`
- [DNS cache](https://github.com/leassaryn/myssh/blob/main/dns_cache.go): `dns_cache.go`
- [Geo data](https://github.com/leassaryn/myssh/blob/main/geo_download.go): `geo_download.go`
- [Geo routing](https://github.com/leassaryn/myssh/blob/main/georouter.go): `georouter.go`
- [IPv6 egress](https://github.com/leassaryn/myssh/blob/main/ipv6_egress.go): `ipv6_egress.go`

### Management and observability

- [Latency and speed probes](https://github.com/leassaryn/myssh/blob/main/probe.go): `probe.go`
- [Web dashboard](https://github.com/leassaryn/myssh/blob/main/web/html/static/script.js): `web/html/static/script.js`
- [Web API](https://github.com/leassaryn/myssh/blob/main/web/web.go): `web/web.go`
- [Profile database](https://github.com/leassaryn/myssh/blob/main/web/db.go): `web/db.go`

### Other components

- **User or host app**
- **SSH endpoint**

## Connections

- User or host app → CLI entry: starts (evidence: `cmd/main.go`)
- CLI entry → Configuration: loads (evidence: `cmd/main.go`)
- CLI entry → Engine lifecycle: starts (evidence: `cmd/main.go`)
- Engine lifecycle → SOCKS server: starts (evidence: `engine.go`)
- Engine lifecycle → SSH client: connects
- Engine lifecycle → DNS resolver: starts (evidence: `engine.go`)
- Engine lifecycle → Engine callbacks: emits events (evidence: `engine_callback.go`)
- SOCKS5 ingress → Unified outbound: dispatches
- Unified outbound → SSH client: forwards traffic
- Unified outbound → Geo routing: selects route
- Unified outbound → TCP and UDP relay: relays
- SOCKS5 ingress → Traffic statistics: records usage
- SSH client → SSH endpoint: opens session
- SSH client → HTTP transports: uses transport
- SSH client → Stream transports: uses transport
- SSH client → Datagram transports: uses transport
- SSH client → KCP transport: uses transport
- DNS resolver → DNS cache: uses cache
- Geo data → Geo routing: provides rules
- IPv6 egress → Unified outbound: supports egress
- User or host app → Web dashboard: manages proxy
- Web dashboard → Web API: calls API (evidence: `web/html/static/script.js`)
- Web API → Profile database: reads profiles
- Web API → Engine lifecycle: starts or stops
- Web API → Traffic statistics: reads statistics
- User or host app → Latency and speed probes: requests probes
