Commit c9810700 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Runtime parameter cleanup and after hook improvements. (#248)

parent 261e920f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Lua runtime token generator function now returns a second value representing the token's expiry.
- Add local cache for in-memory storage to the Lua runtime.
- Graceful server shutdown and match termination.
- Expose incoming request data in runtime after hooks.

### Changed
- Improved Postgres compatibility on TIMESTAMPTZ types.
+126 −114

File changed.

Preview size limit exceeded, changes collapsed.

+3 −8
Original line number Diff line number Diff line
@@ -44,16 +44,11 @@ func (s *ApiServer) GetAccount(ctx context.Context, in *empty.Empty) (*api.Accou

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		result, err, code := fn(s.logger, userID.String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort, in)
		err, code := fn(s.logger, userID.String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort)
		if err != nil {
			return nil, status.Error(code, err.Error())
		}
		if result == nil {
			// If result is nil, requested resource is disabled.
			s.logger.Warn("Intercepted a disabled resource.", zap.Any("resource", fullMethod), zap.String("uid", userID.String()))
			return nil, status.Error(codes.NotFound, "Requested resource was not found.")
		}
		in = result
		// Empty input never overridden.

		// Stats measurement end boundary.
		span.End()
@@ -143,7 +138,7 @@ func (s *ApiServer) UpdateAccount(ctx context.Context, in *api.UpdateAccountRequ

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, userID.String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort, &empty.Empty{})
		fn(s.logger, userID.String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort, in)

		// Stats measurement end boundary.
		span.End()
+7 −7
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ func (s *ApiServer) AuthenticateCustom(ctx context.Context, in *api.Authenticate

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session, in)

		// Stats measurement end boundary.
		span.End()
@@ -178,7 +178,7 @@ func (s *ApiServer) AuthenticateDevice(ctx context.Context, in *api.Authenticate

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session, in)

		// Stats measurement end boundary.
		span.End()
@@ -260,7 +260,7 @@ func (s *ApiServer) AuthenticateEmail(ctx context.Context, in *api.AuthenticateE

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session, in)

		// Stats measurement end boundary.
		span.End()
@@ -336,7 +336,7 @@ func (s *ApiServer) AuthenticateFacebook(ctx context.Context, in *api.Authentica

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session, in)

		// Stats measurement end boundary.
		span.End()
@@ -419,7 +419,7 @@ func (s *ApiServer) AuthenticateGameCenter(ctx context.Context, in *api.Authenti

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session, in)

		// Stats measurement end boundary.
		span.End()
@@ -490,7 +490,7 @@ func (s *ApiServer) AuthenticateGoogle(ctx context.Context, in *api.Authenticate

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session, in)

		// Stats measurement end boundary.
		span.End()
@@ -565,7 +565,7 @@ func (s *ApiServer) AuthenticateSteam(ctx context.Context, in *api.AuthenticateS

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session)
		fn(s.logger, dbUserID, dbUsername, exp, clientIP, clientPort, session, in)

		// Stats measurement end boundary.
		span.End()
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ func (s *ApiServer) ListChannelMessages(ctx context.Context, in *api.ListChannel

		// Extract request information and execute the hook.
		clientIP, clientPort := extractClientAddress(s.logger, ctx)
		fn(s.logger, userID.String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort, messageList)
		fn(s.logger, userID.String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort, messageList, in)

		// Stats measurement end boundary.
		span.End()
Loading