package acme import ( "os" "github.com/go-acme/lego/v4/challenge" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/acme/cloudflare" E "github.com/sagernet/sing/common/exceptions" ) type Settings struct { Enabled bool `json:"enabled"` DataDirectory string `json:"data_directory"` Email string `json:"email"` DNSProvider string `json:"dns_provider"` DNSEnv *common.JSONMap `json:"dns_env"` } func (s *Settings) SetupEnvironment() error { for envName, envValue := range s.DNSEnv.Data { err := os.Setenv(envName, envValue.(string)) if err != nil { return err } } return nil } func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) { switch name { case "cloudflare": return cloudflare.NewDNSProvider() } // return dns.NewDNSChallengeProviderByName(name) return nil, E.New("unsupported dns provider ", name) }