Documentation
¶
Index ¶
- Constants
- Variables
- func IsCloudflareIP(ipAddress string) (ret bool, err error)
- type ApiError
- type ApiResponse
- type Client
- func (client *Client) CreateCustomHostname(ctx context.Context, zone, hostname string) (hostnameID string, err error)
- func (client *Client) DeleteCustomHostname(ctx context.Context, zone, hostnameID string) (err error)
- func (client *Client) GetCloudflareIps(ctx context.Context) (res CloudflareIpsResult, err error)
- func (client *Client) GetCustomHostnameDetails(ctx context.Context, zone, hostnameID string) (res CustomHostname, err error)
- func (client *Client) PurgeCache(ctx context.Context, zone string, input PurgeCacheRequest) (res PurgeCacheResponse, err error)
- func (client *Client) VerifyTurnstileToken(ctx context.Context, input TurnstileVerifyRequest) (res TurnstileVerifyResponse, err error)
- type CloudflareIpsResult
- type CustomHostname
- type CustomHostnameOwnershipVerification
- type CustomHostnameOwnershipVerificationHTTP
- type CustomHostnameSSL
- type CustomHostnameSSLCertificates
- type CustomHostnameSSLSettings
- type CustomHostnameStatus
- type CustomMetadata
- type PurgeCacheRequest
- type PurgeCacheResponse
- type SSLValidationError
- type SSLValidationRecord
- type TurnstileVerifyRequest
- type TurnstileVerifyResponse
Constants ¶
const TurnstileDevSecretKey = "1x0000000000000000000000000000000AA"
TurnstileDevSecretKey must ONLY BE USED during development it will always return "success": true
const TurnstileDevSiteKey = "1x00000000000000000000AA"
TurnstileDevSiteKey must ONLY BE USED during development it will always pass
Variables ¶
var IpsJson []byte
Functions ¶
func IsCloudflareIP ¶
TODO: return error?
Types ¶
type ApiResponse ¶
type ApiResponse struct { Result json.RawMessage `json:"result"` Success bool `json:"success"` Errors []ApiError `json:"errors"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateCustomHostname ¶
func (client *Client) CreateCustomHostname(ctx context.Context, zone, hostname string) (hostnameID string, err error)
https://developers.cloudflare.com/api/operations/custom-hostname-for-a-zone-create-custom-hostname
func (*Client) DeleteCustomHostname ¶
func (*Client) GetCloudflareIps ¶
func (client *Client) GetCloudflareIps(ctx context.Context) (res CloudflareIpsResult, err error)
Fetch the IPs used on the Cloudflare network Ips are fetched from https://api.cloudflare.com/client/v4/ips and can be formated using | python3 -m json.tool Changelog: https://www.cloudflare.com/en-gb/ips/ API Docs: https://developers.cloudflare.com/api/operations/cloudflare-i-ps-cloudflare-ip-details
func (*Client) GetCustomHostnameDetails ¶
func (client *Client) GetCustomHostnameDetails(ctx context.Context, zone, hostnameID string) (res CustomHostname, err error)
https://developers.cloudflare.com/api/operations/custom-hostname-for-a-zone-custom-hostname-details
func (*Client) PurgeCache ¶
func (client *Client) PurgeCache(ctx context.Context, zone string, input PurgeCacheRequest) (res PurgeCacheResponse, err error)
func (*Client) VerifyTurnstileToken ¶
func (client *Client) VerifyTurnstileToken(ctx context.Context, input TurnstileVerifyRequest) (res TurnstileVerifyResponse, err error)
https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
type CloudflareIpsResult ¶
type CloudflareIpsResult struct { Ipv4Cidrs []string `json:"ipv4_cidrs"` Ipv6Cidrs []string `json:"ipv6_cidrs"` Etag string `json:"etag"` }
CustomHostnameOwnershipVerificationHTTP represents a response from the Custom Hostnames endpoints.
type CustomHostname ¶
type CustomHostname struct { ID string `json:"id,omitempty"` Hostname string `json:"hostname,omitempty"` CustomOriginServer string `json:"custom_origin_server,omitempty"` CustomOriginSNI string `json:"custom_origin_sni,omitempty"` SSL *CustomHostnameSSL `json:"ssl,omitempty"` CustomMetadata CustomMetadata `json:"custom_metadata,omitempty"` Status CustomHostnameStatus `json:"status,omitempty"` VerificationErrors []string `json:"verification_errors,omitempty"` OwnershipVerification CustomHostnameOwnershipVerification `json:"ownership_verification,omitempty"` OwnershipVerificationHTTP CustomHostnameOwnershipVerificationHTTP `json:"ownership_verification_http,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` }
CustomHostname represents a custom hostname in a zone.
type CustomHostnameOwnershipVerification ¶
type CustomHostnameOwnershipVerification struct { Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` }
CustomHostnameOwnershipVerification represents ownership verification status of a given custom hostname.
type CustomHostnameOwnershipVerificationHTTP ¶
type CustomHostnameOwnershipVerificationHTTP struct { HTTPUrl string `json:"http_url,omitempty"` HTTPBody string `json:"http_body,omitempty"` }
CustomHostnameOwnershipVerificationHTTP represents a response from the Custom Hostnames endpoints.
type CustomHostnameSSL ¶
type CustomHostnameSSL struct { ID string `json:"id,omitempty"` Status string `json:"status,omitempty"` Method string `json:"method,omitempty"` Type string `json:"type,omitempty"` Wildcard *bool `json:"wildcard,omitempty"` CustomCertificate string `json:"custom_certificate,omitempty"` CustomKey string `json:"custom_key,omitempty"` CertificateAuthority string `json:"certificate_authority,omitempty"` Issuer string `json:"issuer,omitempty"` SerialNumber string `json:"serial_number,omitempty"` Settings CustomHostnameSSLSettings `json:"settings,omitempty"` Certificates []CustomHostnameSSLCertificates `json:"certificates,omitempty"` // Deprecated: use ValidationRecords. // If there a single validation record, this will equal ValidationRecords[0] for backwards compatibility. SSLValidationRecord ValidationRecords []SSLValidationRecord `json:"validation_records,omitempty"` ValidationErrors []SSLValidationError `json:"validation_errors,omitempty"` }
CustomHostnameSSL represents the SSL section in a given custom hostname.
type CustomHostnameSSLCertificates ¶
type CustomHostnameSSLCertificates struct { Issuer string `json:"issuer"` SerialNumber string `json:"serial_number"` Signature string `json:"signature"` ExpiresOn *time.Time `json:"expires_on"` IssuedOn *time.Time `json:"issued_on"` FingerprintSha256 string `json:"fingerprint_sha256"` ID string `json:"id"` }
CustomHostnameSSLCertificates represent certificate properties like issuer, expires date and etc.
type CustomHostnameSSLSettings ¶
type CustomHostnameSSLSettings struct { HTTP2 string `json:"http2,omitempty"` HTTP3 string `json:"http3,omitempty"` TLS13 string `json:"tls_1_3,omitempty"` MinTLSVersion string `json:"min_tls_version,omitempty"` Ciphers []string `json:"ciphers,omitempty"` EarlyHints string `json:"early_hints,omitempty"` }
CustomHostnameSSLSettings represents the SSL settings for a custom hostname.
type CustomHostnameStatus ¶
type CustomHostnameStatus string
CustomHostnameStatus is the enumeration of valid state values in the CustomHostnameSSL.
const ( // PENDING status represents state of CustomHostname is pending. PENDING CustomHostnameStatus = "pending" // ACTIVE status represents state of CustomHostname is active. ACTIVE CustomHostnameStatus = "active" // MOVED status represents state of CustomHostname is moved. MOVED CustomHostnameStatus = "moved" // DELETED status represents state of CustomHostname is removed. DELETED CustomHostnameStatus = "deleted" )
type CustomMetadata ¶
CustomMetadata defines custom metadata for the hostname. This requires logic to be implemented by Cloudflare to act on the data provided.
type PurgeCacheRequest ¶
type PurgeCacheRequest struct {
PurgeEverything bool `json:"purge_everything"`
}
type PurgeCacheResponse ¶
type PurgeCacheResponse struct {
ID string `json:"id"`
}
type SSLValidationError ¶
type SSLValidationError struct {
Message string `json:"message,omitempty"`
}
SSLValidationError represents errors that occurred during SSL validation.
type SSLValidationRecord ¶
type SSLValidationRecord struct { CnameTarget string `json:"cname_target,omitempty"` CnameName string `json:"cname,omitempty"` TxtName string `json:"txt_name,omitempty"` TxtValue string `json:"txt_value,omitempty"` HTTPUrl string `json:"http_url,omitempty"` HTTPBody string `json:"http_body,omitempty"` Emails []string `json:"emails,omitempty"` }
SSLValidationRecord displays Domain Control Validation tokens.