mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 10:00:24 +08:00
实现基本的集群DNS列表、设置、简单数据同步
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
@@ -133,32 +134,20 @@ func (this *DNSDomainDAO) UpdateDomainData(domainId int64, data string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新服务相关域名
|
// 更新域名解析记录
|
||||||
func (this *DNSDomainDAO) UpdateServerDomains(domainId int64, serverDomainsJSON []byte) error {
|
func (this *DNSDomainDAO) UpdateDomainRecords(domainId int64, recordsJSON []byte) error {
|
||||||
if domainId <= 0 {
|
if domainId <= 0 {
|
||||||
return errors.New("invalid domainId")
|
return errors.New("invalid domainId")
|
||||||
}
|
}
|
||||||
op := NewDNSDomainOperator()
|
op := NewDNSDomainOperator()
|
||||||
op.Id = domainId
|
op.Id = domainId
|
||||||
op.ServerDomains = serverDomainsJSON
|
op.Records = recordsJSON
|
||||||
_, err := this.Save(op)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新集群相关域名
|
|
||||||
func (this *DNSDomainDAO) UpdateClusterDomains(domainId int64, clusterDomainJSON []byte) error {
|
|
||||||
if domainId <= 0 {
|
|
||||||
return errors.New("invalid domainId")
|
|
||||||
}
|
|
||||||
op := NewDNSDomainOperator()
|
|
||||||
op.Id = domainId
|
|
||||||
op.ClusterDomains = clusterDomainJSON
|
|
||||||
_, err := this.Save(op)
|
_, err := this.Save(op)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新线路
|
// 更新线路
|
||||||
func (this *DNSDomainDAO) UpdateRoutes(domainId int64, routesJSON []byte) error {
|
func (this *DNSDomainDAO) UpdateDomainRoutes(domainId int64, routesJSON []byte) error {
|
||||||
if domainId <= 0 {
|
if domainId <= 0 {
|
||||||
return errors.New("invalid domainId")
|
return errors.New("invalid domainId")
|
||||||
}
|
}
|
||||||
@@ -168,3 +157,23 @@ func (this *DNSDomainDAO) UpdateRoutes(domainId int64, routesJSON []byte) error
|
|||||||
_, err := this.Save(op)
|
_, err := this.Save(op)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查找域名线路
|
||||||
|
func (this *DNSDomainDAO) FindDomainRoutes(domainId int64) ([]string, error) {
|
||||||
|
routes, err := this.Query().
|
||||||
|
Pk(domainId).
|
||||||
|
Result("routes").
|
||||||
|
FindStringCol("")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(routes) == 0 || routes == "null" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
result := []string{}
|
||||||
|
err = json.Unmarshal([]byte(routes), &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ type DNSDomain struct {
|
|||||||
Name string `field:"name"` // 域名
|
Name string `field:"name"` // 域名
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据更新时间
|
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据更新时间
|
||||||
|
DataError string `field:"dataError"` // 数据更新错误
|
||||||
Data string `field:"data"` // 原始数据信息
|
Data string `field:"data"` // 原始数据信息
|
||||||
ServerDomains string `field:"serverDomains"` // 服务相关子域名
|
Records string `field:"records"` // 所有解析记录
|
||||||
ClusterDomains string `field:"clusterDomains"` // 集群相关域名
|
|
||||||
Routes string `field:"routes"` // 线路数据
|
Routes string `field:"routes"` // 线路数据
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
@@ -24,9 +24,9 @@ type DNSDomainOperator struct {
|
|||||||
Name interface{} // 域名
|
Name interface{} // 域名
|
||||||
CreatedAt interface{} // 创建时间
|
CreatedAt interface{} // 创建时间
|
||||||
DataUpdatedAt interface{} // 数据更新时间
|
DataUpdatedAt interface{} // 数据更新时间
|
||||||
|
DataError interface{} // 数据更新错误
|
||||||
Data interface{} // 原始数据信息
|
Data interface{} // 原始数据信息
|
||||||
ServerDomains interface{} // 服务相关子域名
|
Records interface{} // 所有解析记录
|
||||||
ClusterDomains interface{} // 集群相关域名
|
|
||||||
Routes interface{} // 线路数据
|
Routes interface{} // 线路数据
|
||||||
State interface{} // 状态
|
State interface{} // 状态
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,3 +120,14 @@ func (this *DNSProviderDAO) ListEnabledDNSProviders(offset int64, size int64) (r
|
|||||||
FindAll()
|
FindAll()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询某个类型下的所有服务商
|
||||||
|
func (this *DNSProviderDAO) FindAllEnabledDNSProvidersWithType(providerType string) (result []*DNSProvider, err error) {
|
||||||
|
_, err = this.Query().
|
||||||
|
State(DNSProviderStateEnabled).
|
||||||
|
Attr("type", providerType).
|
||||||
|
DescPk().
|
||||||
|
Slice(&result).
|
||||||
|
FindAll()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -297,6 +297,34 @@ func (this *NodeClusterDAO) CountAllEnabledClustersWithDNSDomainId(dnsDomainId i
|
|||||||
Count()
|
Count()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询使用某个DNS域名的集群ID列表
|
||||||
|
func (this *NodeClusterDAO) FindAllEnabledClusterIdsWithDNSDomainId(dnsDomainId int64) ([]int64, error) {
|
||||||
|
ones, err := this.Query().
|
||||||
|
State(NodeClusterStateEnabled).
|
||||||
|
Attr("dnsDomainId", dnsDomainId).
|
||||||
|
ResultPk().
|
||||||
|
FindAll()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := []int64{}
|
||||||
|
for _, one := range ones {
|
||||||
|
result = append(result, int64(one.(*NodeCluster).Id))
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询使用某个DNS域名的所有集群域名
|
||||||
|
func (this *NodeClusterDAO) FindAllEnabledClustersWithDNSDomainId(dnsDomainId int64) (result []*NodeCluster, err error) {
|
||||||
|
_, err = this.Query().
|
||||||
|
State(NodeClusterStateEnabled).
|
||||||
|
Attr("dnsDomainId", dnsDomainId).
|
||||||
|
Result("id", "name", "dnsName").
|
||||||
|
Slice(&result).
|
||||||
|
FindAll()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 查找集群的认证ID
|
// 查找集群的认证ID
|
||||||
func (this *NodeClusterDAO) FindClusterGrantId(clusterId int64) (int64, error) {
|
func (this *NodeClusterDAO) FindClusterGrantId(clusterId int64) (int64, error) {
|
||||||
return this.Query().
|
return this.Query().
|
||||||
@@ -309,7 +337,7 @@ func (this *NodeClusterDAO) FindClusterGrantId(clusterId int64) (int64, error) {
|
|||||||
func (this *NodeClusterDAO) FindClusterDNSInfo(clusterId int64) (*NodeCluster, error) {
|
func (this *NodeClusterDAO) FindClusterDNSInfo(clusterId int64) (*NodeCluster, error) {
|
||||||
one, err := this.Query().
|
one, err := this.Query().
|
||||||
Pk(clusterId).
|
Pk(clusterId).
|
||||||
Result("dnsName", "dnsDomain", "dnsProviderId").
|
Result("dnsName", "dnsDomainId").
|
||||||
Find()
|
Find()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -320,6 +348,29 @@ func (this *NodeClusterDAO) FindClusterDNSInfo(clusterId int64) (*NodeCluster, e
|
|||||||
return one.(*NodeCluster), nil
|
return one.(*NodeCluster), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查某个子域名是否可用
|
||||||
|
func (this *NodeClusterDAO) ExistClusterDNSName(dnsName string, excludeClusterId int64) (bool, error) {
|
||||||
|
return this.Query().
|
||||||
|
Attr("dnsName", dnsName).
|
||||||
|
State(NodeClusterStateEnabled).
|
||||||
|
Where("id!=:clusterId").
|
||||||
|
Param("clusterId", excludeClusterId).
|
||||||
|
Exist()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改集群DNS相关信息
|
||||||
|
func (this *NodeClusterDAO) UpdateClusterDNS(clusterId int64, dnsName string, dnsDomainId int64) error {
|
||||||
|
if clusterId <= 0 {
|
||||||
|
return errors.New("invalid clusterId")
|
||||||
|
}
|
||||||
|
op := NewNodeClusterOperator()
|
||||||
|
op.Id = clusterId
|
||||||
|
op.DnsName = dnsName
|
||||||
|
op.DnsDomainId = dnsDomainId
|
||||||
|
_, err := this.Save(op)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// 生成唯一ID
|
// 生成唯一ID
|
||||||
func (this *NodeClusterDAO) genUniqueId() (string, error) {
|
func (this *NodeClusterDAO) genUniqueId() (string, error) {
|
||||||
for {
|
for {
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func (this *NodeIPAddressDAO) UpdateAddressNodeId(addressId int64, nodeId int64)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找某个节点所有的IP地址
|
// 查找节点的所有的IP地址
|
||||||
func (this *NodeIPAddressDAO) FindAllEnabledAddressesWithNode(nodeId int64) (result []*NodeIPAddress, err error) {
|
func (this *NodeIPAddressDAO) FindAllEnabledAddressesWithNode(nodeId int64) (result []*NodeIPAddress, err error) {
|
||||||
_, err = this.Query().
|
_, err = this.Query().
|
||||||
Attr("nodeId", nodeId).
|
Attr("nodeId", nodeId).
|
||||||
@@ -136,3 +136,15 @@ func (this *NodeIPAddressDAO) FindAllEnabledAddressesWithNode(nodeId int64) (res
|
|||||||
FindAll()
|
FindAll()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查找节点的第一个可访问的IP地址
|
||||||
|
func (this *NodeIPAddressDAO) FindFirstNodeIPAddress(nodeId int64) (string, error) {
|
||||||
|
return this.Query().
|
||||||
|
Attr("nodeId", nodeId).
|
||||||
|
State(NodeIPAddressStateEnabled).
|
||||||
|
Attr("canAccess", true).
|
||||||
|
Desc("order").
|
||||||
|
AscPk().
|
||||||
|
Result("ip").
|
||||||
|
FindStringCol("")
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,3 +39,17 @@ func (this *Node) DecodeStatus() (*nodeconfigs.NodeStatus, error) {
|
|||||||
}
|
}
|
||||||
return status, nil
|
return status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DNS线路
|
||||||
|
func (this *Node) DNSRoute(dnsDomainId int64) (string, error) {
|
||||||
|
routes := map[int64]string{} // domainId => route
|
||||||
|
if len(this.DnsRoutes) == 0 || this.DnsRoutes == "null" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
err := json.Unmarshal([]byte(this.DnsRoutes), &routes)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
route, _ := routes[dnsDomainId]
|
||||||
|
return route, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -798,6 +798,56 @@ func (this *ServerDAO) CountAllEnabledServersWithGroupId(groupId int64) (int64,
|
|||||||
Count()
|
Count()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询使用某个DNS域名的所有服务域名
|
||||||
|
func (this *ServerDAO) FindAllServerDNSNamesWithDNSDomainId(dnsDomainId int64) ([]string, error) {
|
||||||
|
clusterIds, err := SharedNodeClusterDAO.FindAllEnabledClusterIdsWithDNSDomainId(dnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(clusterIds) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
ones, err := this.Query().
|
||||||
|
State(ServerStateEnabled).
|
||||||
|
Attr("isOn", true).
|
||||||
|
Attr("clusterId", clusterIds).
|
||||||
|
Result("dnsName").
|
||||||
|
Reuse(false). // 避免因为IN语句造成内存占用过多
|
||||||
|
FindAll()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := []string{}
|
||||||
|
for _, one := range ones {
|
||||||
|
dnsName := one.(*Server).DnsName
|
||||||
|
if len(dnsName) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
result = append(result, dnsName)
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找DNS名称为空的所有服务
|
||||||
|
func (this *ServerDAO) FindAllServersToFixWithDNSDomainId(dnsDomainId int64) (result []*Server, err error) {
|
||||||
|
clusterIds, err := SharedNodeClusterDAO.FindAllEnabledClusterIdsWithDNSDomainId(dnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(clusterIds) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
_, err = this.Query().
|
||||||
|
State(ServerStateEnabled).
|
||||||
|
Attr("isOn", true).
|
||||||
|
Attr("clusterId", clusterIds).
|
||||||
|
Result("dnsName").
|
||||||
|
Reuse(false). // 避免因为IN语句造成内存占用过多
|
||||||
|
Slice(&result).
|
||||||
|
FindAll()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 创建事件
|
// 创建事件
|
||||||
func (this *ServerDAO) createEvent() error {
|
func (this *ServerDAO) createEvent() error {
|
||||||
return SharedSysEventDAO.CreateEvent(NewServerChangeEvent())
|
return SharedSysEventDAO.CreateEvent(NewServerChangeEvent())
|
||||||
|
|||||||
@@ -52,3 +52,13 @@ func TestServerDAO_genDNSName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log("dnsName:", dnsName)
|
t.Log("dnsName:", dnsName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestServerDAO_FindAllServerDNSNamesWithDNSDomainId(t *testing.T) {
|
||||||
|
dbs.NotifyReady()
|
||||||
|
|
||||||
|
dnsNames, err := SharedServerDAO.FindAllServerDNSNamesWithDNSDomainId(2)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log("dnsNames:", dnsNames)
|
||||||
|
}
|
||||||
|
|||||||
1
internal/dnsclients/.gitignore
vendored
Normal file
1
internal/dnsclients/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*_test.go
|
||||||
204
internal/dnsclients/provider_dnspod.go
Normal file
204
internal/dnsclients/provider_dnspod.go
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
package dnsclients
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
"github.com/iwind/TeaGo/types"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DNSPodProvider struct {
|
||||||
|
apiId string
|
||||||
|
apiToken string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 认证
|
||||||
|
func (this *DNSPodProvider) Auth(params maps.Map) error {
|
||||||
|
this.apiId = params.GetString("id")
|
||||||
|
this.apiToken = params.GetString("token")
|
||||||
|
|
||||||
|
if len(this.apiId) == 0 {
|
||||||
|
return errors.New("'id' should be not empty")
|
||||||
|
}
|
||||||
|
if len(this.apiToken) == 0 {
|
||||||
|
return errors.New("'token' should not be empty")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取域名列表
|
||||||
|
func (this *DNSPodProvider) GetRecords(domain string) (records []*Record, err error) {
|
||||||
|
offset := 0
|
||||||
|
size := 100
|
||||||
|
for {
|
||||||
|
recordsResp, err := this.post("/Record.list", map[string]string{
|
||||||
|
"domain": domain,
|
||||||
|
"offset": numberutils.FormatInt(offset),
|
||||||
|
"length": numberutils.FormatInt(size),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
offset += size
|
||||||
|
|
||||||
|
// 记录
|
||||||
|
recordSlice := recordsResp.GetSlice("records")
|
||||||
|
for _, record := range recordSlice {
|
||||||
|
recordMap := maps.NewMap(record)
|
||||||
|
records = append(records, &Record{
|
||||||
|
Id: recordMap.GetString("id"),
|
||||||
|
Name: recordMap.GetString("name"),
|
||||||
|
Type: recordMap.GetString("type"),
|
||||||
|
Value: recordMap.GetString("value"),
|
||||||
|
Route: recordMap.GetString("line"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否到头
|
||||||
|
info := recordsResp.GetMap("info")
|
||||||
|
recordTotal := info.GetInt("record_total")
|
||||||
|
if offset >= recordTotal {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取线路数据
|
||||||
|
func (this *DNSPodProvider) GetRoutes(domain string) ([]string, error) {
|
||||||
|
infoResp, err := this.post("/Domain.info", map[string]string{
|
||||||
|
"domain": domain,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
domainInfo := infoResp.GetMap("domain")
|
||||||
|
grade := domainInfo.GetString("grade")
|
||||||
|
|
||||||
|
linesResp, err := this.post("/Record.Line", map[string]string{
|
||||||
|
"domain": domain,
|
||||||
|
"domain_grade": grade,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
lines := linesResp.GetSlice("lines")
|
||||||
|
if len(lines) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
lineStrings := []string{}
|
||||||
|
for _, line := range lines {
|
||||||
|
lineStrings = append(lineStrings, types.String(line))
|
||||||
|
}
|
||||||
|
|
||||||
|
return lineStrings, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置记录
|
||||||
|
func (this *DNSPodProvider) AddRecord(domain string, newRecord *Record) error {
|
||||||
|
if newRecord == nil {
|
||||||
|
return errors.New("invalid new record")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在CHANGE记录后面加入点
|
||||||
|
if newRecord.Type == RecordTypeCName && !strings.HasSuffix(newRecord.Value, ".") {
|
||||||
|
newRecord.Value += "."
|
||||||
|
}
|
||||||
|
_, err := this.post("/Record.Create", map[string]string{
|
||||||
|
"domain": domain,
|
||||||
|
"sub_domain": newRecord.Name,
|
||||||
|
"record_type": newRecord.Type,
|
||||||
|
"value": newRecord.Value,
|
||||||
|
"record_line": newRecord.Route,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改记录
|
||||||
|
func (this *DNSPodProvider) UpdateRecord(domain string, record *Record, newRecord *Record) error {
|
||||||
|
if record == nil {
|
||||||
|
return errors.New("invalid record")
|
||||||
|
}
|
||||||
|
if newRecord == nil {
|
||||||
|
return errors.New("invalid new record")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在CHANGE记录后面加入点
|
||||||
|
if newRecord.Type == RecordTypeCName && !strings.HasSuffix(newRecord.Value, ".") {
|
||||||
|
newRecord.Value += "."
|
||||||
|
}
|
||||||
|
_, err := this.post("/Record.Modify", map[string]string{
|
||||||
|
"domain": domain,
|
||||||
|
"record_id": record.Id,
|
||||||
|
"sub_domain": newRecord.Name,
|
||||||
|
"record_type": newRecord.Type,
|
||||||
|
"value": newRecord.Value,
|
||||||
|
"record_line": newRecord.Route,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除记录
|
||||||
|
func (this *DNSPodProvider) DeleteRecord(domain string, record *Record) error {
|
||||||
|
if record == nil {
|
||||||
|
return errors.New("invalid record to delete")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := this.post("/Record.Remove", map[string]string{
|
||||||
|
"domain": domain,
|
||||||
|
"record_id": record.Id,
|
||||||
|
})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
func (this *DNSPodProvider) post(path string, params map[string]string) (maps.Map, error) {
|
||||||
|
apiHost := "https://dnsapi.cn"
|
||||||
|
query := url.Values{
|
||||||
|
"login_token": []string{this.apiId + "," + this.apiToken},
|
||||||
|
"format": []string{"json"},
|
||||||
|
"lang": []string{"cn"},
|
||||||
|
}
|
||||||
|
for p, v := range params {
|
||||||
|
query[p] = []string{v}
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest(http.MethodPost, apiHost+path, strings.NewReader(query.Encode()))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
req.Header.Set("User-Agent", "GoEdge Client/1.0.0 (iwind.liu@gmail.com)")
|
||||||
|
|
||||||
|
client := http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
_ = resp.Body.Close()
|
||||||
|
client.CloseIdleConnections()
|
||||||
|
}()
|
||||||
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
m := maps.Map{}
|
||||||
|
err = json.Unmarshal(body, &m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
status := m.GetMap("status")
|
||||||
|
code := status.GetString("code")
|
||||||
|
if code != "1" {
|
||||||
|
return nil, errors.New("code: " + code + ", message: " + status.GetString("message"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
24
internal/dnsclients/provider_interface.go
Normal file
24
internal/dnsclients/provider_interface.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package dnsclients
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/maps"
|
||||||
|
|
||||||
|
// DNS操作接口
|
||||||
|
type ProviderInterface interface {
|
||||||
|
// 认证
|
||||||
|
Auth(params maps.Map) error
|
||||||
|
|
||||||
|
// 获取域名列表
|
||||||
|
GetRecords(domain string) (records []*Record, err error)
|
||||||
|
|
||||||
|
// 读取域名支持的线路数据
|
||||||
|
GetRoutes(domain string) (routes []string, err error)
|
||||||
|
|
||||||
|
// 设置记录
|
||||||
|
AddRecord(domain string, newRecord *Record) error
|
||||||
|
|
||||||
|
// 修改记录
|
||||||
|
UpdateRecord(domain string, record *Record, newRecord *Record) error
|
||||||
|
|
||||||
|
// 删除记录
|
||||||
|
DeleteRecord(domain string, record *Record) error
|
||||||
|
}
|
||||||
17
internal/dnsclients/record.go
Normal file
17
internal/dnsclients/record.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package dnsclients
|
||||||
|
|
||||||
|
type RecordType = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
RecordTypeA RecordType = "A"
|
||||||
|
RecordTypeCName RecordType = "CNAME"
|
||||||
|
RecordTypeText RecordType = "TXT"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Record struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type RecordType `json:"type"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
Route string `json:"route"`
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package dnsproviders
|
package dnsclients
|
||||||
|
|
||||||
import "github.com/iwind/TeaGo/maps"
|
import "github.com/iwind/TeaGo/maps"
|
||||||
|
|
||||||
@@ -27,7 +27,17 @@ var AllProviderTypes = []maps.Map{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindProviderTypeName(providerType string) string {
|
// 查找服务商实例
|
||||||
|
func FindProvider(providerType ProviderType) ProviderInterface {
|
||||||
|
switch providerType {
|
||||||
|
case ProviderTypeDNSPod:
|
||||||
|
return &DNSPodProvider{}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找服务商名称
|
||||||
|
func FindProviderTypeName(providerType ProviderType) string {
|
||||||
for _, t := range AllProviderTypes {
|
for _, t := range AllProviderTypes {
|
||||||
if t.GetString("code") == providerType {
|
if t.GetString("code") == providerType {
|
||||||
return t.GetString("name")
|
return t.GetString("name")
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
package dnsproviders
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
"github.com/iwind/TeaGo/types"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DNSPodProvider struct {
|
|
||||||
apiId string
|
|
||||||
apiToken string
|
|
||||||
}
|
|
||||||
|
|
||||||
// 认证
|
|
||||||
func (this *DNSPodProvider) Auth(params maps.Map) error {
|
|
||||||
this.apiId = params.GetString("id")
|
|
||||||
this.apiToken = params.GetString("token")
|
|
||||||
|
|
||||||
if len(this.apiId) == 0 {
|
|
||||||
return errors.New("'id' should be not empty")
|
|
||||||
}
|
|
||||||
if len(this.apiToken) == 0 {
|
|
||||||
return errors.New("'token' should not be empty")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 读取线路数据
|
|
||||||
func (this *DNSPodProvider) GetRoutes(domain string) ([][]string, error) {
|
|
||||||
infoResp, err := this.post("/Domain.info", map[string]string{
|
|
||||||
"domain": domain,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
domainInfo := infoResp.GetMap("domain")
|
|
||||||
grade := domainInfo.GetString("grade")
|
|
||||||
|
|
||||||
linesResp, err := this.post("/Record.Line", map[string]string{
|
|
||||||
"domain": domain,
|
|
||||||
"domain_grade": grade,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
lines := linesResp.GetSlice("lines")
|
|
||||||
if len(lines) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
lineStrings := []string{}
|
|
||||||
for _, line := range lines {
|
|
||||||
lineStrings = append(lineStrings, types.String(line))
|
|
||||||
}
|
|
||||||
|
|
||||||
return [][]string{lineStrings}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送请求
|
|
||||||
func (this *DNSPodProvider) post(path string, params map[string]string) (maps.Map, error) {
|
|
||||||
apiHost := "https://dnsapi.cn"
|
|
||||||
query := url.Values{
|
|
||||||
"login_token": []string{this.apiId + "," + this.apiToken},
|
|
||||||
"format": []string{"json"},
|
|
||||||
}
|
|
||||||
for p, v := range params {
|
|
||||||
query[p] = []string{v}
|
|
||||||
}
|
|
||||||
req, err := http.NewRequest(http.MethodPost, apiHost+path, strings.NewReader(query.Encode()))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
||||||
req.Header.Set("User-Agent", "GoEdge Client/1.0.0 (iwind.liu@gmail.com)")
|
|
||||||
|
|
||||||
client := http.Client{}
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
_ = resp.Body.Close()
|
|
||||||
client.CloseIdleConnections()
|
|
||||||
}()
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
m := maps.Map{}
|
|
||||||
err = json.Unmarshal(body, &m)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
status := m.GetMap("status")
|
|
||||||
code := status.GetString("code")
|
|
||||||
if code != "1" {
|
|
||||||
return nil, errors.New("code: " + code + ", message: " + status.GetString("message"))
|
|
||||||
}
|
|
||||||
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package dnsproviders
|
|
||||||
|
|
||||||
import "github.com/iwind/TeaGo/maps"
|
|
||||||
|
|
||||||
// DNS操作接口
|
|
||||||
type ProviderInterface interface {
|
|
||||||
// 认证
|
|
||||||
Auth(params maps.Map) error
|
|
||||||
|
|
||||||
// 读取线路数据
|
|
||||||
GetRoutes(domain string) ([][]string, error)
|
|
||||||
}
|
|
||||||
@@ -157,7 +157,7 @@ func (this *AdminService) CreateOrUpdateAdmin(ctx context.Context, req *pb.Creat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改管理员信息
|
// 修改管理员信息
|
||||||
func (this *AdminService) UpdateAdmin(ctx context.Context, req *pb.UpdateAdminRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *AdminService) UpdateAdmin(ctx context.Context, req *pb.UpdateAdminRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin, rpcutils.UserTypeAPI)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin, rpcutils.UserTypeAPI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -168,11 +168,11 @@ func (this *AdminService) UpdateAdmin(ctx context.Context, req *pb.UpdateAdminRe
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改管理员登录信息
|
// 修改管理员登录信息
|
||||||
func (this *AdminService) UpdateAdminLogin(ctx context.Context, req *pb.UpdateAdminLoginRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *AdminService) UpdateAdminLogin(ctx context.Context, req *pb.UpdateAdminLoginRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin, rpcutils.UserTypeAPI)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin, rpcutils.UserTypeAPI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -191,5 +191,5 @@ func (this *AdminService) UpdateAdminLogin(ctx context.Context, req *pb.UpdateAd
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,21 +29,6 @@ func TestAdminService_Login(t *testing.T) {
|
|||||||
a.LogJSON(resp)
|
a.LogJSON(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAdminService_CreateLog(t *testing.T) {
|
|
||||||
service := &AdminService{debug: true}
|
|
||||||
|
|
||||||
resp, err := service.CreateAdminLog(testCtx(t), &pb.CreateAdminLogRequest{
|
|
||||||
Level: "info",
|
|
||||||
Description: "这是一个测试日志",
|
|
||||||
Action: "/login",
|
|
||||||
Ip: "127.0.0.1",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Log(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAdminService_FindAdminFullname(t *testing.T) {
|
func TestAdminService_FindAdminFullname(t *testing.T) {
|
||||||
service := &AdminService{
|
service := &AdminService{
|
||||||
debug: true,
|
debug: true,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *APINodeService) CreateAPINode(ctx context.Context, req *pb.CreateAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改API节点
|
// 修改API节点
|
||||||
func (this *APINodeService) UpdateAPINode(ctx context.Context, req *pb.UpdateAPINodeRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *APINodeService) UpdateAPINode(ctx context.Context, req *pb.UpdateAPINodeRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -38,11 +38,11 @@ func (this *APINodeService) UpdateAPINode(ctx context.Context, req *pb.UpdateAPI
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除API节点
|
// 删除API节点
|
||||||
func (this *APINodeService) DeleteAPINode(ctx context.Context, req *pb.DeleteAPINodeRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *APINodeService) DeleteAPINode(ctx context.Context, req *pb.DeleteAPINodeRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -53,7 +53,7 @@ func (this *APINodeService) DeleteAPINode(ctx context.Context, req *pb.DeleteAPI
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCDeleteSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 列出所有可用API节点
|
// 列出所有可用API节点
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *DBNodeService) CreateDBNode(ctx context.Context, req *pb.CreateDBNod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改数据库节点
|
// 修改数据库节点
|
||||||
func (this *DBNodeService) UpdateDBNode(ctx context.Context, req *pb.UpdateDBNodeRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *DBNodeService) UpdateDBNode(ctx context.Context, req *pb.UpdateDBNodeRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -37,11 +37,11 @@ func (this *DBNodeService) UpdateDBNode(ctx context.Context, req *pb.UpdateDBNod
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除节点
|
// 删除节点
|
||||||
func (this *DBNodeService) DeleteDBNode(ctx context.Context, req *pb.DeleteDBNodeRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *DBNodeService) DeleteDBNode(ctx context.Context, req *pb.DeleteDBNodeRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -51,7 +51,7 @@ func (this *DBNodeService) DeleteDBNode(ctx context.Context, req *pb.DeleteDBNod
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算可用的数据库节点数量
|
// 计算可用的数据库节点数量
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package services
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||||
|
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients"
|
||||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNS域名相关服务
|
// DNS域名相关服务
|
||||||
@@ -27,7 +30,7 @@ func (this *DNSDomainService) CreateDNSDomain(ctx context.Context, req *pb.Creat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改域名
|
// 修改域名
|
||||||
func (this *DNSDomainService) UpdateDNSDomain(ctx context.Context, req *pb.UpdateDNSDomainRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *DNSDomainService) UpdateDNSDomain(ctx context.Context, req *pb.UpdateDNSDomainRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -38,11 +41,11 @@ func (this *DNSDomainService) UpdateDNSDomain(ctx context.Context, req *pb.Updat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除域名
|
// 删除域名
|
||||||
func (this *DNSDomainService) DeleteDNSDomain(ctx context.Context, req *pb.DeleteDNSDomainRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *DNSDomainService) DeleteDNSDomain(ctx context.Context, req *pb.DeleteDNSDomainRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -53,7 +56,51 @@ func (this *DNSDomainService) DeleteDNSDomain(ctx context.Context, req *pb.Delet
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询单个域名完整信息
|
||||||
|
func (this *DNSDomainService) FindEnabledDNSDomain(ctx context.Context, req *pb.FindEnabledDNSDomainRequest) (*pb.FindEnabledDNSDomainResponse, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
domain, err := models.SharedDNSDomainDAO.FindEnabledDNSDomain(req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if domain == nil {
|
||||||
|
return &pb.FindEnabledDNSDomainResponse{DnsDomain: nil}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pbDomain, err := this.convertDomainToPB(domain)
|
||||||
|
return &pb.FindEnabledDNSDomainResponse{DnsDomain: pbDomain}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询单个域名基础信息
|
||||||
|
func (this *DNSDomainService) FindEnabledBasicDNSDomain(ctx context.Context, req *pb.FindEnabledBasicDNSDomainRequest) (*pb.FindEnabledBasicDNSDomainResponse, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
domain, err := models.SharedDNSDomainDAO.FindEnabledDNSDomain(req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if domain == nil {
|
||||||
|
return &pb.FindEnabledBasicDNSDomainResponse{DnsDomain: nil}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pb.FindEnabledBasicDNSDomainResponse{DnsDomain: &pb.DNSDomain{
|
||||||
|
Id: int64(domain.Id),
|
||||||
|
Name: domain.Name,
|
||||||
|
IsOn: domain.IsOn == 1,
|
||||||
|
ProviderId: int64(domain.ProviderId),
|
||||||
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算服务商下的域名数量
|
// 计算服务商下的域名数量
|
||||||
@@ -86,13 +133,326 @@ func (this *DNSDomainService) FindAllEnabledDNSDomainsWithDNSProviderId(ctx cont
|
|||||||
|
|
||||||
result := []*pb.DNSDomain{}
|
result := []*pb.DNSDomain{}
|
||||||
for _, domain := range domains {
|
for _, domain := range domains {
|
||||||
result = append(result, &pb.DNSDomain{
|
pbDomain, err := this.convertDomainToPB(domain)
|
||||||
Id: int64(domain.Id),
|
if err != nil {
|
||||||
Name: domain.Name,
|
return nil, err
|
||||||
IsOn: domain.IsOn == 1,
|
}
|
||||||
DataUpdatedAt: int64(domain.DataUpdatedAt),
|
result = append(result, pbDomain)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.FindAllEnabledDNSDomainsWithDNSProviderIdResponse{DnsDomains: result}, nil
|
return &pb.FindAllEnabledDNSDomainsWithDNSProviderIdResponse{DnsDomains: result}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 列出服务商下的所有域名基本信息
|
||||||
|
func (this *DNSDomainService) FindAllEnabledBasicDNSDomainsWithDNSProviderId(ctx context.Context, req *pb.FindAllEnabledBasicDNSDomainsWithDNSProviderIdRequest) (*pb.FindAllEnabledBasicDNSDomainsWithDNSProviderIdResponse, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
domains, err := models.SharedDNSDomainDAO.FindAllEnabledDomainsWithProviderId(req.DnsProviderId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := []*pb.DNSDomain{}
|
||||||
|
for _, domain := range domains {
|
||||||
|
result = append(result, &pb.DNSDomain{
|
||||||
|
Id: int64(domain.Id),
|
||||||
|
Name: domain.Name,
|
||||||
|
IsOn: domain.IsOn == 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pb.FindAllEnabledBasicDNSDomainsWithDNSProviderIdResponse{DnsDomains: result}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同步域名数据
|
||||||
|
func (this *DNSDomainService) SyncDNSDomainData(ctx context.Context, req *pb.SyncDNSDomainDataRequest) (*pb.SyncDNSDomainDataResponse, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查集群设置完整性
|
||||||
|
clusters, err := models.SharedNodeClusterDAO.FindAllEnabledClustersWithDNSDomainId(req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, cluster := range clusters {
|
||||||
|
if len(cluster.DnsName) == 0 {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "有问题需要修复", ShouldFix: true}, nil
|
||||||
|
}
|
||||||
|
nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithClusterId(int64(cluster.Id))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, node := range nodes {
|
||||||
|
if node.IsOn == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ipAddress, err := models.SharedNodeIPAddressDAO.FindFirstNodeIPAddress(int64(node.Id))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(ipAddress) == 0 {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "有问题需要修复", ShouldFix: true}, nil
|
||||||
|
}
|
||||||
|
route, err := node.DNSRoute(req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(route) == 0 {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "有问题需要修复", ShouldFix: true}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查服务设置完整性
|
||||||
|
servers, err := models.SharedServerDAO.FindAllServersToFixWithDNSDomainId(req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(servers) > 0 {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "有问题需要修复", ShouldFix: true}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 域名信息
|
||||||
|
domain, err := models.SharedDNSDomainDAO.FindEnabledDNSDomain(req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if domain == nil {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "找不到要操作的域名"}, nil
|
||||||
|
}
|
||||||
|
domainId := int64(domain.Id)
|
||||||
|
domainName := domain.Name
|
||||||
|
|
||||||
|
// 服务商信息
|
||||||
|
provider, err := models.SharedDNSProviderDAO.FindEnabledDNSProvider(int64(domain.ProviderId))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if provider == nil {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "域名没有设置服务商"}, nil
|
||||||
|
}
|
||||||
|
apiParams := maps.Map{}
|
||||||
|
if len(provider.ApiParams) > 0 && provider.ApiParams != "null" {
|
||||||
|
err = json.Unmarshal([]byte(provider.ApiParams), &apiParams)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始同步
|
||||||
|
manager := dnsclients.FindProvider(provider.Type)
|
||||||
|
if manager == nil {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "目前不支持'" + provider.Type + "'"}, nil
|
||||||
|
}
|
||||||
|
err = manager.Auth(apiParams)
|
||||||
|
if err != nil {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "调用API认证失败:" + err.Error()}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 线路
|
||||||
|
routes, err := manager.GetRoutes(domainName)
|
||||||
|
if err != nil {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "获取线路失败:" + err.Error()}, nil
|
||||||
|
}
|
||||||
|
routesJSON, err := json.Marshal(routes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = models.SharedDNSDomainDAO.UpdateDomainRoutes(domainId, routesJSON)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 所有记录
|
||||||
|
records, err := manager.GetRecords(domainName)
|
||||||
|
if err != nil {
|
||||||
|
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "获取域名解析记录失败:" + err.Error()}, nil
|
||||||
|
}
|
||||||
|
recordsJSON, err := json.Marshal(records)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = models.SharedDNSDomainDAO.UpdateDomainRecords(domainId, recordsJSON)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修正集群域名
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
// 修正服务域名
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return &pb.SyncDNSDomainDataResponse{
|
||||||
|
IsOk: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看支持的线路
|
||||||
|
func (this *DNSDomainService) FindAllDNSDomainRoutes(ctx context.Context, req *pb.FindAllDNSDomainRoutesRequest) (*pb.FindAllDNSDomainRoutesResponse, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
routes, err := models.SharedDNSDomainDAO.FindDomainRoutes(req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &pb.FindAllDNSDomainRoutesResponse{Routes: routes}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换域名信息
|
||||||
|
func (this *DNSDomainService) convertDomainToPB(domain *models.DNSDomain) (*pb.DNSDomain, error) {
|
||||||
|
domainId := int64(domain.Id)
|
||||||
|
|
||||||
|
records := []*dnsclients.Record{}
|
||||||
|
if len(domain.Records) > 0 && domain.Records != "null" {
|
||||||
|
err := json.Unmarshal([]byte(domain.Records), &records)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recordsMapping := map[string][]*dnsclients.Record{} // name_type => *Record
|
||||||
|
for _, record := range records {
|
||||||
|
key := record.Name + "_" + record.Type
|
||||||
|
_, ok := recordsMapping[key]
|
||||||
|
if ok {
|
||||||
|
recordsMapping[key] = append(recordsMapping[key], record)
|
||||||
|
} else {
|
||||||
|
recordsMapping[key] = []*dnsclients.Record{record}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 集群域名
|
||||||
|
clusterRecords := []*pb.DNSRecord{}
|
||||||
|
allClusterResolved := true
|
||||||
|
{
|
||||||
|
// 检查是否所有的集群都已经被解析
|
||||||
|
clusters, err := models.SharedNodeClusterDAO.FindAllEnabledClustersWithDNSDomainId(domainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, cluster := range clusters {
|
||||||
|
clusterId := int64(cluster.Id)
|
||||||
|
dnsName := cluster.DnsName
|
||||||
|
|
||||||
|
// 子节点
|
||||||
|
nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithClusterId(clusterId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nodeMapping := map[string]*models.Node{} // name_type_value_route => *Node
|
||||||
|
for _, node := range nodes {
|
||||||
|
if node.IsOn == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
ipAddr, err := models.SharedNodeIPAddressDAO.FindFirstNodeIPAddress(int64(node.Id))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
route, err := node.DNSRoute(domainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nodeMapping[dnsName+"_A_"+ipAddr+"_"+route] = node
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已有的记录
|
||||||
|
nodeRecordsMapping := map[string]*dnsclients.Record{} // name_type_value_route => *Record
|
||||||
|
nodeRecords, _ := recordsMapping[dnsName+"_A"]
|
||||||
|
for _, record := range nodeRecords {
|
||||||
|
key := record.Name + "_" + record.Type + "_" + record.Value + "_" + record.Route
|
||||||
|
nodeRecordsMapping[key] = record
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查有无多余的子节点
|
||||||
|
for key, record := range nodeRecordsMapping {
|
||||||
|
_, ok := nodeMapping[key]
|
||||||
|
if !ok {
|
||||||
|
allClusterResolved = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
clusterRecords = append(clusterRecords, this.convertRecordToPB(record))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查有无少的子节点
|
||||||
|
for key := range nodeMapping {
|
||||||
|
_, ok := nodeRecordsMapping[key]
|
||||||
|
if !ok {
|
||||||
|
allClusterResolved = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务域名
|
||||||
|
serverRecords := []*pb.DNSRecord{}
|
||||||
|
allServersResolved := true
|
||||||
|
|
||||||
|
// 检查是否所有的服务都已经被解析
|
||||||
|
{
|
||||||
|
dnsNames, err := models.SharedServerDAO.FindAllServerDNSNamesWithDNSDomainId(domainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, dnsName := range dnsNames {
|
||||||
|
if len(dnsName) == 0 {
|
||||||
|
allServersResolved = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
key := dnsName + "_CNAME"
|
||||||
|
recordList, ok := recordsMapping[key]
|
||||||
|
if !ok {
|
||||||
|
allServersResolved = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, record := range recordList {
|
||||||
|
serverRecords = append(serverRecords, this.convertRecordToPB(record))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 线路
|
||||||
|
routes := []string{}
|
||||||
|
if len(domain.Routes) > 0 && domain.Routes != "null" {
|
||||||
|
err := json.Unmarshal([]byte(domain.Routes), &routes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pb.DNSDomain{
|
||||||
|
Id: int64(domain.Id),
|
||||||
|
ProviderId: int64(domain.ProviderId),
|
||||||
|
Name: domain.Name,
|
||||||
|
IsOn: domain.IsOn == 1,
|
||||||
|
DataUpdatedAt: int64(domain.DataUpdatedAt),
|
||||||
|
ClusterRecords: clusterRecords,
|
||||||
|
AllClustersResolved: allClusterResolved,
|
||||||
|
ServerRecords: serverRecords,
|
||||||
|
AllServersResolved: allServersResolved,
|
||||||
|
Routes: routes,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换域名记录信息
|
||||||
|
func (this *DNSDomainService) convertRecordToPB(record *dnsclients.Record) *pb.DNSRecord {
|
||||||
|
return &pb.DNSRecord{
|
||||||
|
Id: record.Id,
|
||||||
|
Name: record.Name,
|
||||||
|
Value: record.Value,
|
||||||
|
Type: record.Type,
|
||||||
|
Route: record.Route,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package services
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/dnsproviders"
|
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients"
|
||||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
)
|
)
|
||||||
@@ -29,7 +29,7 @@ func (this *DNSProviderService) CreateDNSProvider(ctx context.Context, req *pb.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改服务商
|
// 修改服务商
|
||||||
func (this *DNSProviderService) UpdateDNSProvider(ctx context.Context, req *pb.UpdateDNSProviderRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *DNSProviderService) UpdateDNSProvider(ctx context.Context, req *pb.UpdateDNSProviderRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -40,7 +40,7 @@ func (this *DNSProviderService) UpdateDNSProvider(ctx context.Context, req *pb.U
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算服务商数量
|
// 计算服务商数量
|
||||||
@@ -76,7 +76,7 @@ func (this *DNSProviderService) ListEnabledDNSProviders(ctx context.Context, req
|
|||||||
Id: int64(provider.Id),
|
Id: int64(provider.Id),
|
||||||
Name: provider.Name,
|
Name: provider.Name,
|
||||||
Type: provider.Type,
|
Type: provider.Type,
|
||||||
TypeName: dnsproviders.FindProviderTypeName(provider.Type),
|
TypeName: dnsclients.FindProviderTypeName(provider.Type),
|
||||||
ApiParamsJSON: []byte(provider.ApiParams),
|
ApiParamsJSON: []byte(provider.ApiParams),
|
||||||
DataUpdatedAt: int64(provider.DataUpdatedAt),
|
DataUpdatedAt: int64(provider.DataUpdatedAt),
|
||||||
})
|
})
|
||||||
@@ -85,7 +85,7 @@ func (this *DNSProviderService) ListEnabledDNSProviders(ctx context.Context, req
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除服务商
|
// 删除服务商
|
||||||
func (this *DNSProviderService) DeleteDNSProvider(ctx context.Context, req *pb.DeleteDNSProviderRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *DNSProviderService) DeleteDNSProvider(ctx context.Context, req *pb.DeleteDNSProviderRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -96,7 +96,7 @@ func (this *DNSProviderService) DeleteDNSProvider(ctx context.Context, req *pb.D
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找单个服务商
|
// 查找单个服务商
|
||||||
@@ -119,7 +119,7 @@ func (this *DNSProviderService) FindEnabledDNSProvider(ctx context.Context, req
|
|||||||
Id: int64(provider.Id),
|
Id: int64(provider.Id),
|
||||||
Name: provider.Name,
|
Name: provider.Name,
|
||||||
Type: provider.Type,
|
Type: provider.Type,
|
||||||
TypeName: dnsproviders.FindProviderTypeName(provider.Type),
|
TypeName: dnsclients.FindProviderTypeName(provider.Type),
|
||||||
ApiParamsJSON: []byte(provider.ApiParams),
|
ApiParamsJSON: []byte(provider.ApiParams),
|
||||||
DataUpdatedAt: int64(provider.DataUpdatedAt),
|
DataUpdatedAt: int64(provider.DataUpdatedAt),
|
||||||
}}, nil
|
}}, nil
|
||||||
@@ -134,7 +134,7 @@ func (this *DNSProviderService) FindAllDNSProviderTypes(ctx context.Context, req
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := []*pb.DNSProviderType{}
|
result := []*pb.DNSProviderType{}
|
||||||
for _, t := range dnsproviders.AllProviderTypes {
|
for _, t := range dnsclients.AllProviderTypes {
|
||||||
result = append(result, &pb.DNSProviderType{
|
result = append(result, &pb.DNSProviderType{
|
||||||
Name: t.GetString("name"),
|
Name: t.GetString("name"),
|
||||||
Code: t.GetString("code"),
|
Code: t.GetString("code"),
|
||||||
@@ -143,15 +143,26 @@ func (this *DNSProviderService) FindAllDNSProviderTypes(ctx context.Context, req
|
|||||||
return &pb.FindAllDNSProviderTypesResponse{ProviderTypes: result}, nil
|
return &pb.FindAllDNSProviderTypesResponse{ProviderTypes: result}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新数据
|
// 取得某个类型的所有服务商
|
||||||
func (this *DNSProviderService) UpdateDNSProviderData(ctx context.Context, req *pb.UpdateDNSProviderDataRequest) (*pb.UpdateDNSProviderDataResponse, error) {
|
func (this *DNSProviderService) FindAllEnabledDNSProvidersWithType(ctx context.Context, req *pb.FindAllEnabledDNSProvidersWithTypeRequest) (*pb.FindAllEnabledDNSProvidersWithTypeResponse, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 需要实现
|
providers, err := models.SharedDNSProviderDAO.FindAllEnabledDNSProvidersWithType(req.ProviderTypeCode)
|
||||||
|
if err != nil {
|
||||||
return &pb.UpdateDNSProviderDataResponse{IsOk: true}, nil
|
return nil, err
|
||||||
|
}
|
||||||
|
result := []*pb.DNSProvider{}
|
||||||
|
for _, provider := range providers {
|
||||||
|
result = append(result, &pb.DNSProvider{
|
||||||
|
Id: int64(provider.Id),
|
||||||
|
Name: provider.Name,
|
||||||
|
Type: provider.Type,
|
||||||
|
TypeName: dnsclients.FindProviderTypeName(provider.Type),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &pb.FindAllEnabledDNSProvidersWithTypeResponse{DnsProviders: result}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *FileService) CreateFile(ctx context.Context, req *pb.CreateFileReque
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 将文件置为已完成
|
// 将文件置为已完成
|
||||||
func (this *FileService) UpdateFileFinished(ctx context.Context, req *pb.UpdateFileFinishedRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *FileService) UpdateFileFinished(ctx context.Context, req *pb.UpdateFileFinishedRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -38,5 +38,5 @@ func (this *FileService) UpdateFileFinished(ctx context.Context, req *pb.UpdateF
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (this *HTTPCachePolicyService) CreateHTTPCachePolicy(ctx context.Context, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改缓存策略
|
// 修改缓存策略
|
||||||
func (this *HTTPCachePolicyService) UpdateHTTPCachePolicy(ctx context.Context, req *pb.UpdateHTTPCachePolicyRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPCachePolicyService) UpdateHTTPCachePolicy(ctx context.Context, req *pb.UpdateHTTPCachePolicyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -62,11 +62,11 @@ func (this *HTTPCachePolicyService) UpdateHTTPCachePolicy(ctx context.Context, r
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除缓存策略
|
// 删除缓存策略
|
||||||
func (this *HTTPCachePolicyService) DeleteHTTPCachePolicy(ctx context.Context, req *pb.DeleteHTTPCachePolicyRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *HTTPCachePolicyService) DeleteHTTPCachePolicy(ctx context.Context, req *pb.DeleteHTTPCachePolicyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -78,7 +78,7 @@ func (this *HTTPCachePolicyService) DeleteHTTPCachePolicy(ctx context.Context, r
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算缓存策略数量
|
// 计算缓存策略数量
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ func (this *HTTPFirewallPolicyService) CreateHTTPFirewallPolicy(ctx context.Cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改防火墙策略
|
// 修改防火墙策略
|
||||||
func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicy(ctx context.Context, req *pb.UpdateHTTPFirewallPolicyRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicy(ctx context.Context, req *pb.UpdateHTTPFirewallPolicyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -232,11 +232,11 @@ func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicy(ctx context.Cont
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改分组信息
|
// 修改分组信息
|
||||||
func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicyGroups(ctx context.Context, req *pb.UpdateHTTPFirewallPolicyGroupsRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicyGroups(ctx context.Context, req *pb.UpdateHTTPFirewallPolicyGroupsRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -248,11 +248,11 @@ func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicyGroups(ctx contex
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改inbound信息
|
// 修改inbound信息
|
||||||
func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallInboundConfig(ctx context.Context, req *pb.UpdateHTTPFirewallInboundConfigRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallInboundConfig(ctx context.Context, req *pb.UpdateHTTPFirewallInboundConfigRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -264,7 +264,7 @@ func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallInboundConfig(ctx conte
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算可用的防火墙策略数量
|
// 计算可用的防火墙策略数量
|
||||||
@@ -311,7 +311,7 @@ func (this *HTTPFirewallPolicyService) ListEnabledFirewallPolicies(ctx context.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除某个防火墙策略
|
// 删除某个防火墙策略
|
||||||
func (this *HTTPFirewallPolicyService) DeleteFirewallPolicy(ctx context.Context, req *pb.DeleteFirewallPolicyRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *HTTPFirewallPolicyService) DeleteFirewallPolicy(ctx context.Context, req *pb.DeleteFirewallPolicyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -323,7 +323,7 @@ func (this *HTTPFirewallPolicyService) DeleteFirewallPolicy(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找单个防火墙配置
|
// 查找单个防火墙配置
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type HTTPFirewallRuleGroupService struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置是否启用分组
|
// 设置是否启用分组
|
||||||
func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupIsOn(ctx context.Context, req *pb.UpdateHTTPFirewallRuleGroupIsOnRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupIsOn(ctx context.Context, req *pb.UpdateHTTPFirewallRuleGroupIsOnRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -25,7 +25,7 @@ func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupIsOn(ctx co
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建分组
|
// 创建分组
|
||||||
@@ -44,7 +44,7 @@ func (this *HTTPFirewallRuleGroupService) CreateHTTPFirewallRuleGroup(ctx contex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改分组
|
// 修改分组
|
||||||
func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroup(ctx context.Context, req *pb.UpdateHTTPFirewallRuleGroupRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroup(ctx context.Context, req *pb.UpdateHTTPFirewallRuleGroupRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -56,7 +56,7 @@ func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroup(ctx contex
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取分组配置
|
// 获取分组配置
|
||||||
@@ -111,7 +111,7 @@ func (this *HTTPFirewallRuleGroupService) FindEnabledHTTPFirewallRuleGroup(ctx c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改分组的规则集
|
// 修改分组的规则集
|
||||||
func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupSets(ctx context.Context, req *pb.UpdateHTTPFirewallRuleGroupSetsRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupSets(ctx context.Context, req *pb.UpdateHTTPFirewallRuleGroupSetsRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -122,5 +122,5 @@ func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupSets(ctx co
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (this *HTTPFirewallRuleSetService) CreateOrUpdateHTTPFirewallRuleSetFromCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改是否开启
|
// 修改是否开启
|
||||||
func (this *HTTPFirewallRuleSetService) UpdateHTTPFirewallRuleSetIsOn(ctx context.Context, req *pb.UpdateHTTPFirewallRuleSetIsOnRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPFirewallRuleSetService) UpdateHTTPFirewallRuleSetIsOn(ctx context.Context, req *pb.UpdateHTTPFirewallRuleSetIsOnRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -48,7 +48,7 @@ func (this *HTTPFirewallRuleSetService) UpdateHTTPFirewallRuleSetIsOn(ctx contex
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找规则集配置
|
// 查找规则集配置
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *HTTPHeaderService) CreateHTTPHeader(ctx context.Context, req *pb.Cre
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改Header
|
// 修改Header
|
||||||
func (this *HTTPHeaderService) UpdateHTTPHeader(ctx context.Context, req *pb.UpdateHTTPHeaderRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPHeaderService) UpdateHTTPHeader(ctx context.Context, req *pb.UpdateHTTPHeaderRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -38,7 +38,7 @@ func (this *HTTPHeaderService) UpdateHTTPHeader(ctx context.Context, req *pb.Upd
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找配置
|
// 查找配置
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func (this *HTTPHeaderPolicyService) CreateHTTPHeaderPolicy(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改AddHeaders
|
// 修改AddHeaders
|
||||||
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyAddingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyAddingHeadersRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyAddingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyAddingHeadersRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -58,11 +58,11 @@ func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyAddingHeaders(ctx con
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改SetHeaders
|
// 修改SetHeaders
|
||||||
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicySettingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicySettingHeadersRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicySettingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicySettingHeadersRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -73,11 +73,11 @@ func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicySettingHeaders(ctx co
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改AddTrailers
|
// 修改AddTrailers
|
||||||
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyAddingTrailers(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyAddingTrailersRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyAddingTrailers(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyAddingTrailersRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -88,11 +88,11 @@ func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyAddingTrailers(ctx co
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改ReplaceHeaders
|
// 修改ReplaceHeaders
|
||||||
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyReplacingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyReplacingHeadersRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyReplacingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyReplacingHeadersRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -103,11 +103,11 @@ func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyReplacingHeaders(ctx
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改删除的Headers
|
// 修改删除的Headers
|
||||||
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyDeletingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyDeletingHeadersRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyDeletingHeaders(ctx context.Context, req *pb.UpdateHTTPHeaderPolicyDeletingHeadersRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -118,5 +118,5 @@ func (this *HTTPHeaderPolicyService) UpdateHTTPHeaderPolicyDeletingHeaders(ctx c
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func (this *HTTPLocationService) CreateHTTPLocation(ctx context.Context, req *pb
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改路径规则
|
// 修改路径规则
|
||||||
func (this *HTTPLocationService) UpdateHTTPLocation(ctx context.Context, req *pb.UpdateHTTPLocationRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPLocationService) UpdateHTTPLocation(ctx context.Context, req *pb.UpdateHTTPLocationRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -41,7 +41,7 @@ func (this *HTTPLocationService) UpdateHTTPLocation(ctx context.Context, req *pb
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找路径规则配置
|
// 查找路径规则配置
|
||||||
@@ -64,7 +64,7 @@ func (this *HTTPLocationService) FindEnabledHTTPLocationConfig(ctx context.Conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除路径规则
|
// 删除路径规则
|
||||||
func (this *HTTPLocationService) DeleteHTTPLocation(ctx context.Context, req *pb.DeleteHTTPLocationRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *HTTPLocationService) DeleteHTTPLocation(ctx context.Context, req *pb.DeleteHTTPLocationRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -75,7 +75,7 @@ func (this *HTTPLocationService) DeleteHTTPLocation(ctx context.Context, req *pb
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找反向代理设置
|
// 查找反向代理设置
|
||||||
@@ -167,7 +167,7 @@ func (this *HTTPLocationService) FindAndInitHTTPLocationWebConfig(ctx context.Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改反向代理设置
|
// 修改反向代理设置
|
||||||
func (this *HTTPLocationService) UpdateHTTPLocationReverseProxy(ctx context.Context, req *pb.UpdateHTTPLocationReverseProxyRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPLocationService) UpdateHTTPLocationReverseProxy(ctx context.Context, req *pb.UpdateHTTPLocationReverseProxyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -178,5 +178,5 @@ func (this *HTTPLocationService) UpdateHTTPLocationReverseProxy(ctx context.Cont
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func (this *HTTPPageService) CreateHTTPPage(ctx context.Context, req *pb.CreateH
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改Page
|
// 修改Page
|
||||||
func (this *HTTPPageService) UpdateHTTPPage(ctx context.Context, req *pb.UpdateHTTPPageRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPPageService) UpdateHTTPPage(ctx context.Context, req *pb.UpdateHTTPPageRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -41,7 +41,7 @@ func (this *HTTPPageService) UpdateHTTPPage(ctx context.Context, req *pb.UpdateH
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找单个Page配置
|
// 查找单个Page配置
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func (this *HTTPRewriteRuleService) CreateHTTPRewriteRule(ctx context.Context, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改重写规则
|
// 修改重写规则
|
||||||
func (this *HTTPRewriteRuleService) UpdateHTTPRewriteRule(ctx context.Context, req *pb.UpdateHTTPRewriteRuleRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPRewriteRuleService) UpdateHTTPRewriteRule(ctx context.Context, req *pb.UpdateHTTPRewriteRuleRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -40,5 +40,5 @@ func (this *HTTPRewriteRuleService) UpdateHTTPRewriteRule(ctx context.Context, r
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func (this *HTTPWebService) FindEnabledHTTPWebConfig(ctx context.Context, req *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改Web配置
|
// 修改Web配置
|
||||||
func (this *HTTPWebService) UpdateHTTPWeb(ctx context.Context, req *pb.UpdateHTTPWebRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWeb(ctx context.Context, req *pb.UpdateHTTPWebRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -83,11 +83,11 @@ func (this *HTTPWebService) UpdateHTTPWeb(ctx context.Context, req *pb.UpdateHTT
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改Gzip配置
|
// 修改Gzip配置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebGzip(ctx context.Context, req *pb.UpdateHTTPWebGzipRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebGzip(ctx context.Context, req *pb.UpdateHTTPWebGzipRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -99,11 +99,11 @@ func (this *HTTPWebService) UpdateHTTPWebGzip(ctx context.Context, req *pb.Updat
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改字符集配置
|
// 修改字符集配置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebCharset(ctx context.Context, req *pb.UpdateHTTPWebCharsetRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebCharset(ctx context.Context, req *pb.UpdateHTTPWebCharsetRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,11 +114,11 @@ func (this *HTTPWebService) UpdateHTTPWebCharset(ctx context.Context, req *pb.Up
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改请求Header策略
|
// 更改请求Header策略
|
||||||
func (this *HTTPWebService) UpdateHTTPWebRequestHeader(ctx context.Context, req *pb.UpdateHTTPWebRequestHeaderRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebRequestHeader(ctx context.Context, req *pb.UpdateHTTPWebRequestHeaderRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -130,11 +130,11 @@ func (this *HTTPWebService) UpdateHTTPWebRequestHeader(ctx context.Context, req
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改响应Header策略
|
// 更改响应Header策略
|
||||||
func (this *HTTPWebService) UpdateHTTPWebResponseHeader(ctx context.Context, req *pb.UpdateHTTPWebResponseHeaderRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebResponseHeader(ctx context.Context, req *pb.UpdateHTTPWebResponseHeaderRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -146,11 +146,11 @@ func (this *HTTPWebService) UpdateHTTPWebResponseHeader(ctx context.Context, req
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改Shutdown
|
// 更改Shutdown
|
||||||
func (this *HTTPWebService) UpdateHTTPWebShutdown(ctx context.Context, req *pb.UpdateHTTPWebShutdownRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebShutdown(ctx context.Context, req *pb.UpdateHTTPWebShutdownRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -161,11 +161,11 @@ func (this *HTTPWebService) UpdateHTTPWebShutdown(ctx context.Context, req *pb.U
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改Pages
|
// 更改Pages
|
||||||
func (this *HTTPWebService) UpdateHTTPWebPages(ctx context.Context, req *pb.UpdateHTTPWebPagesRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebPages(ctx context.Context, req *pb.UpdateHTTPWebPagesRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -176,11 +176,11 @@ func (this *HTTPWebService) UpdateHTTPWebPages(ctx context.Context, req *pb.Upda
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改访问日志配置
|
// 更改访问日志配置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebAccessLog(ctx context.Context, req *pb.UpdateHTTPWebAccessLogRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebAccessLog(ctx context.Context, req *pb.UpdateHTTPWebAccessLogRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -191,11 +191,11 @@ func (this *HTTPWebService) UpdateHTTPWebAccessLog(ctx context.Context, req *pb.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改统计配置
|
// 更改统计配置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebStat(ctx context.Context, req *pb.UpdateHTTPWebStatRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebStat(ctx context.Context, req *pb.UpdateHTTPWebStatRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -206,11 +206,11 @@ func (this *HTTPWebService) UpdateHTTPWebStat(ctx context.Context, req *pb.Updat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改缓存配置
|
// 更改缓存配置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebCache(ctx context.Context, req *pb.UpdateHTTPWebCacheRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebCache(ctx context.Context, req *pb.UpdateHTTPWebCacheRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -222,11 +222,11 @@ func (this *HTTPWebService) UpdateHTTPWebCache(ctx context.Context, req *pb.Upda
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改防火墙设置
|
// 更改防火墙设置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebFirewall(ctx context.Context, req *pb.UpdateHTTPWebFirewallRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebFirewall(ctx context.Context, req *pb.UpdateHTTPWebFirewallRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -238,11 +238,11 @@ func (this *HTTPWebService) UpdateHTTPWebFirewall(ctx context.Context, req *pb.U
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改路径规则设置
|
// 更改路径规则设置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebLocations(ctx context.Context, req *pb.UpdateHTTPWebLocationsRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebLocations(ctx context.Context, req *pb.UpdateHTTPWebLocationsRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -254,11 +254,11 @@ func (this *HTTPWebService) UpdateHTTPWebLocations(ctx context.Context, req *pb.
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改跳转到HTTPS设置
|
// 更改跳转到HTTPS设置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebRedirectToHTTPS(ctx context.Context, req *pb.UpdateHTTPWebRedirectToHTTPSRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebRedirectToHTTPS(ctx context.Context, req *pb.UpdateHTTPWebRedirectToHTTPSRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -269,11 +269,11 @@ func (this *HTTPWebService) UpdateHTTPWebRedirectToHTTPS(ctx context.Context, re
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改Websocket设置
|
// 更改Websocket设置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebWebsocket(ctx context.Context, req *pb.UpdateHTTPWebWebsocketRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebWebsocket(ctx context.Context, req *pb.UpdateHTTPWebWebsocketRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -284,11 +284,11 @@ func (this *HTTPWebService) UpdateHTTPWebWebsocket(ctx context.Context, req *pb.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改重写规则设置
|
// 更改重写规则设置
|
||||||
func (this *HTTPWebService) UpdateHTTPWebRewriteRules(ctx context.Context, req *pb.UpdateHTTPWebRewriteRulesRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebService) UpdateHTTPWebRewriteRules(ctx context.Context, req *pb.UpdateHTTPWebRewriteRulesRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -299,5 +299,5 @@ func (this *HTTPWebService) UpdateHTTPWebRewriteRules(ctx context.Context, req *
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (this *HTTPWebsocketService) CreateHTTPWebsocket(ctx context.Context, req *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改Websocket配置
|
// 修改Websocket配置
|
||||||
func (this *HTTPWebsocketService) UpdateHTTPWebsocket(ctx context.Context, req *pb.UpdateHTTPWebsocketRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPWebsocketService) UpdateHTTPWebsocket(ctx context.Context, req *pb.UpdateHTTPWebsocketRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -37,5 +37,5 @@ func (this *HTTPWebsocketService) UpdateHTTPWebsocket(ctx context.Context, req *
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func (this *IPItemService) CreateIPItem(ctx context.Context, req *pb.CreateIPIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改IP
|
// 修改IP
|
||||||
func (this *IPItemService) UpdateIPItem(ctx context.Context, req *pb.UpdateIPItemRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *IPItemService) UpdateIPItem(ctx context.Context, req *pb.UpdateIPItemRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -41,11 +41,11 @@ func (this *IPItemService) UpdateIPItem(ctx context.Context, req *pb.UpdateIPIte
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除IP
|
// 删除IP
|
||||||
func (this *IPItemService) DeleteIPItem(ctx context.Context, req *pb.DeleteIPItemRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *IPItemService) DeleteIPItem(ctx context.Context, req *pb.DeleteIPItemRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -56,7 +56,7 @@ func (this *IPItemService) DeleteIPItem(ctx context.Context, req *pb.DeleteIPIte
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算IP数量
|
// 计算IP数量
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ func (this *IPLibraryService) FindAllEnabledIPLibrariesWithType(ctx context.Cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除IP库
|
// 删除IP库
|
||||||
func (this *IPLibraryService) DeleteIPLibrary(ctx context.Context, req *pb.DeleteIPLibraryRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *IPLibraryService) DeleteIPLibrary(ctx context.Context, req *pb.DeleteIPLibraryRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -160,7 +160,7 @@ func (this *IPLibraryService) DeleteIPLibrary(ctx context.Context, req *pb.Delet
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询某个IP信息
|
// 查询某个IP信息
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *IPListService) CreateIPList(ctx context.Context, req *pb.CreateIPLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改IP列表
|
// 修改IP列表
|
||||||
func (this *IPListService) UpdateIPList(ctx context.Context, req *pb.UpdateIPListRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *IPListService) UpdateIPList(ctx context.Context, req *pb.UpdateIPListRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -38,7 +38,7 @@ func (this *IPListService) UpdateIPList(ctx context.Context, req *pb.UpdateIPLis
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找IP列表
|
// 查找IP列表
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func (this *MessageService) ListUnreadMessages(ctx context.Context, req *pb.List
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置消息已读状态
|
// 设置消息已读状态
|
||||||
func (this *MessageService) UpdateMessageRead(ctx context.Context, req *pb.UpdateMessageReadRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *MessageService) UpdateMessageRead(ctx context.Context, req *pb.UpdateMessageReadRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -97,11 +97,11 @@ func (this *MessageService) UpdateMessageRead(ctx context.Context, req *pb.Updat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置一组消息已读状态
|
// 设置一组消息已读状态
|
||||||
func (this *MessageService) UpdateMessagesRead(ctx context.Context, req *pb.UpdateMessagesReadRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *MessageService) UpdateMessagesRead(ctx context.Context, req *pb.UpdateMessagesReadRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -112,11 +112,11 @@ func (this *MessageService) UpdateMessagesRead(ctx context.Context, req *pb.Upda
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置所有消息为已读
|
// 设置所有消息为已读
|
||||||
func (this *MessageService) UpdateAllMessagesRead(ctx context.Context, req *pb.UpdateAllMessagesReadRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *MessageService) UpdateAllMessagesRead(ctx context.Context, req *pb.UpdateAllMessagesReadRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -127,5 +127,5 @@ func (this *MessageService) UpdateAllMessagesRead(ctx context.Context, req *pb.U
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ func (this *NodeService) DisableNode(ctx context.Context, req *pb.DisableNodeReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改节点
|
// 修改节点
|
||||||
func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -261,7 +261,7 @@ func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeReque
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 列出单个节点
|
// 列出单个节点
|
||||||
@@ -377,7 +377,7 @@ func (this *NodeService) FindCurrentNodeConfig(ctx context.Context, req *pb.Find
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新节点状态
|
// 更新节点状态
|
||||||
func (this *NodeService) UpdateNodeStatus(ctx context.Context, req *pb.UpdateNodeStatusRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeService) UpdateNodeStatus(ctx context.Context, req *pb.UpdateNodeStatusRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验节点
|
// 校验节点
|
||||||
_, nodeId, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeNode)
|
_, nodeId, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -397,7 +397,7 @@ func (this *NodeService) UpdateNodeStatus(ctx context.Context, req *pb.UpdateNod
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步集群中的节点版本
|
// 同步集群中的节点版本
|
||||||
@@ -416,7 +416,7 @@ func (this *NodeService) SyncNodesVersionWithCluster(ctx context.Context, req *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改节点安装状态
|
// 修改节点安装状态
|
||||||
func (this *NodeService) UpdateNodeIsInstalled(ctx context.Context, req *pb.UpdateNodeIsInstalledRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeService) UpdateNodeIsInstalled(ctx context.Context, req *pb.UpdateNodeIsInstalledRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -427,7 +427,7 @@ func (this *NodeService) UpdateNodeIsInstalled(ctx context.Context, req *pb.Upda
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 安装节点
|
// 安装节点
|
||||||
@@ -523,7 +523,7 @@ func (this *NodeService) StopNode(ctx context.Context, req *pb.StopNodeRequest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更改节点连接的API节点信息
|
// 更改节点连接的API节点信息
|
||||||
func (this *NodeService) UpdateNodeConnectedAPINodes(ctx context.Context, req *pb.UpdateNodeConnectedAPINodesRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeService) UpdateNodeConnectedAPINodes(ctx context.Context, req *pb.UpdateNodeConnectedAPINodesRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验节点
|
// 校验节点
|
||||||
_, nodeId, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeNode)
|
_, nodeId, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -535,7 +535,7 @@ func (this *NodeService) UpdateNodeConnectedAPINodes(ctx context.Context, req *p
|
|||||||
return nil, errors.Wrap(err)
|
return nil, errors.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算使用某个认证的节点数量
|
// 计算使用某个认证的节点数量
|
||||||
@@ -804,7 +804,7 @@ func (this *NodeService) FindNodeInstallStatus(ctx context.Context, req *pb.Find
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改节点登录信息
|
// 修改节点登录信息
|
||||||
func (this *NodeService) UpdateNodeLogin(ctx context.Context, req *pb.UpdateNodeLoginRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeService) UpdateNodeLogin(ctx context.Context, req *pb.UpdateNodeLoginRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -820,7 +820,7 @@ func (this *NodeService) UpdateNodeLogin(ctx context.Context, req *pb.UpdateNode
|
|||||||
|
|
||||||
err = models.SharedNodeLoginDAO.UpdateNodeLogin(req.Login.Id, req.Login.Name, req.Login.Type, req.Login.Params)
|
err = models.SharedNodeLoginDAO.UpdateNodeLogin(req.Login.Id, req.Login.Name, req.Login.Type, req.Login.Params)
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算某个节点分组内的节点数量
|
// 计算某个节点分组内的节点数量
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/dnsproviders"
|
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/tasks"
|
"github.com/TeaOSLab/EdgeAPI/internal/tasks"
|
||||||
@@ -32,7 +32,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改集群
|
// 修改集群
|
||||||
func (this *NodeClusterService) UpdateNodeCluster(ctx context.Context, req *pb.UpdateNodeClusterRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeClusterService) UpdateNodeCluster(ctx context.Context, req *pb.UpdateNodeClusterRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -43,11 +43,11 @@ func (this *NodeClusterService) UpdateNodeCluster(ctx context.Context, req *pb.U
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 禁用集群
|
// 禁用集群
|
||||||
func (this *NodeClusterService) DeleteNodeCluster(ctx context.Context, req *pb.DeleteNodeClusterRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *NodeClusterService) DeleteNodeCluster(ctx context.Context, req *pb.DeleteNodeClusterRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -58,7 +58,7 @@ func (this *NodeClusterService) DeleteNodeCluster(ctx context.Context, req *pb.D
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找单个集群
|
// 查找单个集群
|
||||||
@@ -242,6 +242,8 @@ func (this *NodeClusterService) ListEnabledNodeClusters(ctx context.Context, req
|
|||||||
InstallDir: cluster.InstallDir,
|
InstallDir: cluster.InstallDir,
|
||||||
UniqueId: cluster.UniqueId,
|
UniqueId: cluster.UniqueId,
|
||||||
Secret: cluster.Secret,
|
Secret: cluster.Secret,
|
||||||
|
DnsName: cluster.DnsName,
|
||||||
|
DnsDomainId: int64(cluster.DnsDomainId),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +270,7 @@ func (this *NodeClusterService) FindNodeClusterHealthCheckConfig(ctx context.Con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改集群健康检查设置
|
// 修改集群健康检查设置
|
||||||
func (this *NodeClusterService) UpdateNodeClusterHealthCheck(ctx context.Context, req *pb.UpdateNodeClusterHealthCheckRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeClusterService) UpdateNodeClusterHealthCheck(ctx context.Context, req *pb.UpdateNodeClusterHealthCheckRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -279,7 +281,7 @@ func (this *NodeClusterService) UpdateNodeClusterHealthCheck(ctx context.Context
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行健康检查
|
// 执行健康检查
|
||||||
@@ -406,7 +408,7 @@ func (this *NodeClusterService) FindEnabledNodeClusterDNS(ctx context.Context, r
|
|||||||
pbProvider = &pb.DNSProvider{
|
pbProvider = &pb.DNSProvider{
|
||||||
Id: int64(provider.Id),
|
Id: int64(provider.Id),
|
||||||
Type: provider.Type,
|
Type: provider.Type,
|
||||||
TypeName: dnsproviders.FindProviderTypeName(provider.Type),
|
TypeName: dnsclients.FindProviderTypeName(provider.Type),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,3 +448,33 @@ func (this *NodeClusterService) CountAllEnabledNodeClustersWithDNSDomainId(ctx c
|
|||||||
}
|
}
|
||||||
return &pb.RPCCountResponse{Count: count}, nil
|
return &pb.RPCCountResponse{Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查集群域名是否已经被使用
|
||||||
|
func (this *NodeClusterService) CheckNodeClusterDNSName(ctx context.Context, req *pb.CheckNodeClusterDNSNameRequest) (*pb.CheckNodeClusterDNSNameResponse, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
exists, err := models.SharedNodeClusterDAO.ExistClusterDNSName(req.DnsName, req.NodeClusterId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &pb.CheckNodeClusterDNSNameResponse{IsUsed: exists}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改集群的域名设置
|
||||||
|
func (this *NodeClusterService) UpdateNodeClusterDNS(ctx context.Context, req *pb.UpdateNodeClusterDNSRequest) (*pb.RPCSuccess, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = models.SharedNodeClusterDAO.UpdateClusterDNS(req.NodeClusterId, req.DnsName, req.DnsDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return rpcutils.Success()
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (this *NodeGrantService) CreateNodeGrant(ctx context.Context, req *pb.Creat
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *NodeGrantService) UpdateNodeGrant(ctx context.Context, req *pb.UpdateNodeGrantRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeGrantService) UpdateNodeGrant(ctx context.Context, req *pb.UpdateNodeGrantRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -37,7 +37,7 @@ func (this *NodeGrantService) UpdateNodeGrant(ctx context.Context, req *pb.Updat
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = models.SharedNodeGrantDAO.UpdateGrant(req.GrantId, req.Name, req.Method, req.Username, req.Password, req.PrivateKey, req.Description, req.NodeId)
|
err = models.SharedNodeGrantDAO.UpdateGrant(req.GrantId, req.Name, req.Method, req.Username, req.Password, req.PrivateKey, req.Description, req.NodeId)
|
||||||
return &pb.RPCUpdateSuccess{}, err
|
return &pb.RPCSuccess{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *NodeGrantService) DisableNodeGrant(ctx context.Context, req *pb.DisableNodeGrantRequest) (*pb.DisableNodeGrantResponse, error) {
|
func (this *NodeGrantService) DisableNodeGrant(ctx context.Context, req *pb.DisableNodeGrantRequest) (*pb.DisableNodeGrantResponse, error) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *NodeGroupService) CreateNodeGroup(ctx context.Context, req *pb.Creat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改分组
|
// 修改分组
|
||||||
func (this *NodeGroupService) UpdateNodeGroup(ctx context.Context, req *pb.UpdateNodeGroupRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeGroupService) UpdateNodeGroup(ctx context.Context, req *pb.UpdateNodeGroupRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -39,11 +39,11 @@ func (this *NodeGroupService) UpdateNodeGroup(ctx context.Context, req *pb.Updat
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除分组
|
// 删除分组
|
||||||
func (this *NodeGroupService) DeleteNodeGroup(ctx context.Context, req *pb.DeleteNodeGroupRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *NodeGroupService) DeleteNodeGroup(ctx context.Context, req *pb.DeleteNodeGroupRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -55,7 +55,7 @@ func (this *NodeGroupService) DeleteNodeGroup(ctx context.Context, req *pb.Delet
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询所有分组
|
// 查询所有分组
|
||||||
@@ -81,7 +81,7 @@ func (this *NodeGroupService) FindAllEnabledNodeGroupsWithClusterId(ctx context.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改分组排序
|
// 修改分组排序
|
||||||
func (this *NodeGroupService) UpdateNodeGroupOrders(ctx context.Context, req *pb.UpdateNodeGroupOrdersRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeGroupService) UpdateNodeGroupOrders(ctx context.Context, req *pb.UpdateNodeGroupOrdersRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -92,7 +92,7 @@ func (this *NodeGroupService) UpdateNodeGroupOrders(ctx context.Context, req *pb
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找单个分组信息
|
// 查找单个分组信息
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *NodeIPAddressService) CreateNodeIPAddress(ctx context.Context, req *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改IP地址
|
// 修改IP地址
|
||||||
func (this *NodeIPAddressService) UpdateNodeIPAddress(ctx context.Context, req *pb.UpdateNodeIPAddressRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeIPAddressService) UpdateNodeIPAddress(ctx context.Context, req *pb.UpdateNodeIPAddressRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -39,11 +39,11 @@ func (this *NodeIPAddressService) UpdateNodeIPAddress(ctx context.Context, req *
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改IP地址所属节点
|
// 修改IP地址所属节点
|
||||||
func (this *NodeIPAddressService) UpdateNodeIPAddressNodeId(ctx context.Context, req *pb.UpdateNodeIPAddressNodeIdRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *NodeIPAddressService) UpdateNodeIPAddressNodeId(ctx context.Context, req *pb.UpdateNodeIPAddressNodeIdRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -55,7 +55,7 @@ func (this *NodeIPAddressService) UpdateNodeIPAddressNodeId(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 禁用单个IP地址
|
// 禁用单个IP地址
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func (this *OriginService) CreateOrigin(ctx context.Context, req *pb.CreateOrigi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改源站
|
// 修改源站
|
||||||
func (this *OriginService) UpdateOrigin(ctx context.Context, req *pb.UpdateOriginRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *OriginService) UpdateOrigin(ctx context.Context, req *pb.UpdateOriginRequest) (*pb.RPCSuccess, error) {
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -57,7 +57,7 @@ func (this *OriginService) UpdateOrigin(ctx context.Context, req *pb.UpdateOrigi
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找单个源站信息
|
// 查找单个源站信息
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func (this *ReverseProxyService) FindEnabledReverseProxyConfig(ctx context.Conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改反向代理调度算法
|
// 修改反向代理调度算法
|
||||||
func (this *ReverseProxyService) UpdateReverseProxyScheduling(ctx context.Context, req *pb.UpdateReverseProxySchedulingRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ReverseProxyService) UpdateReverseProxyScheduling(ctx context.Context, req *pb.UpdateReverseProxySchedulingRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -86,11 +86,11 @@ func (this *ReverseProxyService) UpdateReverseProxyScheduling(ctx context.Contex
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改主要源站信息
|
// 修改主要源站信息
|
||||||
func (this *ReverseProxyService) UpdateReverseProxyPrimaryOrigins(ctx context.Context, req *pb.UpdateReverseProxyPrimaryOriginsRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ReverseProxyService) UpdateReverseProxyPrimaryOrigins(ctx context.Context, req *pb.UpdateReverseProxyPrimaryOriginsRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -102,11 +102,11 @@ func (this *ReverseProxyService) UpdateReverseProxyPrimaryOrigins(ctx context.Co
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改备用源站信息
|
// 修改备用源站信息
|
||||||
func (this *ReverseProxyService) UpdateReverseProxyBackupOrigins(ctx context.Context, req *pb.UpdateReverseProxyBackupOriginsRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ReverseProxyService) UpdateReverseProxyBackupOrigins(ctx context.Context, req *pb.UpdateReverseProxyBackupOriginsRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -118,11 +118,11 @@ func (this *ReverseProxyService) UpdateReverseProxyBackupOrigins(ctx context.Con
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改是否启用
|
// 修改是否启用
|
||||||
func (this *ReverseProxyService) UpdateReverseProxy(ctx context.Context, req *pb.UpdateReverseProxyRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ReverseProxyService) UpdateReverseProxy(ctx context.Context, req *pb.UpdateReverseProxyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -134,5 +134,5 @@ func (this *ReverseProxyService) UpdateReverseProxy(ctx context.Context, req *pb
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func (this *ServerService) CreateServer(ctx context.Context, req *pb.CreateServe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改服务
|
// 修改服务
|
||||||
func (this *ServerService) UpdateServerBasic(ctx context.Context, req *pb.UpdateServerBasicRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerBasic(ctx context.Context, req *pb.UpdateServerBasicRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -74,11 +74,11 @@ func (this *ServerService) UpdateServerBasic(ctx context.Context, req *pb.Update
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改HTTP服务
|
// 修改HTTP服务
|
||||||
func (this *ServerService) UpdateServerHTTP(ctx context.Context, req *pb.UpdateServerHTTPRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerHTTP(ctx context.Context, req *pb.UpdateServerHTTPRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -104,11 +104,11 @@ func (this *ServerService) UpdateServerHTTP(ctx context.Context, req *pb.UpdateS
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改HTTPS服务
|
// 修改HTTPS服务
|
||||||
func (this *ServerService) UpdateServerHTTPS(ctx context.Context, req *pb.UpdateServerHTTPSRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerHTTPS(ctx context.Context, req *pb.UpdateServerHTTPSRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -134,11 +134,11 @@ func (this *ServerService) UpdateServerHTTPS(ctx context.Context, req *pb.Update
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改TCP服务
|
// 修改TCP服务
|
||||||
func (this *ServerService) UpdateServerTCP(ctx context.Context, req *pb.UpdateServerTCPRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerTCP(ctx context.Context, req *pb.UpdateServerTCPRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -164,11 +164,11 @@ func (this *ServerService) UpdateServerTCP(ctx context.Context, req *pb.UpdateSe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改TLS服务
|
// 修改TLS服务
|
||||||
func (this *ServerService) UpdateServerTLS(ctx context.Context, req *pb.UpdateServerTLSRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerTLS(ctx context.Context, req *pb.UpdateServerTLSRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -194,11 +194,11 @@ func (this *ServerService) UpdateServerTLS(ctx context.Context, req *pb.UpdateSe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改Unix服务
|
// 修改Unix服务
|
||||||
func (this *ServerService) UpdateServerUnix(ctx context.Context, req *pb.UpdateServerUnixRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerUnix(ctx context.Context, req *pb.UpdateServerUnixRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -224,11 +224,11 @@ func (this *ServerService) UpdateServerUnix(ctx context.Context, req *pb.UpdateS
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改UDP服务
|
// 修改UDP服务
|
||||||
func (this *ServerService) UpdateServerUDP(ctx context.Context, req *pb.UpdateServerUDPRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerUDP(ctx context.Context, req *pb.UpdateServerUDPRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -254,11 +254,11 @@ func (this *ServerService) UpdateServerUDP(ctx context.Context, req *pb.UpdateSe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改Web服务
|
// 修改Web服务
|
||||||
func (this *ServerService) UpdateServerWeb(ctx context.Context, req *pb.UpdateServerWebRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerWeb(ctx context.Context, req *pb.UpdateServerWebRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -284,11 +284,11 @@ func (this *ServerService) UpdateServerWeb(ctx context.Context, req *pb.UpdateSe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改反向代理服务
|
// 修改反向代理服务
|
||||||
func (this *ServerService) UpdateServerReverseProxy(ctx context.Context, req *pb.UpdateServerReverseProxyRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerReverseProxy(ctx context.Context, req *pb.UpdateServerReverseProxyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -314,11 +314,11 @@ func (this *ServerService) UpdateServerReverseProxy(ctx context.Context, req *pb
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改域名服务
|
// 修改域名服务
|
||||||
func (this *ServerService) UpdateServerNames(ctx context.Context, req *pb.UpdateServerNamesRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerService) UpdateServerNames(ctx context.Context, req *pb.UpdateServerNamesRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -344,7 +344,7 @@ func (this *ServerService) UpdateServerNames(ctx context.Context, req *pb.Update
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算服务数量
|
// 计算服务数量
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (this *ServerGroupService) CreateServerGroup(ctx context.Context, req *pb.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改分组
|
// 修改分组
|
||||||
func (this *ServerGroupService) UpdateServerGroup(ctx context.Context, req *pb.UpdateServerGroupRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerGroupService) UpdateServerGroup(ctx context.Context, req *pb.UpdateServerGroupRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -39,11 +39,11 @@ func (this *ServerGroupService) UpdateServerGroup(ctx context.Context, req *pb.U
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除分组
|
// 删除分组
|
||||||
func (this *ServerGroupService) DeleteServerGroup(ctx context.Context, req *pb.DeleteServerGroupRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *ServerGroupService) DeleteServerGroup(ctx context.Context, req *pb.DeleteServerGroupRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -55,7 +55,7 @@ func (this *ServerGroupService) DeleteServerGroup(ctx context.Context, req *pb.D
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询所有分组
|
// 查询所有分组
|
||||||
@@ -81,7 +81,7 @@ func (this *ServerGroupService) FindAllEnabledServerGroups(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改分组排序
|
// 修改分组排序
|
||||||
func (this *ServerGroupService) UpdateServerGroupOrders(ctx context.Context, req *pb.UpdateServerGroupOrdersRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *ServerGroupService) UpdateServerGroupOrders(ctx context.Context, req *pb.UpdateServerGroupOrdersRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -92,7 +92,7 @@ func (this *ServerGroupService) UpdateServerGroupOrders(ctx context.Context, req
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找单个分组信息
|
// 查找单个分组信息
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func (this *SSLCertService) CreateSSLCert(ctx context.Context, req *pb.CreateSSL
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改Cert
|
// 修改Cert
|
||||||
func (this *SSLCertService) UpdateSSLCert(ctx context.Context, req *pb.UpdateSSLCertRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *SSLCertService) UpdateSSLCert(ctx context.Context, req *pb.UpdateSSLCertRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -42,7 +42,7 @@ func (this *SSLCertService) UpdateSSLCert(ctx context.Context, req *pb.UpdateSSL
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找证书配置
|
// 查找证书配置
|
||||||
@@ -66,7 +66,7 @@ func (this *SSLCertService) FindEnabledSSLCertConfig(ctx context.Context, req *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除证书
|
// 删除证书
|
||||||
func (this *SSLCertService) DeleteSSLCert(ctx context.Context, req *pb.DeleteSSLCertRequest) (*pb.RPCDeleteSuccess, error) {
|
func (this *SSLCertService) DeleteSSLCert(ctx context.Context, req *pb.DeleteSSLCertRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -78,7 +78,7 @@ func (this *SSLCertService) DeleteSSLCert(ctx context.Context, req *pb.DeleteSSL
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCDeleteSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算匹配的Cert数量
|
// 计算匹配的Cert数量
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func (this *SSLPolicyService) CreateSSLPolicy(ctx context.Context, req *pb.Creat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改Policy
|
// 修改Policy
|
||||||
func (this *SSLPolicyService) UpdateSSLPolicy(ctx context.Context, req *pb.UpdateSSLPolicyRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *SSLPolicyService) UpdateSSLPolicy(ctx context.Context, req *pb.UpdateSSLPolicyRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -40,7 +40,7 @@ func (this *SSLPolicyService) UpdateSSLPolicy(ctx context.Context, req *pb.Updat
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找Policy
|
// 查找Policy
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ type SysSettingService struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更改配置
|
// 更改配置
|
||||||
func (this *SysSettingService) UpdateSysSetting(ctx context.Context, req *pb.UpdateSysSettingRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *SysSettingService) UpdateSysSetting(ctx context.Context, req *pb.UpdateSysSettingRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -23,7 +23,7 @@ func (this *SysSettingService) UpdateSysSetting(ctx context.Context, req *pb.Upd
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取配置
|
// 读取配置
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func (this *HTTPGzipService) FindEnabledHTTPGzipConfig(ctx context.Context, req
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改Gzip配置
|
// 修改Gzip配置
|
||||||
func (this *HTTPGzipService) UpdateHTTPGzip(ctx context.Context, req *pb.UpdateHTTPGzipRequest) (*pb.RPCUpdateSuccess, error) {
|
func (this *HTTPGzipService) UpdateHTTPGzip(ctx context.Context, req *pb.UpdateHTTPGzipRequest) (*pb.RPCSuccess, error) {
|
||||||
// 校验请求
|
// 校验请求
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -105,5 +105,5 @@ func (this *HTTPGzipService) UpdateHTTPGzip(ctx context.Context, req *pb.UpdateH
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,14 +125,14 @@ func ValidateRequest(ctx context.Context, userTypes ...UserType) (userType UserT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回Update成功信息
|
// 返回操作成功信息
|
||||||
func RPCUpdateSuccess() (*pb.RPCUpdateSuccess, error) {
|
func Success() (*pb.RPCSuccess, error) {
|
||||||
return &pb.RPCUpdateSuccess{}, nil
|
return &pb.RPCSuccess{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回Delete成功信息
|
// 返回数量
|
||||||
func RPCDeleteSuccess() (*pb.RPCDeleteSuccess, error) {
|
func NewCountResponse(count int64) (*pb.RPCCountResponse, error) {
|
||||||
return &pb.RPCDeleteSuccess{}, nil
|
return &pb.RPCCountResponse{Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 包装错误
|
// 包装错误
|
||||||
|
|||||||
Reference in New Issue
Block a user