Connection Lifecycle

The complete lifecycle of a tunneled connection.

Tunnel setup

  1. Agent connects to SERVER_IP:9000
  2. Agent sends the agent token for authentication
  3. Agent sends REGISTER <port>
  4. Server checks port availability and confirms
  5. Server starts listening on the public port

Incoming connection

  1. Public user connects to SERVER_IP:PUBLIC_PORT
  2. Server generates a UUID (e.g., 8bab2f9a-b0e2-4db2-8fed-9a8dda8e3aed)
  3. Server sends CONNECT <uuid> to the agent
  4. Agent connects to the local service on the target port
  5. Agent opens a new connection to SERVER_IP:9001
  6. Agent sends DATA <uuid>
  7. Server matches the UUID and bridges the connections
  8. Traffic flows bidirectionally
text
Public User <--> Server:PUBLIC_PORT <--> Server:9001 <--> Agent <--> Local Service

Teardown

  • When the public user disconnects, the data connection is closed
  • When the agent disconnects from the control channel, the server releases the public port and closes all associated data connections
  • Port ownership is removed, making the port available for other agents