123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package acme
- import (
- "errors"
- "log"
- "os"
- "strings"
- "github.com/go-acme/lego/v4/challenge"
- "imuslab.com/zoraxy/mod/acme/acmedns"
- )
- func GetDnsChallengeProviderByName(dnsProvider string, dnsCredentials string) (challenge.Provider, error) {
-
-
-
- return acmedns.GetDNSProviderByJsonConfig(dnsProvider, dnsCredentials)
- }
- func setCredentialsIntoEnvironmentVariables(credentials map[string]string) {
- for key, value := range credentials {
- err := os.Setenv(key, value)
- if err != nil {
- log.Println("[ERR] Failed to set environment variable %s: %v", key, err)
- } else {
- log.Println("[INFO] Environment variable %s set successfully", key)
- }
- }
- }
- func extractDnsCredentials(input string) (map[string]string, error) {
- result := make(map[string]string)
-
- lines := strings.Split(input, "\n")
-
- for _, line := range lines {
-
-
- parts := strings.SplitN(line, "=", 1)
-
- if len(parts) == 2 {
- key := strings.TrimSpace(parts[0])
- value := strings.TrimSpace(parts[1])
-
- result[key] = value
- if value == "" || key == "" {
-
- return result, errors.New("DNS credential extract failed")
- }
- }
- }
- return result, nil
- }
|