go

module
v0.0.0-...-632f32b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT

README

ccfly Go control service

The local control service behind the ccfly CLI. It:

  • tails the Claude Code jsonl transcripts under ~/.claude,
  • drives the session's tmux pane,
  • serves a local HTTP/WS API consumed by @ccfly/react,
  • serves its own terminal WebSocket at GET /term?session=<tmux>[&cwd=&cmd=]: a PTY running tmux new-session -A -s <session> speaking a ttyd-compatible frame protocol (handshake {AuthToken,columns,rows}, '0'=output/input, '1'=resize). The live terminal mirror needs no external ttyd.

Build

go build -o ../bin/ccfly ./cmd/ccfly

or from the repo root:

pnpm build:go

Verify the SNI egress environment

When the cloud has assigned this device an SNI exit, the local control API can run a fresh production-path check:

curl -sS 'http://127.0.0.1:7699/sni-status?probe=1'

probe.path_ok is true only when the local interception is armed, the in-band nonce response identifies the configured overlay node and account exit, and a separate real upstream TLS handshake succeeds. In Linux instance images, capture_mode is container_dns: Docker fixes the only resolver to 127.0.0.1, intercepted A answers resolve to loopback, and the authorized tcp4 127.0.0.1:443 relay is checked end to end. target_node, target_exit_id, target_identity, and bound_egress_ipv4 explain the observed selection when diagnosing a mismatch.

Mesh endpoint failover

CCFLY_MESH_ENDPOINTS optionally supplies an ordered JSON list of mesh endpoints. url remains the WebSocket Host and TLS certificate identity; dial_addr optionally selects a different TCP destination. The cloud-provided mesh_url is always appended as the final compatibility fallback.

CCFLY_MESH_ENDPOINTS='[{"url":"wss://114.132.213.6/mesh","dial_addr":"138.252.163.7:443"}]'

Each endpoint is attempted in order. A failed or disconnected preferred route falls through to the next entry without changing the device identity or mesh token. A malformed override is ignored so the legacy route remains available.

Distribution

CI cross-compiles this into per-platform binaries and packs each into an @ccfly/cli-<os>-<cpu> npm subpackage under ../npm/. The ccfly npm package pulls in the matching one via optionalDependencies. See ../npm/README.md.

Module path: github.com/jsdvjx/ccfly/go (matches the GitHub remote github.com/jsdvjx/ccfly).

Directories

Path Synopsis
cmd
ccfly command
Command ccfly is the local control service for Claude Code sessions.
Command ccfly is the local control service for Claude Code sessions.
ccfly-hostd command
Command ccfly-hostd is the ccfly host agent.
Command ccfly-hostd is the ccfly host agent.
ccfly-mesh command
Command ccfly-mesh is a minimal, mesh-only ccfly client for servers that just need to join the overlay (组网) — e.g.
Command ccfly-mesh is a minimal, mesh-only ccfly client for servers that just need to join the overlay (组网) — e.g.
internal
cloudhttp
Package cloudhttp 是设备 agent 与 ccfly-cloud 之间所有直连流量(配对/控制面/mesh WSS/ 会话同步/claude login)共用的 HTTP 客户端。
Package cloudhttp 是设备 agent 与 ccfly-cloud 之间所有直连流量(配对/控制面/mesh WSS/ 会话同步/claude login)共用的 HTTP 客户端。
hostagent
Package hostagent 实现 ccfly 主机代理(ccfly-hostd)的控制面:一个很小的 HTTP 接口 (spawn / stop / clear-data / instances),由 ccfly-hostd 经 overlay expose 桥暴露给 cloud 调用, 据此在本 VM 上 `docker run` 每用户的 ccfly 实例容器。
Package hostagent 实现 ccfly 主机代理(ccfly-hostd)的控制面:一个很小的 HTTP 接口 (spawn / stop / clear-data / instances),由 ccfly-hostd 经 overlay expose 桥暴露给 cloud 调用, 据此在本 VM 上 `docker run` 每用户的 ccfly 实例容器。
mesh
Package mesh — overlay TCP port bridges.
Package mesh — overlay TCP port bridges.
profile
Package profile 定义 ccfly 的运行期「能力档」(即用户类型):
Package profile 定义 ccfly 的运行期「能力档」(即用户类型):
svc
Package svc installs a ccfly binary as a persistent OS service so a device stays joined to the overlay across terminal close / logout / reboot / sleep (macOS launchd, Linux systemd).
Package svc installs a ccfly binary as a persistent OS service so a device stays joined to the overlay across terminal close / logout / reboot / sleep (macOS launchd, Linux systemd).
tmuxbin
Package tmuxbin 让 mac 用户不用自装 tmux:darwin 构建把一个「可移植 tmux」 (libevent/ncursesw 静态链接,只依赖 libSystem;见 scripts/build-tmux-macos.sh) 用 go:embed 嵌进 ccfly 主二进制,运行时在系统找不到 tmux 时释放到 ~/.ccfly/bin/tmux。
Package tmuxbin 让 mac 用户不用自装 tmux:darwin 构建把一个「可移植 tmux」 (libevent/ncursesw 静态链接,只依赖 libSystem;见 scripts/build-tmux-macos.sh) 用 go:embed 嵌进 ccfly 主二进制,运行时在系统找不到 tmux 时释放到 ~/.ccfly/bin/tmux。
winexec
Package winexec 把 Windows 自带命令解析成绝对路径。
Package winexec 把 Windows 自带命令解析成绝对路径。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL