mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 06:40:26 +08:00
优化代码
This commit is contained in:
1
internal/dnsclients/.gitignore
vendored
Normal file
1
internal/dnsclients/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*_plus_test.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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 查找服务商名称
|
||||
|
||||
15
internal/dnsclients/types_ext.go
Normal file
15
internal/dnsclients/types_ext.go
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user