mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
ddns: support provider hurricane electric (#1036)
This commit is contained in:
@@ -202,5 +202,5 @@ func batchDeleteDDNS(c *gin.Context) (any, error) {
|
||||
// @Success 200 {object} model.CommonResponse[[]string]
|
||||
// @Router /ddns/providers [get]
|
||||
func listProviders(c *gin.Context) ([]string, error) {
|
||||
return model.ProviderList, nil
|
||||
return model.ProviderList[:], nil
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -18,6 +18,7 @@ require (
|
||||
github.com/knadh/koanf/providers/file v1.1.2
|
||||
github.com/knadh/koanf/v2 v2.1.2
|
||||
github.com/libdns/cloudflare v0.1.3
|
||||
github.com/libdns/he v1.0.2
|
||||
github.com/libdns/libdns v0.2.3
|
||||
github.com/miekg/dns v1.1.63
|
||||
github.com/nezhahq/libdns-tencentcloud v0.0.0-20241029120103-889957240fff
|
||||
@@ -83,6 +84,7 @@ require (
|
||||
golang.org/x/mod v0.23.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/time v0.6.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
4
go.sum
4
go.sum
@@ -100,6 +100,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/libdns/cloudflare v0.1.3 h1:XPFa2f3Mm/3FDNwl9Ki2bfAQJ0Cm5GQB0e8PQVy25Us=
|
||||
github.com/libdns/cloudflare v0.1.3/go.mod h1:XbvSCSMcxspwpSialM3bq0LsS3/Houy9WYxW8Ok8b6M=
|
||||
github.com/libdns/he v1.0.2 h1:AUlHRkRyVCsoaifIXZRoH9dn+nj0MXXwLMvPV4OlNdk=
|
||||
github.com/libdns/he v1.0.2/go.mod h1:jkxQM4jPhj0H64JTgBTB05LDELsqWIRxXk9SzPh6++M=
|
||||
github.com/libdns/libdns v0.2.3 h1:ba30K4ObwMGB/QTmqUxf3H4/GmUrCAIkMWejeGl12v8=
|
||||
github.com/libdns/libdns v0.2.3/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ=
|
||||
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
||||
@@ -223,6 +225,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
|
||||
@@ -10,10 +10,11 @@ const (
|
||||
ProviderWebHook = "webhook"
|
||||
ProviderCloudflare = "cloudflare"
|
||||
ProviderTencentCloud = "tencentcloud"
|
||||
ProviderHE = "he"
|
||||
)
|
||||
|
||||
var ProviderList = []string{
|
||||
ProviderDummy, ProviderWebHook, ProviderCloudflare, ProviderTencentCloud,
|
||||
var ProviderList = [...]string{
|
||||
ProviderDummy, ProviderWebHook, ProviderCloudflare, ProviderTencentCloud, ProviderHE,
|
||||
}
|
||||
|
||||
type DDNSProfile struct {
|
||||
|
||||
@@ -239,7 +239,7 @@ func (s *NezhaHandler) ReportGeoIP(c context.Context, r *pb.GeoIP) (*pb.GeoIP, e
|
||||
ipv6 := geoip.IP.IPv6Addr
|
||||
|
||||
dnsServers := strings.Split(singleton.Conf.DNSServers, ",")
|
||||
ctx := context.WithValue(context.Background(), ddns.DNSServerKey{}, utils.IfOr(len(dnsServers) > 0, dnsServers, utils.DNSServers))
|
||||
ctx := context.WithValue(context.Background(), ddns.DNSServerKey{}, utils.IfOr(dnsServers[0] != "", dnsServers, utils.DNSServers))
|
||||
|
||||
providers, err := singleton.DDNSShared.GetDDNSProvidersFromProfiles(server.DDNSProfiles, &model.IP{IPv4Addr: ipv4, IPv6Addr: ipv6})
|
||||
if err == nil {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/libdns/cloudflare"
|
||||
"github.com/libdns/he"
|
||||
tencentcloud "github.com/nezhahq/libdns-tencentcloud"
|
||||
|
||||
"github.com/nezhahq/nezha/model"
|
||||
@@ -85,6 +86,9 @@ func (c *DDNSClass) GetDDNSProvidersFromProfiles(profileId []uint64, ip *model.I
|
||||
case model.ProviderTencentCloud:
|
||||
provider.Setter = &tencentcloud.Provider{SecretId: profile.AccessID, SecretKey: profile.AccessSecret}
|
||||
providers = append(providers, provider)
|
||||
case model.ProviderHE:
|
||||
provider.Setter = &he.Provider{APIKey: profile.AccessSecret}
|
||||
providers = append(providers, provider)
|
||||
default:
|
||||
return nil, fmt.Errorf("无法找到配置的DDNS提供者 %s", profile.Provider)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user