Documentation
¶
Overview ¶
Package attach starts one client command with its model traffic routed through the Accordion Context proxy, without touching the client's own configuration (spec §19.9, "Escada automática de integração").
The ladder tries these degrees in order and uses the first one that is verified:
- base-url-env: the profile's base URL variable points at the proxy. For a command without a known profile (console mode), every known base URL variable is set at once, together with the MITM variables.
- base-url-flag and temp-config: the profile's command-line flag, or a temporary config file in a per-run 0700 directory, carries the base URL. Only a matched profile that declares them is tried. A profile with quirks.ignores_base_url skips degrees 1 and 2.
- mitm: HTTPS_PROXY points at the in-process MITM listener and the CA bundle variables trust the per-install CA, for this process only.
Each degree is verified before the client starts. acd-ctx sends probe requests along the path the client's environment or arguments would use (the base URL, or HTTPS_PROXY plus the CA bundle). The listener answers a probe itself, without contacting any upstream, and a degree counts as working only when its probes arrive. The client then runs once with the winning environment and arguments. Requests the client sends are counted in Result.Hits. A client's own use of the integration cannot be probed before it runs, so Hits reports it after.
The proxy runs in-process on a loopback port that lives as long as the command, so the hit counter sits on the real handler. An interrupt during the checks ends the run, and the temp files are removed on every exit path.
The --system-proxy and --transparent degrees (spec §19.9, degrees 6 and 7) change machine-wide settings. They are off by default and need --yes, see system.go.
Index ¶
Constants ¶
const ( DegreeBaseURL = "base-url-env" DegreeFlag = "base-url-flag" DegreeTempConfig = "temp-config" DegreeConsole = "console" DegreeMITM = "mitm" DegreeSystemProxy = "system-proxy" DegreeTransparent = "transparent" )
Degree names, as reported in Result.Degree and Attempt.Degree.
Variables ¶
This section is empty.
Functions ¶
func BaseURLVars ¶
BaseURLVars lists the base URL variables of every profile, for console mode and for the doctor. Duplicates are removed; order follows the profiles.
Types ¶
type Attempt ¶
type Attempt struct {
Degree string
OK bool
Reason string // "verified" on success, otherwise why the degree failed
}
Attempt records one degree of the ladder.
type Options ¶
type Options struct {
// Args is the client command. Args[0] selects a profile by name; an
// unmatched command runs in console mode.
Args []string
// Cwd is the project directory. Empty means the process working directory.
Cwd string
// Markers are the project root markers. Nil means the proxy defaults.
Markers []string
// Profiles are extra declarative profiles (launcher.LoadProfiles). They
// are matched before the built-in profiles.
Profiles []launcher.Profile
// DBPath is the SQLite database of the in-process proxy. Required.
DBPath string
// CADir holds the per-install CA. Required for the mitm degree.
CADir string
// Version is reported by the in-process proxy.
Version string
// MITMDomains are extra exact host names to intercept. The upstream hosts
// of every profile are always included.
MITMDomains []string
// SystemProxy and Transparent select the machine-wide degrees (degree 6
// and degree 7). System holds their options and consent. See system.go.
SystemProxy bool
Transparent bool
System *SystemOptions
// Environ is the base environment. Nil means os.Environ().
Environ []string
// Stdin, Stdout and Stderr are the client's streams. Nil uses the
// os/exec defaults (no input, discarded output).
Stdin io.Reader
Stdout, Stderr io.Writer
// Dial reaches upstream hosts and blind tunnels. Nil means the default
// dialer with the mitm loopback guard. Tests set it to stay offline.
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
// ProbeTimeout bounds each probe. Zero means 5s.
ProbeTimeout time.Duration
// Logger receives proxy diagnostics. Nil discards them.
Logger *slog.Logger
// contains filtered or unexported fields
}
Options configures one attach run. Args is required.
type Result ¶
type Result struct {
Degree string
Attempts []Attempt
ExitCode int
// Hits counts client requests that reached the proxy handler.
Hits int64
Notes []string
}
Result reports the chosen degree and the outcome of the client run.
type SystemOptions ¶
type SystemOptions struct {
// Yes is the explicit consent (--yes). Required for both degrees.
Yes bool
// Apply installs the transparent rules. Without it they are only printed.
Apply bool
// UID is the user whose TCP 443 traffic is redirected. A negative value
// means SUDO_UID from the environment.
UID int
// AllDestinations redirects all TCP 443 traffic of UID, not only the
// connections to the MITM domains (--all-443).
AllDestinations bool
// NoPeerAuth is --i-understand-no-peer-auth. It is needed on platforms
// without a peer-uid check, where any local process can use the listener.
NoPeerAuth bool
// DataDirExplicit says the data directory was chosen by the user
// (ACD_CTX_DB) instead of derived from HOME. It is one of the two things
// that make --transparent under sudo safe when HOME is not the user's.
DataDirExplicit bool
// StateDir holds the state files. Empty means "sysproxy" beside the database.
StateDir string
// Env gives access to commands and to the machine. It is required, and
// the CLI sets the real runner in it.
Env *sysproxy.Env
}
SystemOptions configures the machine-wide degrees (spec §19.9, degrees 6 and 7). Both are off by default. They change settings that other programs use, so both refuse without Yes, and the state they change is saved and restored.