# snail007/goproxy architecture

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

- Interactive diagram: https://gitdiagram.com/snail007/goproxy
- Repository: https://github.com/snail007/goproxy

## Overview

GoProxy is a multi-protocol proxy and tunneling server. The principal workflow is a client request entering a configured proxy service, being parsed or forwarded, optionally routed through a parent proxy, and relayed to a destination. The graph includes the HTTP routing/authentication stages, TCP and UDP forwarding, and tunnel endpoints. README capabilities such as SOCKS5, WebSocket, load balancing, and protocol conversion are documented but their implementations are not identifiable from the sampled source, so they are represented only as a documented feature area under services/.

Main entry points: [`services/http.go`](https://github.com/snail007/goproxy/blob/master/services/http.go) (HTTP proxy), [`services/service.go`](https://github.com/snail007/goproxy/blob/master/services/service.go) (Service registry), [`utils/serve-channel.go`](https://github.com/snail007/goproxy/blob/master/utils/serve-channel.go) (Network listeners), [`services/tcp.go`](https://github.com/snail007/goproxy/blob/master/services/tcp.go) (TCP proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Startup and control"]
  node_main["Process entry<br/>[main.go]"]
  node_config["CLI configuration<br/>[config.go]"]
  node_registry["Service registry<br/>[service.go]"]
end

subgraph group_proxy["Proxy services"]
  node_http["HTTP proxy<br/>[http.go]"]
  node_tcp["TCP proxy<br/>[tcp.go]"]
  node_udp["UDP proxy<br/>[udp.go]"]
  node_http_features["Documented protocols"]
end

subgraph group_tunnel["Tunnel services"]
  node_tclient["Tunnel client<br/>[tunnel_client.go]"]
  node_tserver["Tunnel server<br/>[tunnel_server.go]"]
  node_tbridge["Tunnel bridge<br/>[tunnel_bridge.go]"]
  node_udp_queue["UDP work queue<br/>[tunnel_server.go]"]
end

subgraph group_runtime["Runtime utilities"]
  node_listener["Network listeners<br/>[serve-channel.go]"]
  node_http_tools["HTTP parsing and auth<br/>[structs.go]"]
  node_routing["Domain routing checks<br/>[structs.go]"]
  node_connections["Connection utilities<br/>[functions.go]"]
end

node_client(("Proxy client"))
node_destination(("Target service"))
node_parent(("Parent proxy"))

node_main -->|"loads configuration"| node_config
node_config -->|"registers and runs"| node_registry
node_main -->|"cleans service"| node_registry
node_registry -->|"starts service"| node_http
node_registry -->|"starts service"| node_tcp
node_registry -->|"starts service"| node_udp
node_registry -->|"starts service"| node_tclient
node_registry -->|"starts service"| node_tserver
node_registry -->|"starts service"| node_tbridge
node_client -->|"sends requests"| node_http
node_client -->|"opens connection"| node_tcp
node_client -->|"sends datagrams"| node_udp
node_http -->|"opens listener"| node_listener
node_tcp -->|"opens listener"| node_listener
node_udp -->|"opens listener"| node_listener
node_listener -->|"dispatches requests"| node_http
node_listener -->|"dispatches connections"| node_tcp
node_listener -->|"dispatches datagrams"| node_udp
node_http -->|"parses and authenticates"| node_http_tools
node_http -->|"checks destination"| node_routing
node_http -->|"connects and relays"| node_connections
node_http -->|"forwards via parent"| node_parent
node_http -->|"forwards directly"| node_destination
node_tcp -->|"connects and relays"| node_connections
node_tcp -->|"forwards via parent"| node_parent
node_tcp -->|"forwards to target"| node_destination
node_udp -->|"forwards via parent"| node_parent
node_udp -->|"forwards datagrams"| node_destination
node_tclient -->|"opens TLS tunnel"| node_parent
node_tclient -->|"relays to local target"| node_destination
node_tserver -->|"opens TLS tunnel"| node_parent
node_tserver -->|"listens for tunnel traffic"| node_listener
node_tserver -->|"queues UDP packets"| node_udp_queue
node_udp_queue -->|"sends tunneled packets"| node_parent
node_tbridge -->|"bridges traffic"| node_listener
node_http_features -.->|"includes documented modes"| node_http

click node_main "https://github.com/snail007/goproxy/blob/master/main.go"
click node_config "https://github.com/snail007/goproxy/blob/master/config.go"
click node_registry "https://github.com/snail007/goproxy/blob/master/services/service.go"
click node_http "https://github.com/snail007/goproxy/blob/master/services/http.go"
click node_tcp "https://github.com/snail007/goproxy/blob/master/services/tcp.go"
click node_udp "https://github.com/snail007/goproxy/blob/master/services/udp.go"
click node_http_features "https://github.com/snail007/goproxy/tree/master/services"
click node_tclient "https://github.com/snail007/goproxy/blob/master/services/tunnel_client.go"
click node_tserver "https://github.com/snail007/goproxy/blob/master/services/tunnel_server.go"
click node_tbridge "https://github.com/snail007/goproxy/blob/master/services/tunnel_bridge.go"
click node_listener "https://github.com/snail007/goproxy/blob/master/utils/serve-channel.go"
click node_http_tools "https://github.com/snail007/goproxy/blob/master/utils/structs.go"
click node_routing "https://github.com/snail007/goproxy/blob/master/utils/structs.go"
click node_connections "https://github.com/snail007/goproxy/blob/master/utils/functions.go"
click node_udp_queue "https://github.com/snail007/goproxy/blob/master/services/tunnel_server.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_main,node_config,node_registry,node_client toneBlue
class node_http,node_tcp,node_udp,node_http_features toneAmber
class node_tclient,node_tserver,node_tbridge,node_udp_queue toneMint
class node_listener,node_http_tools,node_routing,node_connections toneRose
class node_destination,node_parent toneIndigo
```

## Components

### Startup and control

- [Process entry](https://github.com/snail007/goproxy/blob/master/main.go): `main.go`
- [CLI configuration](https://github.com/snail007/goproxy/blob/master/config.go): `config.go`
- [Service registry](https://github.com/snail007/goproxy/blob/master/services/service.go): `services/service.go`

### Proxy services

- [HTTP proxy](https://github.com/snail007/goproxy/blob/master/services/http.go): `services/http.go`
- [TCP proxy](https://github.com/snail007/goproxy/blob/master/services/tcp.go): `services/tcp.go`
- [UDP proxy](https://github.com/snail007/goproxy/blob/master/services/udp.go): `services/udp.go`
- [Documented protocols](https://github.com/snail007/goproxy/tree/master/services): `services`

### Tunnel services

- [Tunnel client](https://github.com/snail007/goproxy/blob/master/services/tunnel_client.go): `services/tunnel_client.go`
- [Tunnel server](https://github.com/snail007/goproxy/blob/master/services/tunnel_server.go): `services/tunnel_server.go`
- [Tunnel bridge](https://github.com/snail007/goproxy/blob/master/services/tunnel_bridge.go): `services/tunnel_bridge.go`
- [UDP work queue](https://github.com/snail007/goproxy/blob/master/services/tunnel_server.go): `services/tunnel_server.go`

### Runtime utilities

- [Network listeners](https://github.com/snail007/goproxy/blob/master/utils/serve-channel.go): `utils/serve-channel.go`
- [HTTP parsing and auth](https://github.com/snail007/goproxy/blob/master/utils/structs.go): `utils/structs.go`
- [Domain routing checks](https://github.com/snail007/goproxy/blob/master/utils/structs.go): `utils/structs.go`
- [Connection utilities](https://github.com/snail007/goproxy/blob/master/utils/functions.go): `utils/functions.go`

### Other components

- **Proxy client**
- **Target service**
- **Parent proxy**

## Connections

- Process entry → CLI configuration: loads configuration
- CLI configuration → Service registry: registers and runs
- Process entry → Service registry: cleans service
- Service registry → HTTP proxy: starts service
- Service registry → TCP proxy: starts service
- Service registry → UDP proxy: starts service
- Service registry → Tunnel client: starts service
- Service registry → Tunnel server: starts service
- Service registry → Tunnel bridge: starts service
- Proxy client → HTTP proxy: sends requests
- Proxy client → TCP proxy: opens connection
- Proxy client → UDP proxy: sends datagrams
- HTTP proxy → Network listeners: opens listener
- TCP proxy → Network listeners: opens listener
- UDP proxy → Network listeners: opens listener
- Network listeners → HTTP proxy: dispatches requests
- Network listeners → TCP proxy: dispatches connections
- Network listeners → UDP proxy: dispatches datagrams
- HTTP proxy → HTTP parsing and auth: parses and authenticates
- HTTP proxy → Domain routing checks: checks destination
- HTTP proxy → Connection utilities: connects and relays
- HTTP proxy → Parent proxy: forwards via parent
- HTTP proxy → Target service: forwards directly
- TCP proxy → Connection utilities: connects and relays
- TCP proxy → Parent proxy: forwards via parent
- TCP proxy → Target service: forwards to target
- UDP proxy → Parent proxy: forwards via parent
- UDP proxy → Target service: forwards datagrams
- Tunnel client → Parent proxy: opens TLS tunnel
- Tunnel client → Target service: relays to local target
- Tunnel server → Parent proxy: opens TLS tunnel
- Tunnel server → Network listeners: listens for tunnel traffic
- Tunnel server → UDP work queue: queues UDP packets
- UDP work queue → Parent proxy: sends tunneled packets
- Tunnel bridge → Network listeners: bridges traffic
- Documented protocols → HTTP proxy: includes documented modes
