lansync

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package lansync implements cct's experimental device-to-device session sync over a local network. It is the project's only feature that sends session data off the machine, so it is strictly opt-in, peer-to-peer (no server/relay/cloud), refuses non-private addresses by default, and authenticates the peer with a high-entropy pairing code before any data moves.

Security model (stdlib only, no PAKE/mDNS dependency):

  • The channel is TLS with per-process self-signed certificates (mutual auth). Trust is NOT delegated to a CA.
  • The pairing code is a freshly generated ~96-bit secret shown by the serving side. Both sides derive a key from it and exchange an HMAC confirmation bound to BOTH TLS certificate fingerprints (channel binding). A man-in-the- middle terminates TLS separately with each side, so the fingerprints it presents differ from the real ones; without the code it cannot forge the confirmation, and the code's entropy makes offline guessing infeasible.

The actual session transfer reuses the existing, tested bundle export/import (+ --merge) path verbatim, so all checksum/manifest/conflict/mtime guarantees carry over unchanged.

Index

Constants

View Source
const ExperimentalNotice = "EXPERIMENTAL: cct sync sends your sessions over the local network to a paired device.\n" +
	"It talks only to a peer you confirm with a one-time code, never to a server or the internet,\n" +
	"and refuses non-private addresses. Re-run with --i-understand to proceed."

ExperimentalNotice is shown before every run because sync sends data off-machine.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Tool        agent.Kind      // codex or claude
	ClaudeHome  claudehome.Home // used to scan when Tool == claude
	ProjectPath string          // absolute; "" means all in-scope sessions
	Port        int             // serve: listen port (0 = OS-assigned)
	Code        string          // connect: the pairing code shown by the peer
	AllowPublic bool            // override the private-address guard
	PullOnly    bool            // do not send my sessions
	PushOnly    bool            // do not apply received sessions
	DryRun      bool            // exchange manifests and preview only; write nothing
	Confirmed   bool            // the experimental --i-understand gate
	Out         io.Writer       // progress/UX output
	// MapCWD / MapCWDHere / HereDir remap a received session's recorded cwd as it
	// is applied, so a peer's project that lives at a different path here still
	// lands under the right local project (and, for Claude, the right sidebar
	// group). Same semantics as on import.
	MapCWD     []bundle.CWDMapping
	MapCWDHere bool
	HereDir    string
}

Options configures one LAN sync run.

type Result

type Result struct {
	PeerHost    string
	Sent        int
	Received    bundle.ImportResult
	DryRun      bool
	PreviewSend int
	PreviewRecv int
}

Result summarizes a sync from the local side's perspective.

func Connect

func Connect(home codexhome.Home, opts Options, hostport string) (Result, error)

Connect dials a peer and syncs using the code the peer displayed.

func Serve

func Serve(home codexhome.Home, opts Options) (Result, error)

Serve waits for one peer to connect, authenticates it with a freshly generated pairing code, and syncs. home is the import target (for Claude, a codexhome.Home whose Root is the Claude home root).

Jump to

Keyboard shortcuts

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