Browse Source

update push

master
DengBiao 1 year ago
parent
commit
9c4a4739d8
2 changed files with 1 additions and 31 deletions
  1. +1
    -28
      pkg/interceptor/interceptor.go
  2. +0
    -3
      pkg/pb/logic.ext.pb.go

+ 1
- 28
pkg/interceptor/interceptor.go View File

@@ -21,7 +21,7 @@ func NewInterceptor(name string, urlWhitelist map[string]int) grpc.UnaryServerIn
defer gerrors.LogPanic(name, ctx, req, info, &err) defer gerrors.LogPanic(name, ctx, req, info, &err)


md, _ := metadata.FromIncomingContext(ctx) md, _ := metadata.FromIncomingContext(ctx)
resp, err = handleMasterAuth(ctx, req, info, handler)
resp, err = handleWithAuth(ctx, req, info, handler, urlWhitelist)
logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req), logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err)) zap.Any("resp", resp), zap.Error(err))


@@ -31,19 +31,6 @@ func NewInterceptor(name string, urlWhitelist map[string]int) grpc.UnaryServerIn
logger.Logger.Error(name, zap.String("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req), logger.Logger.Error(name, zap.String("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err), zap.String("stack", gerrors.GetErrorStack(s))) zap.Any("resp", resp), zap.Error(err), zap.String("stack", gerrors.GetErrorStack(s)))
} }
if err != nil {
return
}

resp, err = handleWithAuth(ctx, req, info, handler, urlWhitelist)
logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err))
s, _ = status.FromError(err)
if s.Code() != 0 && s.Code() < 1000 {
md, _ := metadata.FromIncomingContext(ctx)
logger.Logger.Error(name, zap.String("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err), zap.String("stack", gerrors.GetErrorStack(s)))
}
return return
} }
} }
@@ -75,17 +62,3 @@ func handleWithAuth(ctx context.Context, req interface{}, info *grpc.UnaryServer
} }
return handler(ctx, req) return handler(ctx, req)
} }

// handleMasterAuth 处理站长权限
func handleMasterAuth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
serverName := strings.Split(info.FullMethod, "/")[1]
if !strings.HasSuffix(serverName, "Int") {
masterId, err := grpclib.GetCtxMasterId(ctx)
_, err = rpc.GetBusinessIntClient().MasterAuth(ctx, &pb.MasterAuthReq{MasterId: masterId})
if err != nil {
return nil, err
}
}

return handler(ctx, req)
}

+ 0
- 3
pkg/pb/logic.ext.pb.go View File

@@ -2772,9 +2772,6 @@ func _LogicExt_SendMessage_Handler(srv interface{}, ctx context.Context, dec fun
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
utils.FilePutContents("LogicExt_SendMessage_Handler", utils.SerializeStr(map[string]interface{}{
"data": interceptor,
}))
if interceptor == nil { if interceptor == nil {
return srv.(LogicExtServer).SendMessage(ctx, in) return srv.(LogicExtServer).SendMessage(ctx, in)
} }


Loading…
Cancel
Save