How 1catai/1cat-tunnel works
1Cat Tunnel is a reverse-access tunnel: an administrator issues a node credential, a client registers its local TCP/UDP presets over an outbound control connection, and the server allocates public listeners. External traffic triggers a client-side connection to the local service and is forwarded through a separate data channel. The README also documents a Web console, restart-restored mappings and counters, and platform-specific client setup and management. The root server/client are explicitly historical 0.1.2 code; the newer client lives under client/. Server internals were only partially sampled, so uncertain handler and persistence wiring is not shown.
Main entry points: client.go Client session runtime · server.go Server control and tunnels · main.go Client entry · tunnel.go Public tunnel listeners
Components 20
Client runtime
- Client entry
cmd/tunnel-client/main.go - Client session runtime
internal/client/client.go - Client configuration
internal/client/config.go - First-run setup
internal/client/client.go - Windows service
client/internal/winclient/service_windows.go - Config and logging utilities
internal/launcher/launcher.go
Server runtime
- Server entry
cmd/tunnel-server/main.go - Server control and tunnels
internal/server/server.go - Server configuration
internal/server/config.go - Public tunnel listeners
internal/server/tunnel.go
Tunnel protocol
- Control and attach messages
internal/common/protocol.go
Management and state
- Server HTTP console
internal/server/http.go - Admin dashboard
internal/server/dashboard.go - Persisted server state
internal/server/state.go - Local management panel
client/internal/client/management_web.go - Panel authentication
client/internal/client/management_auth.go
Other components
- Administrator
- Client operator
- External TCP/UDP users
- Local services
Connections 24
- Administrator → Server HTTP console: manages nodes
- Server entry → Server configuration: loads configuration
- Server entry → Server control and tunnels: starts server
- Server control and tunnels → Server HTTP console: serves console
- Server HTTP console → Admin dashboard: renders console
- Server control and tunnels → Persisted server state: restores and saves
- Server control and tunnels → Control and attach messages: exchanges messages
- Server control and tunnels → Public tunnel listeners: creates listeners
- External TCP/UDP users → Public tunnel listeners: connects to ports
- Client operator → Client entry: starts client
- Client entry → Config and logging utilities: resolves configuration
- Client entry → Client configuration: loads configuration
- Client entry → First-run setup: starts setup
- First-run setup → Client configuration: saves presets
- Client entry → Client session runtime: runs client
- Windows service → Client session runtime: runs as service
- Client session runtime → Server control and tunnels: registers and reconnects
- Client session runtime → Control and attach messages: exchanges control and attach
- Server control and tunnels → Client session runtime: requests connections
- Client session runtime → Local services: dials local preset
- Public tunnel listeners → Client session runtime: forwards data channel
- Client session runtime → Local management panel: starts local panel
- Local management panel → Panel authentication: authenticates requests
- Client operator → Local management panel: views status