tunnelcat-sdk docs
Docs / Testing / Mock server

Mock Server

cmd/mockserver is a local mock control/exit server for testing SDK adapters (and tunneld itself) with zero real credentials and zero network access.

What it does

It implements just enough of the wire protocol to satisfy Authenticator.Login() and one round of data-plane traffic:

  • Auth: accepts any username/password/apikey on verifyPassword and authenticateKey — quoting its own source comment, "this is a mock — it does no real authentication." Issues a random 32-hex-char session token.
  • Data plane: relays one round of decrypted upload-frame traffic to the real TCP target the client requested, using tunnelcat-server's exported crypto helpers (SessionKey, OpenFrame, ParseUploadFrame, BuildUploadResponse) rather than reimplementing the framing — the relay logic mirrors tunnelcat-server's own tunnel_test.go stub server.
Polling mode only

It only implements the polling side of the wire protocol — stream-open frames get a 404. This is why every SDK example passes pollingOnly: true. Don't take that as the recommended production setting: a real control/exit server should implement streaming (see Wire Protocol · Data plane) for efficiency. Polling exists as the simpler, legacy fallback.

Run it

go run ./cmd/mockserver             # listens on 127.0.0.1:8443 by default
go run ./cmd/mockserver -addr 127.0.0.1:9000   # custom address

Point any adapter at it

Use http://127.0.0.1:8443 (note: http, not https — the mock doesn't terminate TLS) as the server parameter in any language's connect() call, with pollingOnly: true and any non-empty username/password:

{"server": "http://127.0.0.1:8443", "apikey": "x", "username": "u", "password": "p", "socksAddr": "127.0.0.1:1080", "pollingOnly": true}

This is exactly the request in IPC Protocol's example session — the mock server is the reference target every adapter's own example/test uses.

When you're done with it

The mock server is a development and CI convenience, not a staging environment — it has no persistence, no multi-session isolation beyond what the wire protocol itself provides, and (again) no streaming support. Point at a real tunnelcat-server control/exit node before shipping.