Explorar o código

v0.0.1开发:移除auth服务

#Suyghur %!s(int64=2) %!d(string=hai) anos
pai
achega
d6e0270c54
Modificáronse 36 ficheiros con 333 adicións e 1129 borrados
  1. 6 7
      bff/authbff/api/etc/authbff.yaml
  2. 4 2
      bff/authbff/api/internal/config/config.go
  3. 30 6
      bff/authbff/api/internal/logic/csloginlogic.go
  4. 32 7
      bff/authbff/api/internal/logic/playerloginlogic.go
  5. 2 6
      bff/authbff/api/internal/svc/servicecontext.go
  6. 1 1
      bff/cmdbff/api/etc/cmdbff.yaml
  7. 0 30
      core/auth/rpc/Dockerfile
  8. 0 40
      core/auth/rpc/auth.go
  9. 0 52
      core/auth/rpc/auth/auth.go
  10. 0 12
      core/auth/rpc/etc/auth.yaml
  11. 0 11
      core/auth/rpc/internal/config/config.go
  12. 0 60
      core/auth/rpc/internal/logic/checkauthlogic.go
  13. 0 61
      core/auth/rpc/internal/logic/csauthlogic.go
  14. 0 63
      core/auth/rpc/internal/logic/playerauthlogic.go
  15. 0 38
      core/auth/rpc/internal/server/authserver.go
  16. 0 13
      core/auth/rpc/internal/svc/servicecontext.go
  17. 0 426
      core/auth/rpc/pb/auth.pb.go
  18. 0 33
      core/auth/rpc/pb/auth.proto
  19. 0 177
      core/auth/rpc/pb/auth_grpc.pb.go
  20. 2 2
      core/cmd/rpc/Dockerfile
  21. 1 1
      core/cmd/rpc/cmd.go
  22. 5 5
      core/cmd/rpc/etc/cmd.yaml
  23. 7 7
      core/inner/rpc/etc/inner.yaml
  24. 1 1
      core/inner/rpc/inner.go
  25. 70 1
      core/inner/rpc/internal/server/innerserver.go
  26. 3 0
      core/inner/rpc/internal/svc/servicecontext.go
  27. 35 37
      core/inner/rpc/pb/inner.pb.go
  28. 1 1
      core/inner/rpc/pb/inner.proto
  29. 1 1
      docker-compose-env.yml
  30. 14 5
      flowsrv/rpc/etc/flowsrv.yaml
  31. 1 2
      flowsrv/rpc/flowsrv.go
  32. 5 1
      flowsrv/rpc/internal/config/config.go
  33. 51 8
      flowsrv/rpc/internal/logic/connectlogic.go
  34. 52 7
      flowsrv/rpc/internal/logic/disconnectlogic.go
  35. 4 0
      flowsrv/rpc/internal/mgr/flowmgr.go
  36. 5 5
      flowsrv/rpc/internal/svc/servicecontext.go

+ 6 - 7
bff/authbff/api/etc/authbff.yaml

@@ -2,14 +2,13 @@ Name: authbff
 Host: 0.0.0.0
 Port: 10000
 
-AuthRpcConf:
-  Endpoints:
-    - localhost:10400
-  NonBlock: true
-
 #链路追踪
 Telemetry:
   Name: authbff-api
-  Endpoint: http://localhost:14268/api/traces
+  Endpoint: http://127.0.0.1:9092/api/traces
   Sampler: 1.0
-  Batcher: jaeger
+  Batcher: jaeger
+
+JwtAuth:
+  AccessSecret: ylink2022
+  AccessExpire: 604800

+ 4 - 2
bff/authbff/api/internal/config/config.go

@@ -2,10 +2,12 @@ package config
 
 import (
 	"github.com/zeromicro/go-zero/rest"
-	"github.com/zeromicro/go-zero/zrpc"
 )
 
 type Config struct {
 	rest.RestConf
-	AuthRpcConf zrpc.RpcClientConf
+	JwtAuth struct {
+		AccessSecret string
+		AccessExpire int64
+	}
 }

+ 30 - 6
bff/authbff/api/internal/logic/csloginlogic.go

@@ -2,10 +2,14 @@ package logic
 
 import (
 	"context"
+	"github.com/golang-jwt/jwt/v4"
+	"github.com/pkg/errors"
 	"github.com/zeromicro/go-zero/core/logx"
+	"time"
 	"ylink/bff/authbff/api/internal/svc"
 	"ylink/bff/authbff/api/internal/types"
-	"ylink/core/auth/rpc/auth"
+	"ylink/comm/jwtkey"
+	"ylink/comm/result"
 )
 
 type CsLoginLogic struct {
@@ -23,13 +27,33 @@ func NewCsLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CsLoginLo
 }
 
 func (l *CsLoginLogic) CsLogin(req *types.CsAuthReq) (resp *types.AuthResp, err error) {
-	authResp, err := l.svcCtx.AuthRpc.CsAuth(l.ctx, &auth.CsAuthReq{
-		CsId: req.CsId,
-	})
+	now := time.Now().Unix()
+	token, err := l.generateCsToken(now, req.CsId)
 	if err != nil {
-		return nil, err
+		return nil, errors.Wrap(result.NewErrCode(result.TokenGenerateError), "")
 	}
 	return &types.AuthResp{
-		AccessToken: authResp.AccessToken,
+		AccessToken: token,
 	}, nil
 }
+
+//
+//  generateCsToken
+//  @Description: 客服token签发
+//  @receiver l
+//  @param iat
+//  @param csId
+//  @return string
+//  @return error
+//
+func (l *CsLoginLogic) generateCsToken(iat int64, csId string) (string, error) {
+	secret := l.svcCtx.Config.JwtAuth.AccessSecret
+	expire := l.svcCtx.Config.JwtAuth.AccessExpire
+	claims := make(jwt.MapClaims)
+	claims["iat"] = iat
+	claims["exp"] = iat + expire
+	claims[jwtkey.CsId] = csId
+	token := jwt.New(jwt.SigningMethodHS256)
+	token.Claims = claims
+	return token.SignedString([]byte(secret))
+}

+ 32 - 7
bff/authbff/api/internal/logic/playerloginlogic.go

@@ -2,10 +2,14 @@ package logic
 
 import (
 	"context"
+	"github.com/golang-jwt/jwt/v4"
+	"github.com/pkg/errors"
 	"github.com/zeromicro/go-zero/core/logx"
+	"time"
 	"ylink/bff/authbff/api/internal/svc"
 	"ylink/bff/authbff/api/internal/types"
-	"ylink/core/auth/rpc/auth"
+	"ylink/comm/jwtkey"
+	"ylink/comm/result"
 )
 
 type PlayerLoginLogic struct {
@@ -23,14 +27,35 @@ func NewPlayerLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Playe
 }
 
 func (l *PlayerLoginLogic) PlayerLogin(req *types.PlayerAuthReq) (resp *types.AuthResp, err error) {
-	authResp, err := l.svcCtx.AuthRpc.PlayerAuth(l.ctx, &auth.PlayerAuthReq{
-		PlayerId: req.PlayerId,
-		GameId:   req.GameId,
-	})
+	now := time.Now().Unix()
+	token, err := l.generatePlayerToken(now, req.PlayerId, req.GameId)
 	if err != nil {
-		return nil, err
+		return nil, errors.Wrap(result.NewErrCode(result.TokenGenerateError), "")
 	}
 	return &types.AuthResp{
-		AccessToken: authResp.AccessToken,
+		AccessToken: token,
 	}, nil
 }
+
+//
+//  generatePlayerToken
+//  @Description: 玩家token签发
+//  @receiver l
+//  @param iat
+//  @param playerId
+//  @param gameId
+//  @return string
+//  @return error
+//
+func (l *PlayerLoginLogic) generatePlayerToken(iat int64, playerId string, gameId string) (string, error) {
+	secret := l.svcCtx.Config.JwtAuth.AccessSecret
+	expire := l.svcCtx.Config.JwtAuth.AccessExpire
+	claims := make(jwt.MapClaims)
+	claims["iat"] = iat
+	claims["exp"] = iat + expire
+	claims[jwtkey.PlayerId] = playerId
+	claims[jwtkey.GameId] = gameId
+	token := jwt.New(jwt.SigningMethodHS256)
+	token.Claims = claims
+	return token.SignedString([]byte(secret))
+}

+ 2 - 6
bff/authbff/api/internal/svc/servicecontext.go

@@ -1,19 +1,15 @@
 package svc
 
 import (
-	"github.com/zeromicro/go-zero/zrpc"
 	"ylink/bff/authbff/api/internal/config"
-	"ylink/core/auth/rpc/auth"
 )
 
 type ServiceContext struct {
-	Config  config.Config
-	AuthRpc auth.Auth
+	Config config.Config
 }
 
 func NewServiceContext(c config.Config) *ServiceContext {
 	return &ServiceContext{
-		Config:  c,
-		AuthRpc: auth.NewAuth(zrpc.MustNewClient(c.AuthRpcConf)),
+		Config: c,
 	}
 }

+ 1 - 1
bff/cmdbff/api/etc/cmdbff.yaml

@@ -4,7 +4,7 @@ Port: 10100
 
 Telemetry:
   Name: cmdbff-api
-  Endpoint: http://localhost:14268/api/traces
+  Endpoint: http://127.0.0.1:9092/api/traces
   Sampler: 1.0
   Batcher: jaeger
 

+ 0 - 30
core/auth/rpc/Dockerfile

@@ -1,30 +0,0 @@
-FROM golang:alpine AS builder
-
-LABEL stage=gobuilder
-
-ENV CGO_ENABLED 0
-ENV GOPROXY https://goproxy.cn,direct
-
-RUN apk update --no-cache && apk add --no-cache tzdata
-
-WORKDIR /build
-
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-COPY . .
-COPY core/auth/rpc/etc /app/etc
-RUN go build -ldflags="-s -w" -o /app/auth core/auth/rpc/auth.go
-
-
-FROM alpine
-
-RUN apk update --no-cache && apk add --no-cache ca-certificates
-COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
-ENV TZ Asia/Shanghai
-
-WORKDIR /app
-COPY --from=builder /app/auth /app/auth
-COPY --from=builder /app/etc /app/etc
-
-CMD ["./auth", "-f", "etc/auth.yaml"]

+ 0 - 40
core/auth/rpc/auth.go

@@ -1,40 +0,0 @@
-package main
-
-import (
-	"flag"
-	"fmt"
-
-	"ylink/core/auth/rpc/internal/config"
-	"ylink/core/auth/rpc/internal/server"
-	"ylink/core/auth/rpc/internal/svc"
-	"ylink/core/auth/rpc/pb"
-
-	"github.com/zeromicro/go-zero/core/conf"
-	"github.com/zeromicro/go-zero/core/service"
-	"github.com/zeromicro/go-zero/zrpc"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/reflection"
-)
-
-var configFile = flag.String("f", "etc/auth.yaml", "the config file")
-
-func main() {
-	flag.Parse()
-
-	var c config.Config
-	conf.MustLoad(*configFile, &c)
-	ctx := svc.NewServiceContext(c)
-	svr := server.NewAuthServer(ctx)
-
-	s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
-		pb.RegisterAuthServer(grpcServer, svr)
-
-		if c.Mode == service.DevMode || c.Mode == service.TestMode {
-			reflection.Register(grpcServer)
-		}
-	})
-	defer s.Stop()
-
-	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
-	s.Start()
-}

+ 0 - 52
core/auth/rpc/auth/auth.go

@@ -1,52 +0,0 @@
-// Code generated by goctl. DO NOT EDIT!
-// Source: auth.proto
-
-package auth
-
-import (
-	"context"
-
-	"ylink/core/auth/rpc/pb"
-
-	"github.com/zeromicro/go-zero/zrpc"
-	"google.golang.org/grpc"
-)
-
-type (
-	AuthResp      = pb.AuthResp
-	CheckAuthReq  = pb.CheckAuthReq
-	CheckAuthResp = pb.CheckAuthResp
-	CsAuthReq     = pb.CsAuthReq
-	PlayerAuthReq = pb.PlayerAuthReq
-
-	Auth interface {
-		PlayerAuth(ctx context.Context, in *PlayerAuthReq, opts ...grpc.CallOption) (*AuthResp, error)
-		CsAuth(ctx context.Context, in *CsAuthReq, opts ...grpc.CallOption) (*AuthResp, error)
-		CheckAuth(ctx context.Context, in *CheckAuthReq, opts ...grpc.CallOption) (*CheckAuthResp, error)
-	}
-
-	defaultAuth struct {
-		cli zrpc.Client
-	}
-)
-
-func NewAuth(cli zrpc.Client) Auth {
-	return &defaultAuth{
-		cli: cli,
-	}
-}
-
-func (m *defaultAuth) PlayerAuth(ctx context.Context, in *PlayerAuthReq, opts ...grpc.CallOption) (*AuthResp, error) {
-	client := pb.NewAuthClient(m.cli.Conn())
-	return client.PlayerAuth(ctx, in, opts...)
-}
-
-func (m *defaultAuth) CsAuth(ctx context.Context, in *CsAuthReq, opts ...grpc.CallOption) (*AuthResp, error) {
-	client := pb.NewAuthClient(m.cli.Conn())
-	return client.CsAuth(ctx, in, opts...)
-}
-
-func (m *defaultAuth) CheckAuth(ctx context.Context, in *CheckAuthReq, opts ...grpc.CallOption) (*CheckAuthResp, error) {
-	client := pb.NewAuthClient(m.cli.Conn())
-	return client.CheckAuth(ctx, in, opts...)
-}

+ 0 - 12
core/auth/rpc/etc/auth.yaml

@@ -1,12 +0,0 @@
-Name: auth.rpc
-ListenOn: 0.0.0.0:10400
-
-Telemetry:
-  Name: auth-rpc
-  Endpoint: http://localhost:14268/api/traces
-  Sampler: 1.0
-  Batcher: jaeger
-
-JwtAuth:
-  AccessSecret: ylink2022
-  AccessExpire: 604800

+ 0 - 11
core/auth/rpc/internal/config/config.go

@@ -1,11 +0,0 @@
-package config
-
-import "github.com/zeromicro/go-zero/zrpc"
-
-type Config struct {
-	zrpc.RpcServerConf
-	JwtAuth struct {
-		AccessSecret string
-		AccessExpire int64
-	}
-}

+ 0 - 60
core/auth/rpc/internal/logic/checkauthlogic.go

@@ -1,60 +0,0 @@
-package logic
-
-import (
-	"context"
-	"github.com/golang-jwt/jwt/v4"
-	"github.com/pkg/errors"
-	"ylink/comm/globalkey"
-	"ylink/comm/jwtkey"
-	"ylink/comm/result"
-
-	"ylink/core/auth/rpc/internal/svc"
-	"ylink/core/auth/rpc/pb"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type CheckAuthLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewCheckAuthLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckAuthLogic {
-	return &CheckAuthLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *CheckAuthLogic) CheckAuth(in *pb.CheckAuthReq) (*pb.CheckAuthResp, error) {
-	token, err := jwt.Parse(in.AccessToken, func(token *jwt.Token) (i interface{}, err error) {
-		return []byte(l.svcCtx.Config.JwtAuth.AccessSecret), nil
-	})
-
-	if token.Valid {
-		//将获取的token中的Claims强转为MapClaims
-		claims, _ := token.Claims.(jwt.MapClaims)
-		var uid string
-		if in.Type == globalkey.CONNECT_TYPE_PLAYER {
-			uid = claims[jwtkey.PlayerId].(string)
-		} else {
-			uid = claims[jwtkey.CsId].(string)
-		}
-		return &pb.CheckAuthResp{
-			Uid: uid,
-		}, nil
-	} else if ve, ok := err.(*jwt.ValidationError); ok {
-		if ve.Errors&jwt.ValidationErrorMalformed != 0 {
-			return nil, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
-		} else if ve.Errors&(jwt.ValidationErrorExpired|jwt.ValidationErrorNotValidYet) != 0 {
-			// Token is either expired or not active yet
-			return nil, errors.Wrap(result.NewErrCode(result.TokenExpireError), "")
-		} else {
-			return nil, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
-		}
-	} else {
-		return nil, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
-	}
-}

+ 0 - 61
core/auth/rpc/internal/logic/csauthlogic.go

@@ -1,61 +0,0 @@
-package logic
-
-import (
-	"context"
-	"github.com/golang-jwt/jwt/v4"
-	"github.com/pkg/errors"
-	"time"
-	"ylink/comm/jwtkey"
-	"ylink/comm/result"
-
-	"ylink/core/auth/rpc/internal/svc"
-	"ylink/core/auth/rpc/pb"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type CsAuthLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewCsAuthLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CsAuthLogic {
-	return &CsAuthLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *CsAuthLogic) CsAuth(in *pb.CsAuthReq) (*pb.AuthResp, error) {
-	now := time.Now().Unix()
-	token, err := l.generateCsToken(now, in.CsId)
-	if err != nil {
-		return nil, errors.Wrap(result.NewErrCode(result.TokenGenerateError), "")
-	}
-	return &pb.AuthResp{
-		AccessToken: token,
-	}, nil
-}
-
-//
-//  generateCsToken
-//  @Description: 客服token签发
-//  @receiver l
-//  @param iat
-//  @param csId
-//  @return string
-//  @return error
-//
-func (l *CsAuthLogic) generateCsToken(iat int64, csId string) (string, error) {
-	secret := l.svcCtx.Config.JwtAuth.AccessSecret
-	expire := l.svcCtx.Config.JwtAuth.AccessExpire
-	claims := make(jwt.MapClaims)
-	claims["iat"] = iat
-	claims["exp"] = iat + expire
-	claims[jwtkey.CsId] = csId
-	token := jwt.New(jwt.SigningMethodHS256)
-	token.Claims = claims
-	return token.SignedString([]byte(secret))
-}

+ 0 - 63
core/auth/rpc/internal/logic/playerauthlogic.go

@@ -1,63 +0,0 @@
-package logic
-
-import (
-	"context"
-	"github.com/golang-jwt/jwt/v4"
-	"github.com/pkg/errors"
-	"time"
-	"ylink/comm/jwtkey"
-	"ylink/comm/result"
-
-	"ylink/core/auth/rpc/internal/svc"
-	"ylink/core/auth/rpc/pb"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type PlayerAuthLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewPlayerAuthLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlayerAuthLogic {
-	return &PlayerAuthLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *PlayerAuthLogic) PlayerAuth(in *pb.PlayerAuthReq) (*pb.AuthResp, error) {
-	now := time.Now().Unix()
-	token, err := l.generatePlayerToken(now, in.PlayerId, in.GameId)
-	if err != nil {
-		return nil, errors.Wrap(result.NewErrCode(result.TokenGenerateError), "")
-	}
-	return &pb.AuthResp{
-		AccessToken: token,
-	}, nil
-}
-
-//
-//  generatePlayerToken
-//  @Description: 玩家token签发
-//  @receiver l
-//  @param iat
-//  @param playerId
-//  @param gameId
-//  @return string
-//  @return error
-//
-func (l *PlayerAuthLogic) generatePlayerToken(iat int64, playerId string, gameId string) (string, error) {
-	secret := l.svcCtx.Config.JwtAuth.AccessSecret
-	expire := l.svcCtx.Config.JwtAuth.AccessExpire
-	claims := make(jwt.MapClaims)
-	claims["iat"] = iat
-	claims["exp"] = iat + expire
-	claims[jwtkey.PlayerId] = playerId
-	claims[jwtkey.GameId] = gameId
-	token := jwt.New(jwt.SigningMethodHS256)
-	token.Claims = claims
-	return token.SignedString([]byte(secret))
-}

+ 0 - 38
core/auth/rpc/internal/server/authserver.go

@@ -1,38 +0,0 @@
-// Code generated by goctl. DO NOT EDIT!
-// Source: auth.proto
-
-package server
-
-import (
-	"context"
-
-	"ylink/core/auth/rpc/internal/logic"
-	"ylink/core/auth/rpc/internal/svc"
-	"ylink/core/auth/rpc/pb"
-)
-
-type AuthServer struct {
-	svcCtx *svc.ServiceContext
-	pb.UnimplementedAuthServer
-}
-
-func NewAuthServer(svcCtx *svc.ServiceContext) *AuthServer {
-	return &AuthServer{
-		svcCtx: svcCtx,
-	}
-}
-
-func (s *AuthServer) PlayerAuth(ctx context.Context, in *pb.PlayerAuthReq) (*pb.AuthResp, error) {
-	l := logic.NewPlayerAuthLogic(ctx, s.svcCtx)
-	return l.PlayerAuth(in)
-}
-
-func (s *AuthServer) CsAuth(ctx context.Context, in *pb.CsAuthReq) (*pb.AuthResp, error) {
-	l := logic.NewCsAuthLogic(ctx, s.svcCtx)
-	return l.CsAuth(in)
-}
-
-func (s *AuthServer) CheckAuth(ctx context.Context, in *pb.CheckAuthReq) (*pb.CheckAuthResp, error) {
-	l := logic.NewCheckAuthLogic(ctx, s.svcCtx)
-	return l.CheckAuth(in)
-}

+ 0 - 13
core/auth/rpc/internal/svc/servicecontext.go

@@ -1,13 +0,0 @@
-package svc
-
-import "ylink/core/auth/rpc/internal/config"
-
-type ServiceContext struct {
-	Config config.Config
-}
-
-func NewServiceContext(c config.Config) *ServiceContext {
-	return &ServiceContext{
-		Config: c,
-	}
-}

+ 0 - 426
core/auth/rpc/pb/auth.pb.go

@@ -1,426 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// 	protoc-gen-go v1.28.0
-// 	protoc        v3.19.4
-// source: pb/auth.proto
-
-package pb
-
-import (
-	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
-)
-
-const (
-	// Verify that this generated code is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
-	// Verify that runtime/protoimpl is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type PlayerAuthReq struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	PlayerId string `protobuf:"bytes,1,opt,name=player_id,json=playerId,proto3" json:"player_id,omitempty"`
-	GameId   string `protobuf:"bytes,2,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"`
-}
-
-func (x *PlayerAuthReq) Reset() {
-	*x = PlayerAuthReq{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_pb_auth_proto_msgTypes[0]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *PlayerAuthReq) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*PlayerAuthReq) ProtoMessage() {}
-
-func (x *PlayerAuthReq) ProtoReflect() protoreflect.Message {
-	mi := &file_pb_auth_proto_msgTypes[0]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use PlayerAuthReq.ProtoReflect.Descriptor instead.
-func (*PlayerAuthReq) Descriptor() ([]byte, []int) {
-	return file_pb_auth_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *PlayerAuthReq) GetPlayerId() string {
-	if x != nil {
-		return x.PlayerId
-	}
-	return ""
-}
-
-func (x *PlayerAuthReq) GetGameId() string {
-	if x != nil {
-		return x.GameId
-	}
-	return ""
-}
-
-type CsAuthReq struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	CsId string `protobuf:"bytes,1,opt,name=cs_id,json=csId,proto3" json:"cs_id,omitempty"`
-}
-
-func (x *CsAuthReq) Reset() {
-	*x = CsAuthReq{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_pb_auth_proto_msgTypes[1]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *CsAuthReq) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*CsAuthReq) ProtoMessage() {}
-
-func (x *CsAuthReq) ProtoReflect() protoreflect.Message {
-	mi := &file_pb_auth_proto_msgTypes[1]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use CsAuthReq.ProtoReflect.Descriptor instead.
-func (*CsAuthReq) Descriptor() ([]byte, []int) {
-	return file_pb_auth_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *CsAuthReq) GetCsId() string {
-	if x != nil {
-		return x.CsId
-	}
-	return ""
-}
-
-type AuthResp struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
-}
-
-func (x *AuthResp) Reset() {
-	*x = AuthResp{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_pb_auth_proto_msgTypes[2]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *AuthResp) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*AuthResp) ProtoMessage() {}
-
-func (x *AuthResp) ProtoReflect() protoreflect.Message {
-	mi := &file_pb_auth_proto_msgTypes[2]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use AuthResp.ProtoReflect.Descriptor instead.
-func (*AuthResp) Descriptor() ([]byte, []int) {
-	return file_pb_auth_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *AuthResp) GetAccessToken() string {
-	if x != nil {
-		return x.AccessToken
-	}
-	return ""
-}
-
-type CheckAuthReq struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	Type        int64  `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
-	AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
-}
-
-func (x *CheckAuthReq) Reset() {
-	*x = CheckAuthReq{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_pb_auth_proto_msgTypes[3]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *CheckAuthReq) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*CheckAuthReq) ProtoMessage() {}
-
-func (x *CheckAuthReq) ProtoReflect() protoreflect.Message {
-	mi := &file_pb_auth_proto_msgTypes[3]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use CheckAuthReq.ProtoReflect.Descriptor instead.
-func (*CheckAuthReq) Descriptor() ([]byte, []int) {
-	return file_pb_auth_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *CheckAuthReq) GetType() int64 {
-	if x != nil {
-		return x.Type
-	}
-	return 0
-}
-
-func (x *CheckAuthReq) GetAccessToken() string {
-	if x != nil {
-		return x.AccessToken
-	}
-	return ""
-}
-
-type CheckAuthResp struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"`
-}
-
-func (x *CheckAuthResp) Reset() {
-	*x = CheckAuthResp{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_pb_auth_proto_msgTypes[4]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *CheckAuthResp) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*CheckAuthResp) ProtoMessage() {}
-
-func (x *CheckAuthResp) ProtoReflect() protoreflect.Message {
-	mi := &file_pb_auth_proto_msgTypes[4]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use CheckAuthResp.ProtoReflect.Descriptor instead.
-func (*CheckAuthResp) Descriptor() ([]byte, []int) {
-	return file_pb_auth_proto_rawDescGZIP(), []int{4}
-}
-
-func (x *CheckAuthResp) GetUid() string {
-	if x != nil {
-		return x.Uid
-	}
-	return ""
-}
-
-var File_pb_auth_proto protoreflect.FileDescriptor
-
-var file_pb_auth_proto_rawDesc = []byte{
-	0x0a, 0x0d, 0x70, 0x62, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
-	0x02, 0x70, 0x62, 0x22, 0x45, 0x0a, 0x0d, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x41, 0x75, 0x74,
-	0x68, 0x52, 0x65, 0x71, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x69,
-	0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49,
-	0x64, 0x12, 0x17, 0x0a, 0x07, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x06, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x20, 0x0a, 0x09, 0x43, 0x73,
-	0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x12, 0x13, 0x0a, 0x05, 0x63, 0x73, 0x5f, 0x69, 0x64,
-	0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x73, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x08,
-	0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65,
-	0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
-	0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x45, 0x0a, 0x0c, 0x43,
-	0x68, 0x65, 0x63, 0x6b, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x74,
-	0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
-	0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18,
-	0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b,
-	0x65, 0x6e, 0x22, 0x21, 0x0a, 0x0d, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x75, 0x74, 0x68, 0x52,
-	0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
-	0x52, 0x03, 0x75, 0x69, 0x64, 0x32, 0x8e, 0x01, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x2d,
-	0x0a, 0x0a, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x11, 0x2e, 0x70,
-	0x62, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x1a,
-	0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a,
-	0x06, 0x63, 0x73, 0x41, 0x75, 0x74, 0x68, 0x12, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x73, 0x41,
-	0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x75, 0x74, 0x68,
-	0x52, 0x65, 0x73, 0x70, 0x12, 0x30, 0x0a, 0x09, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x75, 0x74,
-	0x68, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x75, 0x74, 0x68,
-	0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x75,
-	0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06,
-	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
-}
-
-var (
-	file_pb_auth_proto_rawDescOnce sync.Once
-	file_pb_auth_proto_rawDescData = file_pb_auth_proto_rawDesc
-)
-
-func file_pb_auth_proto_rawDescGZIP() []byte {
-	file_pb_auth_proto_rawDescOnce.Do(func() {
-		file_pb_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_pb_auth_proto_rawDescData)
-	})
-	return file_pb_auth_proto_rawDescData
-}
-
-var file_pb_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
-var file_pb_auth_proto_goTypes = []interface{}{
-	(*PlayerAuthReq)(nil), // 0: pb.PlayerAuthReq
-	(*CsAuthReq)(nil),     // 1: pb.CsAuthReq
-	(*AuthResp)(nil),      // 2: pb.AuthResp
-	(*CheckAuthReq)(nil),  // 3: pb.CheckAuthReq
-	(*CheckAuthResp)(nil), // 4: pb.CheckAuthResp
-}
-var file_pb_auth_proto_depIdxs = []int32{
-	0, // 0: pb.Auth.playerAuth:input_type -> pb.PlayerAuthReq
-	1, // 1: pb.Auth.csAuth:input_type -> pb.CsAuthReq
-	3, // 2: pb.Auth.checkAuth:input_type -> pb.CheckAuthReq
-	2, // 3: pb.Auth.playerAuth:output_type -> pb.AuthResp
-	2, // 4: pb.Auth.csAuth:output_type -> pb.AuthResp
-	4, // 5: pb.Auth.checkAuth:output_type -> pb.CheckAuthResp
-	3, // [3:6] is the sub-list for method output_type
-	0, // [0:3] is the sub-list for method input_type
-	0, // [0:0] is the sub-list for extension type_name
-	0, // [0:0] is the sub-list for extension extendee
-	0, // [0:0] is the sub-list for field type_name
-}
-
-func init() { file_pb_auth_proto_init() }
-func file_pb_auth_proto_init() {
-	if File_pb_auth_proto != nil {
-		return
-	}
-	if !protoimpl.UnsafeEnabled {
-		file_pb_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*PlayerAuthReq); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_pb_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*CsAuthReq); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_pb_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*AuthResp); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_pb_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*CheckAuthReq); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_pb_auth_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*CheckAuthResp); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-	}
-	type x struct{}
-	out := protoimpl.TypeBuilder{
-		File: protoimpl.DescBuilder{
-			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
-			RawDescriptor: file_pb_auth_proto_rawDesc,
-			NumEnums:      0,
-			NumMessages:   5,
-			NumExtensions: 0,
-			NumServices:   1,
-		},
-		GoTypes:           file_pb_auth_proto_goTypes,
-		DependencyIndexes: file_pb_auth_proto_depIdxs,
-		MessageInfos:      file_pb_auth_proto_msgTypes,
-	}.Build()
-	File_pb_auth_proto = out.File
-	file_pb_auth_proto_rawDesc = nil
-	file_pb_auth_proto_goTypes = nil
-	file_pb_auth_proto_depIdxs = nil
-}

+ 0 - 33
core/auth/rpc/pb/auth.proto

@@ -1,33 +0,0 @@
-syntax = "proto3";
-
-option go_package = "./pb";
-
-package pb;
-
-message PlayerAuthReq{
-  string player_id = 1;
-  string game_id = 2;
-}
-
-message CsAuthReq{
-  string cs_id = 1;
-}
-
-message AuthResp{
-  string access_token = 1;
-}
-
-message CheckAuthReq{
-  int64 type = 1;
-  string  access_token = 2;
-}
-
-message CheckAuthResp{
-  string uid = 1;
-}
-
-service Auth{
-  rpc playerAuth (PlayerAuthReq) returns (AuthResp);
-  rpc csAuth (CsAuthReq) returns (AuthResp);
-  rpc checkAuth (CheckAuthReq) returns (CheckAuthResp);
-}

+ 0 - 177
core/auth/rpc/pb/auth_grpc.pb.go

@@ -1,177 +0,0 @@
-// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
-// versions:
-// - protoc-gen-go-grpc v1.2.0
-// - protoc             v3.19.4
-// source: pb/auth.proto
-
-package pb
-
-import (
-	context "context"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-)
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-// Requires gRPC-Go v1.32.0 or later.
-const _ = grpc.SupportPackageIsVersion7
-
-// AuthClient is the client API for Auth service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
-type AuthClient interface {
-	PlayerAuth(ctx context.Context, in *PlayerAuthReq, opts ...grpc.CallOption) (*AuthResp, error)
-	CsAuth(ctx context.Context, in *CsAuthReq, opts ...grpc.CallOption) (*AuthResp, error)
-	CheckAuth(ctx context.Context, in *CheckAuthReq, opts ...grpc.CallOption) (*CheckAuthResp, error)
-}
-
-type authClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewAuthClient(cc grpc.ClientConnInterface) AuthClient {
-	return &authClient{cc}
-}
-
-func (c *authClient) PlayerAuth(ctx context.Context, in *PlayerAuthReq, opts ...grpc.CallOption) (*AuthResp, error) {
-	out := new(AuthResp)
-	err := c.cc.Invoke(ctx, "/pb.Auth/playerAuth", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *authClient) CsAuth(ctx context.Context, in *CsAuthReq, opts ...grpc.CallOption) (*AuthResp, error) {
-	out := new(AuthResp)
-	err := c.cc.Invoke(ctx, "/pb.Auth/csAuth", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *authClient) CheckAuth(ctx context.Context, in *CheckAuthReq, opts ...grpc.CallOption) (*CheckAuthResp, error) {
-	out := new(CheckAuthResp)
-	err := c.cc.Invoke(ctx, "/pb.Auth/checkAuth", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-// AuthServer is the server API for Auth service.
-// All implementations must embed UnimplementedAuthServer
-// for forward compatibility
-type AuthServer interface {
-	PlayerAuth(context.Context, *PlayerAuthReq) (*AuthResp, error)
-	CsAuth(context.Context, *CsAuthReq) (*AuthResp, error)
-	CheckAuth(context.Context, *CheckAuthReq) (*CheckAuthResp, error)
-	mustEmbedUnimplementedAuthServer()
-}
-
-// UnimplementedAuthServer must be embedded to have forward compatible implementations.
-type UnimplementedAuthServer struct {
-}
-
-func (UnimplementedAuthServer) PlayerAuth(context.Context, *PlayerAuthReq) (*AuthResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method PlayerAuth not implemented")
-}
-func (UnimplementedAuthServer) CsAuth(context.Context, *CsAuthReq) (*AuthResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method CsAuth not implemented")
-}
-func (UnimplementedAuthServer) CheckAuth(context.Context, *CheckAuthReq) (*CheckAuthResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method CheckAuth not implemented")
-}
-func (UnimplementedAuthServer) mustEmbedUnimplementedAuthServer() {}
-
-// UnsafeAuthServer may be embedded to opt out of forward compatibility for this service.
-// Use of this interface is not recommended, as added methods to AuthServer will
-// result in compilation errors.
-type UnsafeAuthServer interface {
-	mustEmbedUnimplementedAuthServer()
-}
-
-func RegisterAuthServer(s grpc.ServiceRegistrar, srv AuthServer) {
-	s.RegisterService(&Auth_ServiceDesc, srv)
-}
-
-func _Auth_PlayerAuth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(PlayerAuthReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(AuthServer).PlayerAuth(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/pb.Auth/playerAuth",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(AuthServer).PlayerAuth(ctx, req.(*PlayerAuthReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_CsAuth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(CsAuthReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(AuthServer).CsAuth(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/pb.Auth/csAuth",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(AuthServer).CsAuth(ctx, req.(*CsAuthReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_CheckAuth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(CheckAuthReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(AuthServer).CheckAuth(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/pb.Auth/checkAuth",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(AuthServer).CheckAuth(ctx, req.(*CheckAuthReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-// Auth_ServiceDesc is the grpc.ServiceDesc for Auth service.
-// It's only intended for direct use with grpc.RegisterService,
-// and not to be introspected or modified (even as a copy)
-var Auth_ServiceDesc = grpc.ServiceDesc{
-	ServiceName: "pb.Auth",
-	HandlerType: (*AuthServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "playerAuth",
-			Handler:    _Auth_PlayerAuth_Handler,
-		},
-		{
-			MethodName: "csAuth",
-			Handler:    _Auth_CsAuth_Handler,
-		},
-		{
-			MethodName: "checkAuth",
-			Handler:    _Auth_CheckAuth_Handler,
-		},
-	},
-	Streams:  []grpc.StreamDesc{},
-	Metadata: "pb/auth.proto",
-}

+ 2 - 2
core/cmd/rpc/Dockerfile

@@ -17,9 +17,9 @@ COPY core/cmd/rpc/etc /app/etc
 RUN go build -ldflags="-s -w" -o /app/cmd core/cmd/rpc/cmd.go
 
 
-FROM alpine
+FROM scratch
 
-RUN apk update --no-cache && apk add --no-cache ca-certificates
+COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
 COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
 ENV TZ Asia/Shanghai
 

+ 1 - 1
core/cmd/rpc/cmd.go

@@ -35,6 +35,6 @@ func main() {
 	})
 	defer s.Stop()
 
-	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
+	fmt.Printf("Starting api server at %s...\n", c.ListenOn)
 	s.Start()
 }

+ 5 - 5
core/cmd/rpc/etc/cmd.yaml

@@ -1,4 +1,4 @@
-Name: cmd.rpc
+Name: cmd.api
 ListenOn: 0.0.0.0:10300
 
 InnerRpcConf:
@@ -7,12 +7,12 @@ InnerRpcConf:
   NonBlock: true
 
 Telemetry:
-  Name: cmd-rpc
-  Endpoint: http://localhost:14268/api/traces
+  Name: cmd-api
+  Endpoint: http://127.0.0.1:9092/api/traces
   Sampler: 1.0
   Batcher: jaeger
 
 KqMsgBoxProducerConf:
   Brokers:
-    - localhost:9092
-  Topic: send-box-topic
+    - 127.0.0.1:9092
+  Topic: send-box-topic

+ 7 - 7
core/inner/rpc/etc/inner.yaml

@@ -1,24 +1,24 @@
-Name: inner.rpc
+Name: inner.api
 ListenOn: 127.0.0.1:10500
 
 Telemetry:
-  Name: cmd-rpc
-  Endpoint: http://localhost:14268/api/traces
+  Name: cmd-api
+  Endpoint: http://127.0.0.1:9092/api/traces
   Sampler: 1.0
   Batcher: jaeger
 
 KqMsgBoxConsumerConf:
   Brokers:
-    - localhost:9092
+    - 127.0.0.1:9092
   Topic: send-box-topic
-  GroupId: inner-rpc
+  GroupId: inner-api
 
 KqMsgBoxProducerConf:
   Brokers:
-    - localhost:9092
+    - 127.0.0.1:9092
   Topic: recv-box-topic
 
 KqDbBoxProducerConf:
   Brokers:
-    - localhost:9092
+    - 127.0.0.1:9092
   Topic: db-box-topic

+ 1 - 1
core/inner/rpc/inner.go

@@ -34,6 +34,6 @@ func main() {
 	})
 	defer s.Stop()
 
-	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
+	fmt.Printf("Starting api server at %s...\n", c.ListenOn)
 	s.Start()
 }

+ 70 - 1
core/inner/rpc/internal/server/innerserver.go

@@ -5,6 +5,15 @@ package server
 
 import (
 	"context"
+	"encoding/json"
+	"github.com/Shopify/sarama"
+	treemap "github.com/liyue201/gostl/ds/map"
+	"github.com/zeromicro/go-zero/core/logx"
+	"go.opentelemetry.io/otel/attribute"
+	"ylink/comm/kafka"
+	"ylink/comm/model"
+	"ylink/comm/trace"
+	"ylink/core/inner/rpc/internal/ext"
 
 	"ylink/core/inner/rpc/internal/logic"
 	"ylink/core/inner/rpc/internal/svc"
@@ -14,12 +23,24 @@ import (
 type InnerServer struct {
 	svcCtx *svc.ServiceContext
 	pb.UnimplementedInnerServer
+	ConsumerGroup *kafka.ConsumerGroup
 }
 
 func NewInnerServer(svcCtx *svc.ServiceContext) *InnerServer {
-	return &InnerServer{
+	server := &InnerServer{
 		svcCtx: svcCtx,
+		ConsumerGroup: kafka.NewConsumerGroup(&kafka.ConsumerGroupConfig{
+			KafkaVersion:   sarama.V1_0_0_0,
+			OffsetsInitial: sarama.OffsetNewest,
+			IsReturnErr:    false,
+		},
+			svcCtx.Config.KqMsgBoxConsumerConf.Brokers,
+			[]string{svcCtx.Config.KqMsgBoxConsumerConf.Topic},
+			svcCtx.Config.KqMsgBoxConsumerConf.GroupId),
 	}
+	server.subscribe()
+	return server
+
 }
 
 func (s *InnerServer) PlayerFetchCsInfo(ctx context.Context, in *pb.InnerPlayerFetchCsInfoReq) (*pb.InnerPlayerFetchCsInfoResp, error) {
@@ -46,3 +67,51 @@ func (s *InnerServer) UpdateUserStatus(ctx context.Context, in *pb.UpdateUserSta
 	l := logic.NewUpdateUserStatusLogic(ctx, s.svcCtx)
 	return l.UpdateUserStatus(in)
 }
+
+func (s *InnerServer) Setup(_ sarama.ConsumerGroupSession) error {
+	return nil
+}
+
+func (s *InnerServer) Cleanup(_ sarama.ConsumerGroupSession) error {
+	return nil
+}
+
+func (s *InnerServer) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
+	for msg := range claim.Messages() {
+		if msg.Topic == s.svcCtx.Config.KqMsgBoxConsumerConf.Topic {
+			s.handleMessage(sess, msg)
+		}
+	}
+	return nil
+}
+
+func (s *InnerServer) handleMessage(sess sarama.ConsumerGroupSession, msg *sarama.ConsumerMessage) {
+	traceId := kafka.GetTraceFromHeader(msg.Headers)
+	if len(traceId) == 0 {
+		return
+	}
+	trace.RunOnTracing(traceId, func(ctx context.Context) {
+		var message model.KqMessage
+		if err := json.Unmarshal(msg.Value, &message); err != nil {
+			logx.WithContext(ctx).Errorf("unmarshal msg error: %v", err)
+			return
+		}
+		trace.StartTrace(ctx, "InnerServer.handleMessage.SendMessage", func(ctx context.Context) {
+			if len(message.ReceiverId) == 0 || message.ReceiverId == "" {
+				// 玩家发的消息
+				p2cMap := ext.Game2PlayerMap.Get(message.GameId).(*treemap.Map)
+				message.ReceiverId = p2cMap.Get(message.SenderId).(string)
+				logx.WithContext(ctx).Infof("receiver: %s", message.ReceiverId)
+				kMsg, _ := json.Marshal(message)
+				s.svcCtx.KqMsgBoxProducer.SendMessage(ctx, string(kMsg), message.ReceiverId)
+			} else {
+				s.svcCtx.KqMsgBoxProducer.SendMessage(ctx, string(msg.Value), message.ReceiverId)
+			}
+			sess.MarkMessage(msg, "")
+		}, attribute.String("msg.key", string(msg.Key)))
+	})
+}
+
+func (s *InnerServer) subscribe() {
+	go s.ConsumerGroup.RegisterHandleAndConsumer(s)
+}

+ 3 - 0
core/inner/rpc/internal/svc/servicecontext.go

@@ -2,6 +2,7 @@ package svc
 
 import (
 	treemap "github.com/liyue201/gostl/ds/map"
+	"github.com/liyue201/gostl/ds/set"
 	"ylink/comm/kafka"
 	"ylink/comm/model"
 	"ylink/core/inner/rpc/internal/config"
@@ -15,6 +16,8 @@ type ServiceContext struct {
 
 func NewServiceContext(c config.Config) *ServiceContext {
 	fetchCsCenterInfo()
+	ext.Game2PlayerStatMap = treemap.New(treemap.WithGoroutineSafe())
+	ext.CsStatSet = set.New(set.WithGoroutineSafe())
 	return &ServiceContext{
 		Config:           c,
 		KqMsgBoxProducer: kafka.NewKafkaProducer(c.KqMsgBoxProducerConf.Brokers, c.KqMsgBoxProducerConf.Topic),

+ 35 - 37
core/inner/rpc/pb/inner.pb.go

@@ -468,9 +468,9 @@ type UpdateUserStatusReq struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Type   int64   `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
-	Uid    string  `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"`
-	GameId *string `protobuf:"bytes,3,opt,name=game_id,json=gameId,proto3,oneof" json:"game_id,omitempty"`
+	Type   int64  `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
+	Uid    string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"`
+	GameId string `protobuf:"bytes,3,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"`
 }
 
 func (x *UpdateUserStatusReq) Reset() {
@@ -520,8 +520,8 @@ func (x *UpdateUserStatusReq) GetUid() string {
 }
 
 func (x *UpdateUserStatusReq) GetGameId() string {
-	if x != nil && x.GameId != nil {
-		return *x.GameId
+	if x != nil {
+		return x.GameId
 	}
 	return ""
 }
@@ -613,41 +613,40 @@ var file_pb_inner_proto_rawDesc = []byte{
 	0x12, 0x17, 0x0a, 0x07, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
 	0x09, 0x52, 0x06, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x1a, 0x0a, 0x18, 0x49, 0x6e, 0x6e,
 	0x65, 0x72, 0x43, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65,
-	0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x65, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55,
+	0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x54, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55,
 	0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04,
 	0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
 	0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75,
-	0x69, 0x64, 0x12, 0x1c, 0x0a, 0x07, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20,
-	0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x88, 0x01, 0x01,
-	0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x22, 0x16, 0x0a, 0x14,
-	0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
-	0x52, 0x65, 0x73, 0x70, 0x32, 0x98, 0x03, 0x0a, 0x05, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x12, 0x52,
-	0x0a, 0x11, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x46, 0x65, 0x74, 0x63, 0x68, 0x43, 0x73, 0x49,
-	0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x50, 0x6c,
-	0x61, 0x79, 0x65, 0x72, 0x46, 0x65, 0x74, 0x63, 0x68, 0x43, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52,
-	0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x50, 0x6c, 0x61,
+	0x69, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x55,
+	0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52,
+	0x65, 0x73, 0x70, 0x32, 0x98, 0x03, 0x0a, 0x05, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x12, 0x52, 0x0a,
+	0x11, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x46, 0x65, 0x74, 0x63, 0x68, 0x43, 0x73, 0x49, 0x6e,
+	0x66, 0x6f, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x50, 0x6c, 0x61,
 	0x79, 0x65, 0x72, 0x46, 0x65, 0x74, 0x63, 0x68, 0x43, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
-	0x73, 0x70, 0x12, 0x4f, 0x0a, 0x10, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x73, 0x63,
-	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65,
-	0x72, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
-	0x74, 0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x50,
-	0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52,
-	0x65, 0x73, 0x70, 0x12, 0x55, 0x0a, 0x12, 0x63, 0x73, 0x46, 0x65, 0x74, 0x63, 0x68, 0x50, 0x6c,
-	0x61, 0x79, 0x65, 0x72, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x49,
-	0x6e, 0x6e, 0x65, 0x72, 0x43, 0x73, 0x46, 0x65, 0x74, 0x63, 0x68, 0x50, 0x6c, 0x61, 0x79, 0x65,
-	0x72, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x49,
-	0x6e, 0x6e, 0x65, 0x72, 0x43, 0x73, 0x46, 0x65, 0x74, 0x63, 0x68, 0x50, 0x6c, 0x61, 0x79, 0x65,
-	0x72, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4c, 0x0a, 0x0f, 0x63, 0x73,
-	0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x1b, 0x2e,
-	0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x43, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
-	0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e,
-	0x49, 0x6e, 0x6e, 0x65, 0x72, 0x43, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x6c,
-	0x61, 0x79, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x45, 0x0a, 0x10, 0x75, 0x70, 0x64, 0x61,
-	0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x17, 0x2e, 0x70,
-	0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74,
-	0x75, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74,
-	0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x42,
-	0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x71, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x50, 0x6c, 0x61, 0x79,
+	0x65, 0x72, 0x46, 0x65, 0x74, 0x63, 0x68, 0x43, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73,
+	0x70, 0x12, 0x4f, 0x0a, 0x10, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x73, 0x63, 0x6f,
+	0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72,
+	0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
+	0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x50, 0x6c,
+	0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65,
+	0x73, 0x70, 0x12, 0x55, 0x0a, 0x12, 0x63, 0x73, 0x46, 0x65, 0x74, 0x63, 0x68, 0x50, 0x6c, 0x61,
+	0x79, 0x65, 0x72, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e,
+	0x6e, 0x65, 0x72, 0x43, 0x73, 0x46, 0x65, 0x74, 0x63, 0x68, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72,
+	0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e,
+	0x6e, 0x65, 0x72, 0x43, 0x73, 0x46, 0x65, 0x74, 0x63, 0x68, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72,
+	0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4c, 0x0a, 0x0f, 0x63, 0x73, 0x43,
+	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x70,
+	0x62, 0x2e, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x43, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
+	0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x49,
+	0x6e, 0x6e, 0x65, 0x72, 0x43, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x6c, 0x61,
+	0x79, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x45, 0x0a, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74,
+	0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x17, 0x2e, 0x70, 0x62,
+	0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75,
+	0x73, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
+	0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06,
+	0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -822,7 +821,6 @@ func file_pb_inner_proto_init() {
 			}
 		}
 	}
-	file_pb_inner_proto_msgTypes[8].OneofWrappers = []interface{}{}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
 		File: protoimpl.DescBuilder{

+ 1 - 1
core/inner/rpc/pb/inner.proto

@@ -53,7 +53,7 @@ message InnerCsConnectPlayerResp{}
 message UpdateUserStatusReq{
   int64 type = 1;
   string uid = 2;
-  optional string game_id = 3;
+  string game_id = 3;
 }
 
 message UpdateUserStatusResp{}

+ 1 - 1
docker-compose-env.yml

@@ -115,7 +115,7 @@ services:
     ports:
       - "9092:9092"
     environment:
-      - "KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092"
+      - "KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092"
       - "KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 "
       - "KAFKA_ADVERTISED_HOST_NAME=kafka"
       - "KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181"

+ 14 - 5
flowsrv/rpc/etc/flowsrv.yaml

@@ -1,9 +1,9 @@
-Name: flowsrv.rpc
+Name: flowsrv.api
 ListenOn: 0.0.0.0:10200
 
 Telemetry:
-  Name: flowsrv-rpc
-  Endpoint: http://localhost:14268/api/traces
+  Name: flowsrv-api
+  Endpoint: http://127.0.0.1:9092/api/traces
   Sampler: 1.0
   Batcher: jaeger
 
@@ -12,8 +12,17 @@ AuthRpcConf:
     - localhost:10400
   NonBlock: true
 
+InnerRpcConf:
+  Endpoints:
+    - localhost:10500
+  NonBlock: true
+
 KqMsgBoxConsumerConf:
   Brokers:
-    - localhost:9092
+    - 127.0.0.1:9092
   Topic: recv-box-topic
-  GroupId: flowsrv-rpc
+  GroupId: flowsrv-api
+
+JwtAuth:
+  AccessSecret: ylink2022
+  AccessExpire: 604800

+ 1 - 2
flowsrv/rpc/flowsrv.go

@@ -3,7 +3,6 @@ package main
 import (
 	"flag"
 	"fmt"
-
 	"ylink/flowsrv/rpc/internal/config"
 	"ylink/flowsrv/rpc/internal/server"
 	"ylink/flowsrv/rpc/internal/svc"
@@ -35,6 +34,6 @@ func main() {
 	})
 	defer s.Stop()
 
-	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
+	fmt.Printf("Starting api server at %s...\n", c.ListenOn)
 	s.Start()
 }

+ 5 - 1
flowsrv/rpc/internal/config/config.go

@@ -7,6 +7,10 @@ import (
 
 type Config struct {
 	zrpc.RpcServerConf
-	AuthRpcConf          zrpc.RpcClientConf
+	InnerRpcConf         zrpc.RpcClientConf
 	KqMsgBoxConsumerConf kafka.KqConsumerConfig
+	JwtAuth              struct {
+		AccessSecret string
+		AccessExpire int64
+	}
 }

+ 51 - 8
flowsrv/rpc/internal/logic/connectlogic.go

@@ -2,8 +2,12 @@ package logic
 
 import (
 	"context"
+	"github.com/golang-jwt/jwt/v4"
+	"github.com/pkg/errors"
+	"ylink/comm/globalkey"
+	"ylink/comm/jwtkey"
 	"ylink/comm/result"
-	"ylink/core/auth/rpc/auth"
+	"ylink/core/inner/rpc/inner"
 	"ylink/flowsrv/rpc/internal/mgr"
 
 	"ylink/flowsrv/rpc/internal/svc"
@@ -27,10 +31,7 @@ func NewConnectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ConnectLo
 }
 
 func (l *ConnectLogic) Connect(in *pb.CommandReq, stream pb.Flowsrv_ConnectServer) error {
-	authResp, err := l.svcCtx.AuthRpc.CheckAuth(l.ctx, &auth.CheckAuthReq{
-		Type:        in.Type,
-		AccessToken: in.AccessToken,
-	})
+	uid, gameId, err := l.checkAuth(in)
 	if err != nil {
 		return stream.Send(&pb.CommandResp{
 			Code: result.TokenParseError,
@@ -38,9 +39,20 @@ func (l *ConnectLogic) Connect(in *pb.CommandReq, stream pb.Flowsrv_ConnectServe
 			Data: nil,
 		})
 	}
-	// update(对接的user的状态也返回)
-	//stream.RecvMsg()
-	mgr.GetFlowMgrInstance().SetFlow(authResp.Uid, stream)
+	_, err = l.svcCtx.InnerRpc.UpdateUserStatus(l.ctx, &inner.UpdateUserStatusReq{
+		Type:   in.Type,
+		Uid:    uid,
+		GameId: gameId,
+	})
+	if err != nil {
+		return stream.Send(&pb.CommandResp{
+			Code: result.ServerCommonError,
+			Msg:  err.Error(),
+			Data: nil,
+		})
+	}
+
+	mgr.GetFlowMgrInstance().SetFlow(uid, stream)
 
 	return stream.Send(&pb.CommandResp{
 		Code: result.Ok,
@@ -48,3 +60,34 @@ func (l *ConnectLogic) Connect(in *pb.CommandReq, stream pb.Flowsrv_ConnectServe
 		Data: nil,
 	})
 }
+
+func (l *ConnectLogic) checkAuth(in *pb.CommandReq) (string, string, error) {
+	token, err := jwt.Parse(in.AccessToken, func(token *jwt.Token) (i interface{}, err error) {
+		return []byte(l.svcCtx.Config.JwtAuth.AccessSecret), nil
+	})
+
+	uid := ""
+	gameId := ""
+	if token.Valid {
+		//将获取的token中的Claims强转为MapClaims
+		claims, _ := token.Claims.(jwt.MapClaims)
+		if in.Type == globalkey.CONNECT_TYPE_PLAYER {
+			uid = claims[jwtkey.PlayerId].(string)
+			gameId = claims[jwtkey.GameId].(string)
+		} else {
+			uid = claims[jwtkey.CsId].(string)
+		}
+		return uid, gameId, nil
+	} else if ve, ok := err.(*jwt.ValidationError); ok {
+		if ve.Errors&jwt.ValidationErrorMalformed != 0 {
+			return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
+		} else if ve.Errors&(jwt.ValidationErrorExpired|jwt.ValidationErrorNotValidYet) != 0 {
+			// Token is either expired or not active yet
+			return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenExpireError), "")
+		} else {
+			return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
+		}
+	} else {
+		return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
+	}
+}

+ 52 - 7
flowsrv/rpc/internal/logic/disconnectlogic.go

@@ -2,8 +2,13 @@ package logic
 
 import (
 	"context"
+	"github.com/golang-jwt/jwt/v4"
+	"github.com/pkg/errors"
+	"ylink/comm/globalkey"
+	"ylink/comm/jwtkey"
 	"ylink/comm/result"
-	"ylink/core/auth/rpc/auth"
+	"ylink/core/inner/rpc/inner"
+	"ylink/flowsrv/rpc/internal/mgr"
 
 	"ylink/flowsrv/rpc/internal/svc"
 	"ylink/flowsrv/rpc/pb"
@@ -26,10 +31,7 @@ func NewDisconnectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Discon
 }
 
 func (l *DisconnectLogic) Disconnect(in *pb.CommandReq) (*pb.CommandResp, error) {
-	_, err := l.svcCtx.AuthRpc.CheckAuth(l.ctx, &auth.CheckAuthReq{
-		Type:        in.Type,
-		AccessToken: in.AccessToken,
-	})
+	uid, gameId, err := l.checkAuth(in)
 	if err != nil {
 		return &pb.CommandResp{
 			Code: result.TokenParseError,
@@ -37,12 +39,55 @@ func (l *DisconnectLogic) Disconnect(in *pb.CommandReq) (*pb.CommandResp, error)
 			Data: nil,
 		}, err
 	}
+	_, err = l.svcCtx.InnerRpc.UpdateUserStatus(l.ctx, &inner.UpdateUserStatusReq{
+		Type:   in.Type,
+		Uid:    uid,
+		GameId: gameId,
+	})
+	if err != nil {
+		return &pb.CommandResp{
+			Code: result.ServerCommonError,
+			Msg:  err.Error(),
+			Data: nil,
+		}, err
+	}
 
-	// TODO: notify inner service
-
+	mgr.GetFlowMgrInstance().RemoveFlow(uid)
+	
 	return &pb.CommandResp{
 		Code: result.Ok,
 		Msg:  "success",
 		Data: nil,
 	}, nil
 }
+
+func (l *DisconnectLogic) checkAuth(in *pb.CommandReq) (string, string, error) {
+	token, err := jwt.Parse(in.AccessToken, func(token *jwt.Token) (i interface{}, err error) {
+		return []byte(l.svcCtx.Config.JwtAuth.AccessSecret), nil
+	})
+
+	uid := ""
+	gameId := ""
+	if token.Valid {
+		//将获取的token中的Claims强转为MapClaims
+		claims, _ := token.Claims.(jwt.MapClaims)
+		if in.Type == globalkey.CONNECT_TYPE_PLAYER {
+			uid = claims[jwtkey.PlayerId].(string)
+			gameId = claims[jwtkey.GameId].(string)
+		} else {
+			uid = claims[jwtkey.CsId].(string)
+		}
+		return uid, gameId, nil
+	} else if ve, ok := err.(*jwt.ValidationError); ok {
+		if ve.Errors&jwt.ValidationErrorMalformed != 0 {
+			return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
+		} else if ve.Errors&(jwt.ValidationErrorExpired|jwt.ValidationErrorNotValidYet) != 0 {
+			// Token is either expired or not active yet
+			return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenExpireError), "")
+		} else {
+			return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
+		}
+	} else {
+		return uid, gameId, errors.Wrap(result.NewErrCode(result.TokenParseError), "")
+	}
+}

+ 4 - 0
flowsrv/rpc/internal/mgr/flowmgr.go

@@ -34,3 +34,7 @@ func (manager *flowManager) SetFlow(uid string, flow pb.Flowsrv_ConnectServer) {
 func (manager *flowManager) GetFlow(uid string) pb.Flowsrv_ConnectServer {
 	return manager.flowMap[uid]
 }
+
+func (manager *flowManager) RemoveFlow(uid string) {
+	delete(manager.flowMap, uid)
+}

+ 5 - 5
flowsrv/rpc/internal/svc/servicecontext.go

@@ -2,18 +2,18 @@ package svc
 
 import (
 	"github.com/zeromicro/go-zero/zrpc"
-	"ylink/core/auth/rpc/auth"
+	"ylink/core/inner/rpc/inner"
 	"ylink/flowsrv/rpc/internal/config"
 )
 
 type ServiceContext struct {
-	Config  config.Config
-	AuthRpc auth.Auth
+	Config   config.Config
+	InnerRpc inner.Inner
 }
 
 func NewServiceContext(c config.Config) *ServiceContext {
 	return &ServiceContext{
-		Config:  c,
-		AuthRpc: auth.NewAuth(zrpc.MustNewClient(c.AuthRpcConf)),
+		Config:   c,
+		InnerRpc: inner.NewInner(zrpc.MustNewClient(c.InnerRpcConf)),
 	}
 }