diff --git a/internal/dnsclients/.gitignore b/internal/dnsclients/.gitignore new file mode 100644 index 00000000..a13429ee --- /dev/null +++ b/internal/dnsclients/.gitignore @@ -0,0 +1 @@ +*_plus_test.go \ No newline at end of file diff --git a/internal/dnsclients/provider_cloud_flare.go b/internal/dnsclients/provider_cloud_flare.go index ab643f67..51a1f675 100644 --- a/internal/dnsclients/provider_cloud_flare.go +++ b/internal/dnsclients/provider_cloud_flare.go @@ -279,15 +279,15 @@ func (this *CloudFlareProvider) doAPI(method string, apiPath string, args map[st return errors.New("invalid response status '" + strconv.Itoa(resp.StatusCode) + "', response '" + string(data) + "'") } - err = json.Unmarshal(data, respPtr) - if err != nil { - return err - } - if resp.StatusCode != http.StatusOK { return errors.New("response error: " + string(data)) } + err = json.Unmarshal(data, respPtr) + if err != nil { + return errors.New("decode json failed: " + err.Error() + ", response text: " + string(data)) + } + return nil } diff --git a/internal/dnsclients/types.go b/internal/dnsclients/types.go index 51e6c804..487a6e38 100644 --- a/internal/dnsclients/types.go +++ b/internal/dnsclients/types.go @@ -1,7 +1,6 @@ package dnsclients import ( - teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/iwind/TeaGo/maps" ) @@ -49,21 +48,7 @@ func FindAllProviderTypes() []maps.Map { }, } - if teaconst.IsPlus { - typeMaps = append(typeMaps, []maps.Map{ - { - "name": "EdgeDNS", - "code": ProviderTypeLocalEdgeDNS, - "description": "GoEdge商业版提供的智能DNS服务。", - }, - // TODO 需要实现用户使用AccessId/AccessKey来连接DNS服务 - /**{ - "name": "用户EdgeDNS", - "code": ProviderTypeUserEdgeDNS, - "description": "通过API连接企业版提供的DNS服务。", - },**/ - }...) - } + typeMaps = filterTypeMaps(typeMaps) typeMaps = append(typeMaps, maps.Map{ "name": "自定义HTTP DNS", @@ -91,7 +76,8 @@ func FindProvider(providerType ProviderType) ProviderInterface { case ProviderTypeCustomHTTP: return &CustomHTTPProvider{} } - return nil + + return filterProvider(providerType) } // FindProviderTypeName 查找服务商名称 diff --git a/internal/dnsclients/types_ext.go b/internal/dnsclients/types_ext.go new file mode 100644 index 00000000..fdcfe29b --- /dev/null +++ b/internal/dnsclients/types_ext.go @@ -0,0 +1,15 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. +//go:build !plus +// +build !plus + +package dnsclients + +import "github.com/iwind/TeaGo/maps" + +func filterTypeMaps(typeMaps []maps.Map) []maps.Map { + return typeMaps +} + +func filterProvider(providerType string) ProviderInterface { + return nil +}