Documentation
¶
Index ¶
- Constants
- func DoWithFallbackForTest(client *http.Client, req *http.Request, apiIp string) (*http.Response, error)
- func ParseRawUID(rawUID string) (string, string)
- func ProbeReachability(ctx context.Context, cdDev bool) error
- func SendLogs(ctx context.Context, lr *LogsRequest, cdDev bool) error
- type ErrorResponse
- type LogsRequest
- type ResolverConfig
- func FetchResolverConfig(ctx context.Context, req *ResolverConfigRequest, cdDev bool) (*ResolverConfig, error)
- func FetchResolverUID(ctx context.Context, req *UtilityOrgRequest, version string, cdDev bool) (*ResolverConfig, error)
- func UpdateCustomLastFailed(ctx context.Context, rawUID, version string, cdDev, lastUpdatedFailed bool) (*ResolverConfig, error)
- type ResolverConfigRequest
- type SplitDNS
- type UtilityOrgRequest
Constants ¶
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.
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.
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
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
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.
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
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.