mirror of
https://github.com/usual2970/certimate.git
synced 2025-09-20 23:16:00 +00:00
.github
.vscode
docker
internal
applicant
aliyun.go
applicant.go
aws.go
cloudflare.go
godaddy.go
httpreq.go
huaweicloud.go
namesilo.go
pdns.go
tencent.go
deployer
domain
domains
notify
repository
rest
routes
utils
migrations
ui
.dockerignore
.editorconfig
.gitignore
.goreleaser.yml
CHANGELOG.md
CONTRIBUTING.md
CONTRIBUTING_EN.md
Dockerfile_build
LICENSE.md
Makefile
README.md
README_EN.md
go.mod
go.sum
main.go
nixpacks.toml
usage.gif
37 lines
692 B
Go
37 lines
692 B
Go
package applicant
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
|
|
cf "github.com/go-acme/lego/v4/providers/dns/cloudflare"
|
|
|
|
"certimate/internal/domain"
|
|
)
|
|
|
|
type cloudflare struct {
|
|
option *ApplyOption
|
|
}
|
|
|
|
func NewCloudflare(option *ApplyOption) Applicant {
|
|
return &cloudflare{
|
|
option: option,
|
|
}
|
|
}
|
|
|
|
func (c *cloudflare) Apply() (*Certificate, error) {
|
|
access := &domain.CloudflareAccess{}
|
|
json.Unmarshal([]byte(c.option.Access), access)
|
|
|
|
os.Setenv("CLOUDFLARE_DNS_API_TOKEN", access.DnsApiToken)
|
|
os.Setenv("CLOUDFLARE_PROPAGATION_TIMEOUT", fmt.Sprintf("%d", c.option.Timeout))
|
|
|
|
provider, err := cf.NewDNSProvider()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return apply(c.option, provider)
|
|
}
|