Skip to content

Commit

Permalink
refract: move ddns module to pkg/
Browse files Browse the repository at this point in the history
  • Loading branch information
DarcJC committed Feb 26, 2024
1 parent db7bace commit 1f4b151
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion service/rpc/nezha.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package rpc
import (
"context"
"fmt"
"github.com/naiba/nezha/pkg/ddns"
"github.com/naiba/nezha/pkg/utils"
"github.com/naiba/nezha/service/singleton/ddns"
"log"
"time"

Expand Down
14 changes: 7 additions & 7 deletions service/singleton/ddns.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package singleton
import (
"errors"
"fmt"
"github.com/naiba/nezha/service/singleton/ddns"
ddns2 "github.com/naiba/nezha/pkg/ddns"
"log"
)

func RetryableUpdateDomain(provider ddns.Provider, config *ddns.DomainConfig, maxRetries int) bool {
func RetryableUpdateDomain(provider ddns2.Provider, config *ddns2.DomainConfig, maxRetries int) bool {
if nil == config {
return false
}
Expand All @@ -22,21 +22,21 @@ func RetryableUpdateDomain(provider ddns.Provider, config *ddns.DomainConfig, ma
return false
}

func GetDDNSProviderFromString(provider string) (ddns.Provider, error) {
func GetDDNSProviderFromString(provider string) (ddns2.Provider, error) {
switch provider {
case "webhook":
return ddns.ProviderWebHook{
return ddns2.ProviderWebHook{
URL: Conf.DDNS.WebhookURL,
RequestMethod: Conf.DDNS.WebhookMethod,
RequestBody: Conf.DDNS.WebhookRequestBody,
RequestHeader: Conf.DDNS.WebhookHeaders,
}, nil
case "dummy":
return ddns.ProviderDummy{}, nil
return ddns2.ProviderDummy{}, nil
case "cloudflare":
return ddns.ProviderCloudflare{
return ddns2.ProviderCloudflare{
Secret: Conf.DDNS.AccessSecret,
}, nil
}
return ddns.ProviderDummy{}, errors.New(fmt.Sprintf("无法找到配置的DDNS提供者%s", Conf.DDNS.Provider))
return ddns2.ProviderDummy{}, errors.New(fmt.Sprintf("无法找到配置的DDNS提供者%s", Conf.DDNS.Provider))
}

0 comments on commit 1f4b151

Please sign in to comment.