mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-01 19:36:36 +08:00
节点可以单独设置所使用的API节点地址
This commit is contained in:
@@ -2041,6 +2041,14 @@ func (this *NodeService) FindEnabledNodeConfigInfo(ctx context.Context, req *pb.
|
||||
if dnsResolverConfig != nil {
|
||||
result.HasSystemSettings = dnsResolverConfig.Type != nodeconfigs.DNSResolverTypeDefault
|
||||
}
|
||||
|
||||
if !result.HasSystemSettings {
|
||||
// api node addresses
|
||||
var apiNodeAddrs = node.DecodeAPINodeAddrs()
|
||||
if len(apiNodeAddrs) > 0 {
|
||||
result.HasSystemSettings = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ddos protection
|
||||
@@ -2142,3 +2150,50 @@ func (this *NodeService) UpdateNodeRegionInfo(ctx context.Context, req *pb.Updat
|
||||
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// FindNodeAPIConfig 查找单个节点的API相关配置
|
||||
func (this *NodeService) FindNodeAPIConfig(ctx context.Context, req *pb.FindNodeAPIConfigRequest) (*pb.FindNodeAPIConfigResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tx = this.NullTx()
|
||||
node, err := models.SharedNodeDAO.FindNodeAPIConfig(tx, req.NodeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if node == nil {
|
||||
return &pb.FindNodeAPIConfigResponse{
|
||||
ApiNodeAddrsJSON: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &pb.FindNodeAPIConfigResponse{
|
||||
ApiNodeAddrsJSON: node.ApiNodeAddrs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateNodeAPIConfig 修改某个节点的API相关配置
|
||||
func (this *NodeService) UpdateNodeAPIConfig(ctx context.Context, req *pb.UpdateNodeAPIConfigRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tx = this.NullTx()
|
||||
var apiNodeAddrs = []*serverconfigs.NetworkAddressConfig{}
|
||||
if len(req.ApiNodeAddrsJSON) > 0 {
|
||||
err = json.Unmarshal(req.ApiNodeAddrsJSON, &apiNodeAddrs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
err = models.SharedNodeDAO.UpdateNodeAPIConfig(tx, req.NodeId, apiNodeAddrs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
23
internal/rpc/services/service_ping.go
Normal file
23
internal/rpc/services/service_ping.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
// PingService Ping服务
|
||||
// 用来测试连接是否可用
|
||||
type PingService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// Ping 发起Ping
|
||||
func (this *PingService) Ping(ctx context.Context, req *pb.PingRequest) (*pb.PingResponse, error) {
|
||||
_, _, err := this.ValidateNodeId(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pb.PingResponse{}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user