Documentation
¶
Overview ¶
Package bridgeclient is the daemon side of the bridge protocol: it connects an outbound websocket to ccproxy, accepts RPCs from the server, and executes them against the local filesystem rooted at --root.
Index ¶
- type Auditor
- type Client
- type ConfirmFunc
- type EventEmitter
- type FSHandlers
- func (h *FSHandlers) Chmod(_ context.Context, p bridge.ChmodParams) *bridge.RPCError
- func (h *FSHandlers) Create(_ context.Context, p bridge.CreateParams) *bridge.RPCError
- func (h *FSHandlers) Exec(ctx context.Context, p bridge.ExecParams) (bridge.ExecResult, *bridge.RPCError)
- func (h *FSHandlers) Mkdir(_ context.Context, p bridge.MkdirParams) *bridge.RPCError
- func (h *FSHandlers) Read(_ context.Context, p bridge.ReadParams) (bridge.ReadResult, *bridge.RPCError)
- func (h *FSHandlers) ReadDir(_ context.Context, p bridge.ReadDirParams) (bridge.ReadDirResult, *bridge.RPCError)
- func (h *FSHandlers) Remove(_ context.Context, p bridge.RemoveParams) *bridge.RPCError
- func (h *FSHandlers) Rename(_ context.Context, p bridge.RenameParams) *bridge.RPCError
- func (h *FSHandlers) Stat(_ context.Context, p bridge.StatParams) (bridge.StatResult, *bridge.RPCError)
- func (h *FSHandlers) Write(_ context.Context, p bridge.WriteParams) (bridge.WriteResult, *bridge.RPCError)
- type Handlers
- type IgnoreList
- type Options
- type StubHandlers
- func (StubHandlers) Chmod(context.Context, bridge.ChmodParams) *bridge.RPCError
- func (StubHandlers) Create(context.Context, bridge.CreateParams) *bridge.RPCError
- func (StubHandlers) Exec(context.Context, bridge.ExecParams) (bridge.ExecResult, *bridge.RPCError)
- func (StubHandlers) Mkdir(context.Context, bridge.MkdirParams) *bridge.RPCError
- func (StubHandlers) Read(context.Context, bridge.ReadParams) (bridge.ReadResult, *bridge.RPCError)
- func (StubHandlers) ReadDir(context.Context, bridge.ReadDirParams) (bridge.ReadDirResult, *bridge.RPCError)
- func (StubHandlers) Remove(context.Context, bridge.RemoveParams) *bridge.RPCError
- func (StubHandlers) Rename(context.Context, bridge.RenameParams) *bridge.RPCError
- func (StubHandlers) Stat(context.Context, bridge.StatParams) (bridge.StatResult, *bridge.RPCError)
- func (StubHandlers) Write(context.Context, bridge.WriteParams) (bridge.WriteResult, *bridge.RPCError)
- type TTYConfirm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auditor ¶
type Auditor struct {
// contains filtered or unexported fields
}
Auditor appends one JSON line per RPC to a log file. Best-effort: write errors are dropped so a misbehaving filesystem can't crash the daemon.
func NewAuditor ¶
NewAuditor opens the log at path (creating the directory if needed) in append mode. Pass an empty path to disable auditing — the returned Auditor will be a no-op.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a single bridge connection. Use Run to dial and serve until the context is cancelled or the server disconnects.
type ConfirmFunc ¶
ConfirmFunc is called before any write/exec RPC. Return false to deny. The op string is short and human-readable: "write", "remove", "exec", etc.
type EventEmitter ¶
type EventEmitter interface {
// contains filtered or unexported methods
}
EventEmitter is what the watcher uses to publish notifications back to the server. The daemon's connection (a *daemonSession) implements it.
type FSHandlers ¶
type FSHandlers struct {
Root string
MaxFileBytes int64 // reject reads above this; 0 = unlimited
Ignore *IgnoreList // optional; nil disables denylist
Confirm ConfirmFunc // optional; nil auto-approves
}
FSHandlers implements Handlers against a real filesystem rooted at Root. All input paths are interpreted relative to Root and clamped — any path that, after Clean+EvalSymlinks, escapes Root returns ErrCodeOutOfRoot.
func NewFSHandlers ¶
func NewFSHandlers(root string) *FSHandlers
NewFSHandlers builds an FSHandlers with a 32 MiB default file size limit.
func (*FSHandlers) Chmod ¶
func (h *FSHandlers) Chmod(_ context.Context, p bridge.ChmodParams) *bridge.RPCError
func (*FSHandlers) Create ¶
func (h *FSHandlers) Create(_ context.Context, p bridge.CreateParams) *bridge.RPCError
func (*FSHandlers) Exec ¶
func (h *FSHandlers) Exec(ctx context.Context, p bridge.ExecParams) (bridge.ExecResult, *bridge.RPCError)
func (*FSHandlers) Mkdir ¶
func (h *FSHandlers) Mkdir(_ context.Context, p bridge.MkdirParams) *bridge.RPCError
func (*FSHandlers) Read ¶
func (h *FSHandlers) Read(_ context.Context, p bridge.ReadParams) (bridge.ReadResult, *bridge.RPCError)
func (*FSHandlers) ReadDir ¶
func (h *FSHandlers) ReadDir(_ context.Context, p bridge.ReadDirParams) (bridge.ReadDirResult, *bridge.RPCError)
func (*FSHandlers) Remove ¶
func (h *FSHandlers) Remove(_ context.Context, p bridge.RemoveParams) *bridge.RPCError
func (*FSHandlers) Rename ¶
func (h *FSHandlers) Rename(_ context.Context, p bridge.RenameParams) *bridge.RPCError
func (*FSHandlers) Stat ¶
func (h *FSHandlers) Stat(_ context.Context, p bridge.StatParams) (bridge.StatResult, *bridge.RPCError)
func (*FSHandlers) Write ¶
func (h *FSHandlers) Write(_ context.Context, p bridge.WriteParams) (bridge.WriteResult, *bridge.RPCError)
type Handlers ¶
type Handlers interface {
Stat(ctx context.Context, p bridge.StatParams) (bridge.StatResult, *bridge.RPCError)
ReadDir(ctx context.Context, p bridge.ReadDirParams) (bridge.ReadDirResult, *bridge.RPCError)
Read(ctx context.Context, p bridge.ReadParams) (bridge.ReadResult, *bridge.RPCError)
Write(ctx context.Context, p bridge.WriteParams) (bridge.WriteResult, *bridge.RPCError)
Create(ctx context.Context, p bridge.CreateParams) *bridge.RPCError
Mkdir(ctx context.Context, p bridge.MkdirParams) *bridge.RPCError
Remove(ctx context.Context, p bridge.RemoveParams) *bridge.RPCError
Rename(ctx context.Context, p bridge.RenameParams) *bridge.RPCError
Chmod(ctx context.Context, p bridge.ChmodParams) *bridge.RPCError
Exec(ctx context.Context, p bridge.ExecParams) (bridge.ExecResult, *bridge.RPCError)
}
Handlers is the set of FS operations the daemon exposes. A stub is available via NewStubHandlers for protocol-only testing.
func NewStubHandlers ¶
func NewStubHandlers() Handlers
type IgnoreList ¶
type IgnoreList struct {
// contains filtered or unexported fields
}
IgnoreList is a glob-pattern allowlist/denylist read from a .ccproxyignore file at the daemon's root. It uses the same simplified semantics as .gitignore: blank lines and lines starting with `#` are comments; trailing slashes mark directory-only patterns; patterns are matched with filepath.Match against each path segment.
Defaults always denied even if no .ccproxyignore exists:
.ssh, .aws, .gnupg, id_rsa*, id_ed25519*, .env*
func LoadIgnore ¶
func LoadIgnore(root string) (*IgnoreList, error)
LoadIgnore reads .ccproxyignore from root (if present) and merges with the built-in deny list.
func (*IgnoreList) Match ¶
func (i *IgnoreList) Match(rel string) bool
Match reports whether rel (a path relative to root) hits any deny pattern. Hidden segments are matched independently so a pattern like `.ssh` denies `foo/.ssh/key`.
type Options ¶
type Options struct {
ServerURL string // wss://host/bridge
BearerToken string
Root string
AllowWrite bool
AllowExec bool
Version string
// PingInterval is how often the daemon sends application-level keepalives
// (server expects to see traffic regularly).
PingInterval time.Duration
// AuditPath, if non-empty, is the file the daemon appends one JSON
// line per RPC to (audit log).
AuditPath string
// Watch enables fsnotify-backed change detection that streams
// bridge.EventWatch frames back to the server.
Watch bool
}
Options configures a daemon Client.
type StubHandlers ¶
type StubHandlers struct{}
StubHandlers is a placeholder Handlers implementation that fails every call with ErrCodeUnsupported. Used to prove the protocol works before the real filesystem handlers land.
func (StubHandlers) Chmod ¶
func (StubHandlers) Chmod(context.Context, bridge.ChmodParams) *bridge.RPCError
func (StubHandlers) Create ¶
func (StubHandlers) Create(context.Context, bridge.CreateParams) *bridge.RPCError
func (StubHandlers) Exec ¶
func (StubHandlers) Exec(context.Context, bridge.ExecParams) (bridge.ExecResult, *bridge.RPCError)
func (StubHandlers) Mkdir ¶
func (StubHandlers) Mkdir(context.Context, bridge.MkdirParams) *bridge.RPCError
func (StubHandlers) Read ¶
func (StubHandlers) Read(context.Context, bridge.ReadParams) (bridge.ReadResult, *bridge.RPCError)
func (StubHandlers) ReadDir ¶
func (StubHandlers) ReadDir(context.Context, bridge.ReadDirParams) (bridge.ReadDirResult, *bridge.RPCError)
func (StubHandlers) Remove ¶
func (StubHandlers) Remove(context.Context, bridge.RemoveParams) *bridge.RPCError
func (StubHandlers) Rename ¶
func (StubHandlers) Rename(context.Context, bridge.RenameParams) *bridge.RPCError
func (StubHandlers) Stat ¶
func (StubHandlers) Stat(context.Context, bridge.StatParams) (bridge.StatResult, *bridge.RPCError)
func (StubHandlers) Write ¶
func (StubHandlers) Write(context.Context, bridge.WriteParams) (bridge.WriteResult, *bridge.RPCError)
type TTYConfirm ¶
type TTYConfirm struct {
// contains filtered or unexported fields
}
TTYConfirm prompts the user on stdin/stderr for each operation and returns the answer. Concurrent calls are serialized so prompts don't interleave.
func NewTTYConfirm ¶
func NewTTYConfirm() *TTYConfirm
NewTTYConfirm wires the prompt to stderr+stdin. Returns nil if stdin isn't a terminal (no point prompting nobody) — caller should fall back to auto-approve.
func (*TTYConfirm) Ask ¶
func (t *TTYConfirm) Ask(op, path string) bool
Ask blocks until the user answers y/Y or n/N. Default is no.