How nicocha30/ligolo-ng works
Ligolo-ng is a reverse TCP/TLS tunneling tool: a local network tool sends traffic through a TUN interface, a userland stack translates it into remote connections, and an agent relays those connections to its reachable network. The proxy also manages agent sessions, listeners, interfaces/routes, configuration, and a web/API surface. The README documents the packet-to-agent workflow; source excerpts show session handling and selected component calls. Some command, API, and platform-specific wiring is not fully sampled, so those links are omitted or marked unverified.
Main entry points: app.go CLI and tunnels · main.go Proxy runtime · handlers.go TCP UDP ICMP · handler.go Agent handler
Components 18
Runtime entrypoints
- Agent runtime
cmd/agent/main.go - Proxy runtime
cmd/proxy/main.go
Agent sessions
- Connection listener
pkg/controller/controller.go - Agent handler
pkg/agent/handler.go - Packet protocol
pkg/protocol/packets.go - Stream relays
pkg/relay/relay.go - Agent sessions
pkg/controller/agent.go - TLS certificates
pkg/tlsutils/certmanager.go
Tunnel datapath
- TUN interface
pkg/proxy/netstack/tun/gvisor.go - Userland stack
pkg/proxy/netstack/stack.go - TCP UDP ICMP
pkg/proxy/netstack/handlers.go
Proxy management
- CLI and tunnels
cmd/proxy/app/app.go - Web and API
cmd/proxy/app/daemon.go - Proxy configuration
cmd/proxy/config/config.go - Agent listeners
pkg/proxy/listeners.go
Host networking
- Route management
pkg/proxy/netinfo/netinfo.go - Interface commands
cmd/proxy/app/interfaces.go
Other components
- Network tool
Connections 25
- Network tool → TUN interface: sends packets
- TUN interface → Userland stack: feeds packets
pkg/proxy/netstack/stack.go - Userland stack → TCP UDP ICMP: dispatches flows
pkg/proxy/netstack/stack.go - TCP UDP ICMP → Agent handler: relays connections
- Agent handler → Packet protocol: encodes messages
pkg/agent/handler.go - Agent handler → Stream relays: starts relays
pkg/agent/handler.go - Proxy runtime → Connection listener: starts listener
cmd/proxy/main.go - Connection listener → TLS certificates: loads certificates
pkg/controller/controller.go - Proxy runtime → CLI and tunnels: runs commands
cmd/proxy/main.go - Proxy runtime → Agent sessions: registers agents
cmd/proxy/main.go - Agent runtime → Agent handler: handles session
cmd/agent/main.go - CLI and tunnels → Agent sessions: manages sessions
- Agent sessions → Packet protocol: requests agent info
pkg/controller/agent.go - CLI and tunnels → Userland stack: starts tunnels
cmd/proxy/app/app.go - TCP UDP ICMP → Packet protocol: encodes flows
pkg/proxy/netstack/handlers.go - TCP UDP ICMP → Stream relays: relays streams
pkg/proxy/netstack/handlers.go - CLI and tunnels → Agent listeners: adds listeners
- Agent listeners → Packet protocol: sends requests
pkg/proxy/listeners.go - Agent listeners → Stream relays: forwards sockets
pkg/proxy/listeners.go - CLI and tunnels → Proxy configuration: uses settings
cmd/proxy/app/app.go - CLI and tunnels → Route management: manages tunnel interface
cmd/proxy/app/app.go - Interface commands → Route management: configures routes
cmd/proxy/app/interfaces.go - Interface commands → Proxy configuration: stores interface settings
cmd/proxy/app/interfaces.go - Proxy runtime → Web and API: starts API
- Web and API → Proxy configuration: updates settings
cmd/proxy/app/daemon.go