# phuslu/liner architecture

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

- Interactive diagram: https://gitdiagram.com/phuslu/liner
- Repository: https://github.com/phuslu/liner
- Video tour (about a minute): https://gitdiagram.com/phuslu/liner/video

## Overview

Liner appears to be a configurable network proxy and tunneling server: clients enter through DNS, HTTP, SOCKS, SSH, transparent-proxy, or TUN interfaces, and traffic can be forwarded through selectable dialers. Its HTTP web handlers also provide site content and ancillary services. The README supplies no capability detail; the graph relies on the sampled handler excerpts and the limited main.go excerpt, so unsampled configuration and routing links are omitted.

Main entry points: [`handler_dns.go`](https://github.com/phuslu/liner/blob/master/handler_dns.go) (DNS handler), [`handler_http_web.go`](https://github.com/phuslu/liner/blob/master/handler_http_web.go) (Web handler), [`handler_tun.go`](https://github.com/phuslu/liner/blob/master/handler_tun.go) (TUN handler), [`main.go`](https://github.com/phuslu/liner/blob/master/main.go) (Server setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime setup"]
  node_main["Server setup<br/>[main.go]"]
end

subgraph group_ingress["Client ingress"]
  node_dns_handler["DNS handler<br/>[handler_dns.go]"]
  node_http_forward["HTTP forward proxy"]
  node_http_tunnel["HTTP tunnel"]
  node_socks["SOCKS proxy<br/>[handler_socks.go]"]
  node_ssh["SSH server<br/>[handler_ssh.go]"]
  node_tproxy["Transparent proxy<br/>[handler_tproxy.go]"]
  node_tun["TUN handler<br/>[handler_tun.go]"]
end

subgraph group_web["HTTP web services"]
  node_http_server["HTTP server<br/>[handler_http.go]"]
  node_web_handler["Web handler"]
  node_web_index["Web content"]
  node_web_proxy["Web reverse proxy"]
  node_web_cgi["CGI service"]
  node_web_dav["WebDAV service"]
  node_web_doh["DNS-over-HTTPS"]
  node_web_logtail["Log tail"]
  node_web_shell["Web shell"]
end

subgraph group_transport["Forwarding transports"]
  node_dialers["Dialer implementations<br/>[dialer_http3.go]"]
  node_tunnel_transports["Tunnel transports<br/>[handler_tunnel.go]"]
end

subgraph group_support["Resolution and support"]
  node_functions["Template functions<br/>[functions.go]"]
  node_dns_resolver["DNS resolver pool<br/>[resolver_dns.go]"]
  node_geo_resolver["Geo resolver<br/>[resolver_geo.go]"]
  node_process_darwin["Process lookup &#40;Darwin&#41;"]
  node_process_linux["Process lookup &#40;Linux&#41;"]
  node_process_windows["Process lookup &#40;Windows&#41;"]
end

node_client(("Network clients"))
node_upstream(("Upstream network services"))

node_client -->|"queries"| node_dns_handler
node_client -->|"proxies requests"| node_http_forward
node_client -->|"opens tunnel"| node_http_tunnel
node_client -->|"opens proxy"| node_socks
node_client -->|"opens session"| node_ssh
node_client -->|"sends traffic"| node_tproxy
node_client -->|"sends packets"| node_tun
node_client -.->|"requests content"| node_http_server
node_main -->|"creates resolver"| node_dns_resolver
node_main -->|"configures TUN"| node_tun
node_dns_handler -->|"selects upstream"| node_dns_resolver
node_dns_handler -->|"forwards queries"| node_upstream
node_http_forward -.->|"dials target"| node_dialers
node_http_tunnel -->|"opens streams"| node_upstream
node_socks -->|"dials target"| node_upstream
node_tproxy -->|"dials target"| node_upstream
node_tun -->|"forwards traffic"| node_upstream
node_http_server -.->|"serves requests"| node_web_handler
node_web_handler -.->|"serves content"| node_web_index
node_web_handler -.->|"dispatches proxy"| node_web_proxy

click node_main "https://github.com/phuslu/liner/blob/master/main.go"
click node_dns_handler "https://github.com/phuslu/liner/blob/master/handler_dns.go"
click node_http_forward "https://github.com/phuslu/liner/blob/master/handler_http_forward.go"
click node_http_tunnel "https://github.com/phuslu/liner/blob/master/handler_http_tunnel.go"
click node_socks "https://github.com/phuslu/liner/blob/master/handler_socks.go"
click node_ssh "https://github.com/phuslu/liner/blob/master/handler_ssh.go"
click node_tproxy "https://github.com/phuslu/liner/blob/master/handler_tproxy.go"
click node_tun "https://github.com/phuslu/liner/blob/master/handler_tun.go"
click node_http_server "https://github.com/phuslu/liner/blob/master/handler_http.go"
click node_web_handler "https://github.com/phuslu/liner/blob/master/handler_http_web.go"
click node_web_index "https://github.com/phuslu/liner/blob/master/handler_http_web_index.go"
click node_web_proxy "https://github.com/phuslu/liner/blob/master/handler_http_web_proxy.go"
click node_web_cgi "https://github.com/phuslu/liner/blob/master/handler_http_web_cgi.go"
click node_web_dav "https://github.com/phuslu/liner/blob/master/handler_http_web_dav.go"
click node_web_doh "https://github.com/phuslu/liner/blob/master/handler_http_web_doh.go"
click node_web_logtail "https://github.com/phuslu/liner/blob/master/handler_http_web_logtail.go"
click node_web_shell "https://github.com/phuslu/liner/blob/master/handler_http_web_shell.go"
click node_dialers "https://github.com/phuslu/liner/blob/master/dialer_http3.go"
click node_tunnel_transports "https://github.com/phuslu/liner/blob/master/handler_tunnel.go"
click node_functions "https://github.com/phuslu/liner/blob/master/functions.go"
click node_dns_resolver "https://github.com/phuslu/liner/blob/master/resolver_dns.go"
click node_geo_resolver "https://github.com/phuslu/liner/blob/master/resolver_geo.go"
click node_process_darwin "https://github.com/phuslu/liner/blob/master/processinfo_darwin.go"
click node_process_linux "https://github.com/phuslu/liner/blob/master/processinfo_linux.go"
click node_process_windows "https://github.com/phuslu/liner/blob/master/processinfo_windows.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_client toneBlue
class node_dns_handler,node_http_forward,node_http_tunnel,node_socks,node_ssh,node_tproxy,node_tun toneAmber
class node_http_server,node_web_handler,node_web_index,node_web_proxy,node_web_cgi,node_web_dav,node_web_doh,node_web_logtail,node_web_shell toneMint
class node_dialers,node_tunnel_transports toneRose
class node_functions,node_dns_resolver,node_geo_resolver,node_process_darwin,node_process_linux,node_process_windows,node_upstream toneIndigo
```

## Components

### Runtime setup

- [Server setup](https://github.com/phuslu/liner/blob/master/main.go): `main.go`

### Client ingress

- [DNS handler](https://github.com/phuslu/liner/blob/master/handler_dns.go): `handler_dns.go`
- [HTTP forward proxy](https://github.com/phuslu/liner/blob/master/handler_http_forward.go): `handler_http_forward.go`
- [HTTP tunnel](https://github.com/phuslu/liner/blob/master/handler_http_tunnel.go): `handler_http_tunnel.go`
- [SOCKS proxy](https://github.com/phuslu/liner/blob/master/handler_socks.go): `handler_socks.go`
- [SSH server](https://github.com/phuslu/liner/blob/master/handler_ssh.go): `handler_ssh.go`
- [Transparent proxy](https://github.com/phuslu/liner/blob/master/handler_tproxy.go): `handler_tproxy.go`
- [TUN handler](https://github.com/phuslu/liner/blob/master/handler_tun.go): `handler_tun.go`

### HTTP web services

- [HTTP server](https://github.com/phuslu/liner/blob/master/handler_http.go): `handler_http.go`
- [Web handler](https://github.com/phuslu/liner/blob/master/handler_http_web.go): `handler_http_web.go`
- [Web content](https://github.com/phuslu/liner/blob/master/handler_http_web_index.go): `handler_http_web_index.go`
- [Web reverse proxy](https://github.com/phuslu/liner/blob/master/handler_http_web_proxy.go): `handler_http_web_proxy.go`
- [CGI service](https://github.com/phuslu/liner/blob/master/handler_http_web_cgi.go): `handler_http_web_cgi.go`
- [WebDAV service](https://github.com/phuslu/liner/blob/master/handler_http_web_dav.go): `handler_http_web_dav.go`
- [DNS-over-HTTPS](https://github.com/phuslu/liner/blob/master/handler_http_web_doh.go): `handler_http_web_doh.go`
- [Log tail](https://github.com/phuslu/liner/blob/master/handler_http_web_logtail.go): `handler_http_web_logtail.go`
- [Web shell](https://github.com/phuslu/liner/blob/master/handler_http_web_shell.go): `handler_http_web_shell.go`

### Forwarding transports

- [Dialer implementations](https://github.com/phuslu/liner/blob/master/dialer_http3.go): `dialer_http3.go`
- [Tunnel transports](https://github.com/phuslu/liner/blob/master/handler_tunnel.go): `handler_tunnel.go`

### Resolution and support

- [Template functions](https://github.com/phuslu/liner/blob/master/functions.go): `functions.go`
- [DNS resolver pool](https://github.com/phuslu/liner/blob/master/resolver_dns.go): `resolver_dns.go`
- [Geo resolver](https://github.com/phuslu/liner/blob/master/resolver_geo.go): `resolver_geo.go`
- [Process lookup (Darwin)](https://github.com/phuslu/liner/blob/master/processinfo_darwin.go): `processinfo_darwin.go`
- [Process lookup (Linux)](https://github.com/phuslu/liner/blob/master/processinfo_linux.go): `processinfo_linux.go`
- [Process lookup (Windows)](https://github.com/phuslu/liner/blob/master/processinfo_windows.go): `processinfo_windows.go`

### Other components

- **Network clients**
- **Upstream network services**

## Connections

- Network clients → DNS handler: queries (evidence: `handler_dns.go`)
- Network clients → HTTP forward proxy: proxies requests (evidence: `handler_http_forward.go`)
- Network clients → HTTP tunnel: opens tunnel (evidence: `handler_http_tunnel.go`)
- Network clients → SOCKS proxy: opens proxy (evidence: `handler_socks.go`)
- Network clients → SSH server: opens session (evidence: `handler_ssh.go`)
- Network clients → Transparent proxy: sends traffic (evidence: `handler_tproxy.go`)
- Network clients → TUN handler: sends packets (evidence: `handler_tun.go`)
- Network clients → HTTP server: requests content
- Server setup → DNS resolver pool: creates resolver (evidence: `main.go`)
- Server setup → TUN handler: configures TUN (evidence: `main.go`)
- DNS handler → DNS resolver pool: selects upstream (evidence: `handler_dns.go`)
- DNS handler → Upstream network services: forwards queries (evidence: `handler_dns.go`)
- HTTP forward proxy → Dialer implementations: dials target
- HTTP tunnel → Upstream network services: opens streams (evidence: `handler_http_tunnel.go`)
- SOCKS proxy → Upstream network services: dials target (evidence: `handler_socks.go`)
- Transparent proxy → Upstream network services: dials target (evidence: `handler_tproxy.go`)
- TUN handler → Upstream network services: forwards traffic (evidence: `handler_tun.go`)
- HTTP server → Web handler: serves requests
- Web handler → Web content: serves content
- Web handler → Web reverse proxy: dispatches proxy
