mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 15:00:27 +08:00
调整SSL证书目录结构
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package teaconst
|
||||
|
||||
const (
|
||||
Version = "0.0.2.1"
|
||||
Version = "0.0.3"
|
||||
|
||||
ProductName = "Edge API"
|
||||
ProcessName = "edge-api"
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -61,3 +68,96 @@ func (this *ACMEUserDAO) FindEnabledACMEUser(id int64) (*ACMEUser, error) {
|
||||
}
|
||||
return result.(*ACMEUser), err
|
||||
}
|
||||
|
||||
// 创建用户
|
||||
func (this *ACMEUserDAO) CreateACMEUser(adminId int64, userId int64, email string, description string) (int64, error) {
|
||||
// 生成私钥
|
||||
privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
privateKeyData, err := x509.MarshalPKCS8PrivateKey(privateKey)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
privateKeyText := base64.StdEncoding.EncodeToString(privateKeyData)
|
||||
|
||||
op := NewACMEUserOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.Email = email
|
||||
op.Description = description
|
||||
op.PrivateKey = privateKeyText
|
||||
op.State = ACMEUserStateEnabled
|
||||
_, err = this.Save(op)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return types.Int64(op.Id), nil
|
||||
}
|
||||
|
||||
// 查找用户列表
|
||||
func (this *ACMEUserDAO) UpdateACMEUser(acmeUserId int64, description string) error {
|
||||
if acmeUserId <= 0 {
|
||||
return errors.New("invalid acmeUserId")
|
||||
}
|
||||
op := NewACMEUserOperator()
|
||||
op.Id = acmeUserId
|
||||
op.Description = description
|
||||
_, err := this.Save(op)
|
||||
return err
|
||||
}
|
||||
|
||||
// 计算用户数量
|
||||
func (this *ACMEUserDAO) CountACMEUsersWithAdminId(adminId int64, userId int64) (int64, error) {
|
||||
query := this.Query()
|
||||
if adminId > 0 {
|
||||
query.Attr("adminId", adminId)
|
||||
}
|
||||
if userId > 0 {
|
||||
query.Attr("userId", userId)
|
||||
}
|
||||
|
||||
return query.
|
||||
State(ACMEUserStateEnabled).
|
||||
Count()
|
||||
}
|
||||
|
||||
// 列出当前管理员的用户
|
||||
func (this *ACMEUserDAO) ListACMEUsers(adminId int64, userId int64, offset int64, size int64) (result []*ACMEUser, err error) {
|
||||
query := this.Query()
|
||||
if adminId > 0 {
|
||||
query.Attr("adminId", adminId)
|
||||
}
|
||||
if userId > 0 {
|
||||
query.Attr("userId", userId)
|
||||
}
|
||||
|
||||
_, err = query.
|
||||
State(ACMEUserStateEnabled).
|
||||
Offset(offset).
|
||||
Limit(size).
|
||||
Slice(&result).
|
||||
DescPk().
|
||||
FindAll()
|
||||
return
|
||||
}
|
||||
|
||||
// 检查用户权限
|
||||
func (this *ACMEUserDAO) CheckACMEUser(acmeUserId int64, adminId int64, userId int64) (bool, error) {
|
||||
if acmeUserId <= 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
query := this.Query()
|
||||
if adminId > 0 {
|
||||
query.Attr("adminId", adminId)
|
||||
} else if userId > 0 {
|
||||
query.Attr("userId", userId)
|
||||
} else {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return query.Exist()
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ func (this *APINode) listenRPC(listener net.Listener, tlsConfig *tls.Config) err
|
||||
pb.RegisterDNSProviderServiceServer(rpcServer, &services.DNSProviderService{})
|
||||
pb.RegisterDNSDomainServiceServer(rpcServer, &services.DNSDomainService{})
|
||||
pb.RegisterDNSServiceServer(rpcServer, &services.DNSService{})
|
||||
pb.RegisterACMEUserServiceServer(rpcServer, &services.ACMEUserService{})
|
||||
err := rpcServer.Serve(listener)
|
||||
if err != nil {
|
||||
return errors.New("[API_NODE]start rpc failed: " + err.Error())
|
||||
|
||||
146
internal/rpc/services/service_acme_user.go
Normal file
146
internal/rpc/services/service_acme_user.go
Normal file
@@ -0,0 +1,146 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
// 用户服务
|
||||
type ACMEUserService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建用户
|
||||
func (this *ACMEUserService) CreateACMEUser(ctx context.Context, req *pb.CreateACMEUserRequest) (*pb.CreateACMEUserResponse, error) {
|
||||
// 校验请求
|
||||
adminId, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
acmeUserId, err := models.SharedACMEUserDAO.CreateACMEUser(adminId, userId, req.Email, req.Description)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pb.CreateACMEUserResponse{AcmeUserId: acmeUserId}, nil
|
||||
}
|
||||
|
||||
// 修改用户
|
||||
func (this *ACMEUserService) UpdateACMEUser(ctx context.Context, req *pb.UpdateACMEUserRequest) (*pb.RPCSuccess, error) {
|
||||
// 校验请求
|
||||
adminId, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 检查是否有权限
|
||||
b, err := models.SharedACMEUserDAO.CheckACMEUser(req.AcmeUserId, adminId, userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !b {
|
||||
return nil, this.PermissionError()
|
||||
}
|
||||
|
||||
err = models.SharedACMEUserDAO.UpdateACMEUser(req.AcmeUserId, req.Description)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
func (this *ACMEUserService) DeleteACMEUser(ctx context.Context, req *pb.DeleteACMEUserRequest) (*pb.RPCSuccess, error) {
|
||||
// 校验请求
|
||||
adminId, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 检查是否有权限
|
||||
b, err := models.SharedACMEUserDAO.CheckACMEUser(req.AcmeUserId, adminId, userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !b {
|
||||
return nil, this.PermissionError()
|
||||
}
|
||||
|
||||
err = models.SharedACMEUserDAO.DisableACMEUser(req.AcmeUserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算用户数量
|
||||
func (this *ACMEUserService) CountACMEUsers(ctx context.Context, req *pb.CountAcmeUsersRequest) (*pb.RPCCountResponse, error) {
|
||||
// 校验请求
|
||||
adminId, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
count, err := models.SharedACMEUserDAO.CountACMEUsersWithAdminId(adminId, userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return this.ResponseCount(count)
|
||||
}
|
||||
|
||||
// 列出单页用户
|
||||
func (this *ACMEUserService) ListACMEUsers(ctx context.Context, req *pb.ListACMEUsersRequest) (*pb.ListACMEUsersResponse, error) {
|
||||
// 校验请求
|
||||
adminId, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
acmeUsers, err := models.SharedACMEUserDAO.ListACMEUsers(adminId, userId, req.Offset, req.Size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := []*pb.ACMEUser{}
|
||||
for _, user := range acmeUsers {
|
||||
result = append(result, &pb.ACMEUser{
|
||||
Id: int64(user.Id),
|
||||
Email: user.Email,
|
||||
Description: user.Description,
|
||||
CreatedAt: int64(user.CreatedAt),
|
||||
})
|
||||
}
|
||||
return &pb.ListACMEUsersResponse{AcmeUsers: result}, nil
|
||||
}
|
||||
|
||||
// 查找单个用户
|
||||
func (this *ACMEUserService) FindEnabledACMEUser(ctx context.Context, req *pb.FindEnabledACMEUserRequest) (*pb.FindEnabledACMEUserResponse, error) {
|
||||
// 校验请求
|
||||
adminId, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 检查是否有权限
|
||||
b, err := models.SharedACMEUserDAO.CheckACMEUser(req.AcmeUserId, adminId, userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !b {
|
||||
return nil, this.PermissionError()
|
||||
}
|
||||
|
||||
acmeUser, err := models.SharedACMEUserDAO.FindEnabledACMEUser(req.AcmeUserId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if acmeUser == nil {
|
||||
return &pb.FindEnabledACMEUserResponse{AcmeUser: nil}, nil
|
||||
}
|
||||
return &pb.FindEnabledACMEUserResponse{AcmeUser: &pb.ACMEUser{
|
||||
Id: int64(acmeUser.Id),
|
||||
Email: acmeUser.Email,
|
||||
Description: acmeUser.Description,
|
||||
CreatedAt: int64(acmeUser.CreatedAt),
|
||||
}}, nil
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
)
|
||||
|
||||
type AdminService struct {
|
||||
BaseService
|
||||
|
||||
debug bool
|
||||
}
|
||||
|
||||
@@ -168,7 +170,7 @@ func (this *AdminService) UpdateAdmin(ctx context.Context, req *pb.UpdateAdminRe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 修改管理员登录信息
|
||||
@@ -191,5 +193,5 @@ func (this *AdminService) UpdateAdminLogin(ctx context.Context, req *pb.UpdateAd
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,44 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type BaseService struct {
|
||||
}
|
||||
|
||||
// 校验管理员和用户
|
||||
func (this *BaseService) ValidateAdminAndUser(ctx context.Context) (adminId int64, userId int64, err error) {
|
||||
reqUserType, reqUserId, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin, rpcutils.UserTypeUser)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
adminId = int64(0)
|
||||
userId = int64(0)
|
||||
switch reqUserType {
|
||||
case rpcutils.UserTypeAdmin:
|
||||
adminId = reqUserId
|
||||
case rpcutils.UserTypeUser:
|
||||
userId = reqUserId
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 返回成功
|
||||
func (this *BaseService) Success() (*pb.RPCSuccess, error) {
|
||||
return rpcutils.Success()
|
||||
}
|
||||
|
||||
// 返回数字
|
||||
func (this *BaseService) ResponseCount(count int64) (*pb.RPCCountResponse, error) {
|
||||
return &pb.RPCCountResponse{Count: count}, nil
|
||||
}
|
||||
|
||||
// 返回权限错误
|
||||
func (this *BaseService) PermissionError() error {
|
||||
return errors.New("Permission Denied")
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
// 数据库节点相关服务
|
||||
type DBNodeService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建数据库节点
|
||||
@@ -37,7 +38,7 @@ func (this *DBNodeService) UpdateDBNode(ctx context.Context, req *pb.UpdateDBNod
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除节点
|
||||
@@ -51,7 +52,7 @@ func (this *DBNodeService) DeleteDBNode(ctx context.Context, req *pb.DeleteDBNod
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算可用的数据库节点数量
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
// DNS域名相关服务
|
||||
type DNSDomainService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建域名
|
||||
@@ -98,7 +99,7 @@ func (this *DNSDomainService) UpdateDNSDomain(ctx context.Context, req *pb.Updat
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除域名
|
||||
@@ -113,7 +114,7 @@ func (this *DNSDomainService) DeleteDNSDomain(ctx context.Context, req *pb.Delet
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查询单个域名完整信息
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
// DNS服务商相关服务
|
||||
type DNSProviderService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建服务商
|
||||
@@ -40,7 +41,7 @@ func (this *DNSProviderService) UpdateDNSProvider(ctx context.Context, req *pb.U
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算服务商数量
|
||||
@@ -96,7 +97,7 @@ func (this *DNSProviderService) DeleteDNSProvider(ctx context.Context, req *pb.D
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找单个服务商
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// 文件相关服务
|
||||
type FileService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建文件
|
||||
@@ -38,5 +39,5 @@ func (this *FileService) UpdateFileFinished(ctx context.Context, req *pb.UpdateF
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type HTTPCachePolicyService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 获取所有可用策略
|
||||
@@ -62,7 +63,7 @@ func (this *HTTPCachePolicyService) UpdateHTTPCachePolicy(ctx context.Context, r
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除缓存策略
|
||||
@@ -78,7 +79,7 @@ func (this *HTTPCachePolicyService) DeleteHTTPCachePolicy(ctx context.Context, r
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算缓存策略数量
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
// HTTP防火墙(WAF)相关服务
|
||||
type HTTPFirewallPolicyService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 获取所有可用策略
|
||||
@@ -232,7 +233,7 @@ func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicy(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 修改分组信息
|
||||
@@ -248,7 +249,7 @@ func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicyGroups(ctx contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 修改inbound信息
|
||||
@@ -264,7 +265,7 @@ func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallInboundConfig(ctx conte
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算可用的防火墙策略数量
|
||||
@@ -323,7 +324,7 @@ func (this *HTTPFirewallPolicyService) DeleteFirewallPolicy(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找单个防火墙配置
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
// WAF规则分组相关服务
|
||||
type HTTPFirewallRuleGroupService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 设置是否启用分组
|
||||
@@ -25,7 +26,7 @@ func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupIsOn(ctx co
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 创建分组
|
||||
@@ -56,7 +57,7 @@ func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroup(ctx contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 获取分组配置
|
||||
@@ -122,5 +123,5 @@ func (this *HTTPFirewallRuleGroupService) UpdateHTTPFirewallRuleGroupSets(ctx co
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
// 规则集相关服务
|
||||
type HTTPFirewallRuleSetService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 根据配置创建规则集
|
||||
@@ -48,7 +49,7 @@ func (this *HTTPFirewallRuleSetService) UpdateHTTPFirewallRuleSetIsOn(ctx contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找规则集配置
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type HTTPLocationService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建路径规则
|
||||
@@ -41,7 +42,7 @@ func (this *HTTPLocationService) UpdateHTTPLocation(ctx context.Context, req *pb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找路径规则配置
|
||||
@@ -75,7 +76,7 @@ func (this *HTTPLocationService) DeleteHTTPLocation(ctx context.Context, req *pb
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找反向代理设置
|
||||
@@ -178,5 +179,5 @@ func (this *HTTPLocationService) UpdateHTTPLocationReverseProxy(ctx context.Cont
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type HTTPPageService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建Page
|
||||
@@ -41,7 +42,7 @@ func (this *HTTPPageService) UpdateHTTPPage(ctx context.Context, req *pb.UpdateH
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找单个Page配置
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type HTTPRewriteRuleService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建重写规则
|
||||
@@ -40,5 +41,5 @@ func (this *HTTPRewriteRuleService) UpdateHTTPRewriteRule(ctx context.Context, r
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type HTTPWebService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建Web配置
|
||||
@@ -161,7 +162,7 @@ func (this *HTTPWebService) UpdateHTTPWebShutdown(ctx context.Context, req *pb.U
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改Pages
|
||||
@@ -176,7 +177,7 @@ func (this *HTTPWebService) UpdateHTTPWebPages(ctx context.Context, req *pb.Upda
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改访问日志配置
|
||||
@@ -191,7 +192,7 @@ func (this *HTTPWebService) UpdateHTTPWebAccessLog(ctx context.Context, req *pb.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改统计配置
|
||||
@@ -206,7 +207,7 @@ func (this *HTTPWebService) UpdateHTTPWebStat(ctx context.Context, req *pb.Updat
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改缓存配置
|
||||
@@ -222,7 +223,7 @@ func (this *HTTPWebService) UpdateHTTPWebCache(ctx context.Context, req *pb.Upda
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改防火墙设置
|
||||
@@ -238,7 +239,7 @@ func (this *HTTPWebService) UpdateHTTPWebFirewall(ctx context.Context, req *pb.U
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改路径规则设置
|
||||
@@ -254,7 +255,7 @@ func (this *HTTPWebService) UpdateHTTPWebLocations(ctx context.Context, req *pb.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改跳转到HTTPS设置
|
||||
@@ -269,7 +270,7 @@ func (this *HTTPWebService) UpdateHTTPWebRedirectToHTTPS(ctx context.Context, re
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改Websocket设置
|
||||
@@ -284,7 +285,7 @@ func (this *HTTPWebService) UpdateHTTPWebWebsocket(ctx context.Context, req *pb.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 更改重写规则设置
|
||||
@@ -299,5 +300,5 @@ func (this *HTTPWebService) UpdateHTTPWebRewriteRules(ctx context.Context, req *
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type HTTPWebsocketService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建Websocket配置
|
||||
@@ -37,5 +38,5 @@ func (this *HTTPWebsocketService) UpdateHTTPWebsocket(ctx context.Context, req *
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// IP条目相关服务
|
||||
type IPItemService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建IP
|
||||
@@ -41,7 +42,7 @@ func (this *IPItemService) UpdateIPItem(ctx context.Context, req *pb.UpdateIPIte
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除IP
|
||||
@@ -56,7 +57,7 @@ func (this *IPItemService) DeleteIPItem(ctx context.Context, req *pb.DeleteIPIte
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算IP数量
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
// IP库服务
|
||||
type IPLibraryService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建IP库
|
||||
@@ -160,7 +161,7 @@ func (this *IPLibraryService) DeleteIPLibrary(ctx context.Context, req *pb.Delet
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查询某个IP信息
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// IP名单相关服务
|
||||
type IPListService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建IP列表
|
||||
@@ -38,7 +39,7 @@ func (this *IPListService) UpdateIPList(ctx context.Context, req *pb.UpdateIPLis
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找IP列表
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// 消息相关服务
|
||||
type MessageService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 计算未读消息数
|
||||
@@ -97,7 +98,7 @@ func (this *MessageService) UpdateMessageRead(ctx context.Context, req *pb.Updat
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 设置一组消息已读状态
|
||||
@@ -112,7 +113,7 @@ func (this *MessageService) UpdateMessagesRead(ctx context.Context, req *pb.Upda
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 设置所有消息为已读
|
||||
@@ -127,5 +128,5 @@ func (this *MessageService) UpdateAllMessagesRead(ctx context.Context, req *pb.U
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ func init() {
|
||||
|
||||
// 边缘节点相关服务
|
||||
type NodeService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建节点
|
||||
@@ -305,7 +306,7 @@ func (this *NodeService) DeleteNode(ctx context.Context, req *pb.DeleteNodeReque
|
||||
}
|
||||
}()
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 修改节点
|
||||
@@ -649,7 +650,7 @@ func (this *NodeService) UpdateNodeConnectedAPINodes(ctx context.Context, req *p
|
||||
return nil, errors.Wrap(err)
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算使用某个认证的节点数量
|
||||
@@ -934,7 +935,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)
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算某个节点分组内的节点数量
|
||||
@@ -1131,7 +1132,7 @@ func (this *NodeService) UpdateNodeDNS(ctx context.Context, req *pb.UpdateNodeDN
|
||||
}
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 自动同步DNS状态
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type NodeClusterService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建集群
|
||||
@@ -58,7 +59,7 @@ func (this *NodeClusterService) DeleteNodeCluster(ctx context.Context, req *pb.D
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找单个集群
|
||||
@@ -281,7 +282,7 @@ func (this *NodeClusterService) UpdateNodeClusterHealthCheck(ctx context.Context
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 执行健康检查
|
||||
@@ -487,7 +488,7 @@ func (this *NodeClusterService) UpdateNodeClusterDNS(ctx context.Context, req *p
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 检查集群的DNS是否有变化
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// 节点分组相关服务
|
||||
type NodeGroupService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建分组
|
||||
@@ -39,7 +40,7 @@ func (this *NodeGroupService) UpdateNodeGroup(ctx context.Context, req *pb.Updat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除分组
|
||||
@@ -55,7 +56,7 @@ func (this *NodeGroupService) DeleteNodeGroup(ctx context.Context, req *pb.Delet
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查询所有分组
|
||||
@@ -92,7 +93,7 @@ func (this *NodeGroupService) UpdateNodeGroupOrders(ctx context.Context, req *pb
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找单个分组信息
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// 服务分组相关服务
|
||||
type ServerGroupService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建分组
|
||||
@@ -39,7 +40,7 @@ func (this *ServerGroupService) UpdateServerGroup(ctx context.Context, req *pb.U
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 删除分组
|
||||
@@ -55,7 +56,7 @@ func (this *ServerGroupService) DeleteServerGroup(ctx context.Context, req *pb.D
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查询所有分组
|
||||
@@ -92,7 +93,7 @@ func (this *ServerGroupService) UpdateServerGroupOrders(ctx context.Context, req
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找单个分组信息
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
// SSL证书相关服务
|
||||
type SSLCertService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建Cert
|
||||
@@ -42,7 +43,7 @@ func (this *SSLCertService) UpdateSSLCert(ctx context.Context, req *pb.UpdateSSL
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找证书配置
|
||||
@@ -78,7 +79,7 @@ func (this *SSLCertService) DeleteSSLCert(ctx context.Context, req *pb.DeleteSSL
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 计算匹配的Cert数量
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type SSLPolicyService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 创建Policy
|
||||
@@ -40,7 +41,7 @@ func (this *SSLPolicyService) UpdateSSLPolicy(ctx context.Context, req *pb.Updat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 查找Policy
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type SysSettingService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 更改配置
|
||||
@@ -22,8 +23,8 @@ func (this *SysSettingService) UpdateSysSetting(ctx context.Context, req *pb.Upd
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rpcutils.Success()
|
||||
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// 读取配置
|
||||
|
||||
Reference in New Issue
Block a user