controld

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonTokenInvalid      = "token_invalid"
	ReasonTokenExpired      = "token_expired"
	ReasonTokenLimitReached = "token_limit_reached"
	ReasonTokenDisabled     = "token_disabled"
)

Provisioning-token rejection reasons the API sends in error.metadata.reason (HTTP 400, code 40003). This list can grow; a value outside it is not an error, just one cmd/cli does not classify yet.

View Source
const (
	// SplitDNSModeOS resolves the domain through the endpoint's own OS/default
	// resolver, so it follows DHCP and VPN resolver changes.
	SplitDNSModeOS = "os"
	// SplitDNSModeResolvers resolves the domain through the addresses in
	// Resolvers first. When none of them answers, or they answer SERVFAIL or
	// NXDOMAIN, the query falls back to the resolvers of the endpoint's active
	// network and VPN. This is the default explicit selection.
	SplitDNSModeResolvers = "resolvers"
	// SplitDNSModeResolversOnly resolves the domain through the addresses in
	// Resolvers and nothing else: their answer, or their failure, is final.
	SplitDNSModeResolversOnly = "resolvers_only"
)

Internal Domain resolution modes. Mode is what the administrator selected; Resolvers is only meaningful under SplitDNSModeResolvers and SplitDNSModeResolversOnly.

View Source
const (
	InvalidConfigCode = 40402
)

Variables

This section is empty.

Functions

func DoWithFallbackForTest added in v1.5.6

func DoWithFallbackForTest(client *http.Client, req *http.Request, apiIp string) (*http.Response, error)

DoWithFallbackForTest exposes doWithFallback so tests outside this package can drive the real two-attempt composition through the real retry predicate, rather than asserting a copy of this error shape against another copy of it.

func ParseRawUID added in v1.3.0

func ParseRawUID(rawUID string) (string, string)

ParseRawUID parse the input raw UID, returning real UID and ClientID. The raw UID can have 2 forms:

- <uid> - <uid>/<client_id>

func ProbeReachability added in v1.5.8

func ProbeReachability(ctx context.Context, cdDev bool) error

ProbeReachability makes one lightweight request to the ControlD API host, reusing the same transport and IP-fallback logic real provisioning traffic takes. Any HTTP response, even an error status, counts as reachable: this checks the network path, not whether the endpoint accepts the request.

The caller controls how long to wait via ctx; there is no timeout here beyond what ctx enforces.

func SendLogs added in v1.4.0

func SendLogs(ctx context.Context, lr *LogsRequest, cdDev bool) error

SendLogs sends runtime log to ControlD API.

Types

type ErrorResponse added in v1.4.0

type ErrorResponse struct {
	ErrorField struct {
		Message  string        `json:"message"`
		Code     int           `json:"code"`
		Metadata errorMetadata `json:"metadata"`
	} `json:"error"`
	// StatusCode is the HTTP status the API answered with. It is not part of the JSON
	// body: this type is built for *any* non-200 whose body decodes, so the body alone
	// cannot tell a permanent rejection of the request from a transient server-side
	// failure, and callers that act differently on the two need the status to tell them
	// apart. Zero means the status was not recorded.
	StatusCode int `json:"-"`
}

func (ErrorResponse) Error added in v1.4.0

func (u ErrorResponse) Error() string

type LogsRequest added in v1.4.0

type LogsRequest struct {
	UID  string        `json:"uid"`
	Data io.ReadCloser `json:"-"`
}

LogsRequest contains request data for sending runtime logs to API.

type ResolverConfig

type ResolverConfig struct {
	DOH   string `json:"doh"`
	Ctrld struct {
		CustomConfig     string `json:"custom_config"`
		CustomLastUpdate int64  `json:"custom_last_update"`
		VersionTarget    string `json:"version_target"`
	} `json:"ctrld"`
	Exclude         []string   `json:"exclude"`
	SplitDNS        []SplitDNS `json:"split_dns"`
	UID             string     `json:"uid"`
	DeactivationPin *int64     `json:"deactivation_pin,omitempty"`
}

ResolverConfig represents Control D resolver data.

func FetchResolverConfig

func FetchResolverConfig(ctx context.Context, req *ResolverConfigRequest, cdDev bool) (*ResolverConfig, error)

FetchResolverConfig fetch Control D config for given uid.

func FetchResolverUID added in v1.3.0

func FetchResolverUID(ctx context.Context, req *UtilityOrgRequest, version string, cdDev bool) (*ResolverConfig, error)

FetchResolverUID fetch resolver uid from a given request.

func UpdateCustomLastFailed added in v1.3.8

func UpdateCustomLastFailed(ctx context.Context, rawUID, version string, cdDev, lastUpdatedFailed bool) (*ResolverConfig, error)

UpdateCustomLastFailed calls API to mark custom config is bad.

type ResolverConfigRequest added in v1.4.9

type ResolverConfigRequest struct {
	RawUID   string
	Version  string
	Metadata map[string]string
}

ResolverConfigRequest contains request data for fetching resolver config.

type SplitDNS added in v1.5.8

type SplitDNS struct {
	Domain    string   `json:"domain"`
	Mode      string   `json:"mode"`
	Resolvers []string `json:"resolvers"`
}

SplitDNS is one organization Internal Domain: a domain suffix, the resolution mode the organization administrator selected for it, and the resolver addresses that mode may need.

Mode decides the routing. Resolvers is read only under the explicit modes, so addresses left behind by an earlier selection cannot resurrect themselves once the administrator switches back to the OS resolver. An empty Mode is a deployment that predates the field; the caller infers the mode from Resolvers in that case.

type UtilityOrgRequest added in v1.3.10

type UtilityOrgRequest struct {
	ProvToken string            `json:"prov_token"`
	Hostname  string            `json:"hostname"`
	Metadata  map[string]string `json:"metadata"`
}

UtilityOrgRequest contains request data for calling Org API.

Jump to

Keyboard shortcuts

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