carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1// Package controlsock names the root instance-control channel (design
2// §5). It is a leaf package with no internal imports so both
3// internal/provision and internal/unixdial can depend on it without an
4// import cycle: provision already imports internal/release (for the
5// store), and internal/release's unix dial sites need
6// unixdial.Checked — which must know the control endpoint's path
7// without pulling provision (and therefore release) back in.
8package controlsock
9
10import (
11 "path/filepath"
12 "strings"
13)
14
15// Dir and Path are the root instance-control channel (design §5).
16// Deliberately NOT under provision.SocketDir: an instance's namespace
17// replaces /run/carlos with an empty tmpfs, and nothing an instance can
18// reach must resolve to this path.
19const (
20 Dir = "/run/carlos-control"
21 Path = Dir + "/control.sock"
22)
23
24// IsEndpoint reports whether path is the control channel or anything
25// else under its directory. The edge and the agent refuse to dial such a
26// path as an upstream (design §5.4): a registry row pointing at it is
27// refused before connect().
28func IsEndpoint(path string) bool {
29 clean := filepath.Clean(path)
30 return clean == Dir || strings.HasPrefix(clean, Dir+"/")
31}
32