mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	API取消对节点时钟的检查
This commit is contained in:
		@@ -16,7 +16,6 @@ import (
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
	"google.golang.org/grpc/metadata"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type BaseService struct {
 | 
			
		||||
@@ -162,12 +161,6 @@ func (this *BaseService) ValidateNodeId(ctx context.Context, roles ...rpcutils.U
 | 
			
		||||
		return rpcutils.UserTypeNone, 0, errors.New("decode token error: " + err.Error())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	timestamp := m.GetInt64("timestamp")
 | 
			
		||||
	if time.Now().Unix()-timestamp > 600 {
 | 
			
		||||
		// 请求超过10分钟认为超时
 | 
			
		||||
		return rpcutils.UserTypeNone, 0, errors.New("authenticate timeout, please check your system clock")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	role = apiToken.Role
 | 
			
		||||
	switch apiToken.Role {
 | 
			
		||||
	case rpcutils.UserTypeNode:
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ import (
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
	"google.golang.org/grpc/metadata"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type UserType = string
 | 
			
		||||
@@ -125,12 +124,6 @@ func ValidateRequest(ctx context.Context, userTypes ...UserType) (userType UserT
 | 
			
		||||
		return UserTypeNone, 0, 0, errors.New("decode token error: " + err.Error())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	timestamp := m.GetInt64("timestamp")
 | 
			
		||||
	if time.Now().Unix()-timestamp > 600 {
 | 
			
		||||
		// 请求超过10分钟认为超时
 | 
			
		||||
		return UserTypeNone, 0, 0, errors.New("authenticate timeout, please check your system clock")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	t := m.GetString("type")
 | 
			
		||||
	if len(userTypes) > 0 && !lists.ContainsString(userTypes, t) {
 | 
			
		||||
		return UserTypeNone, 0, 0, errors.New("not supported node type: '" + t + "'")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user