console

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteAllData

func DeleteAllData(ctx context.Context, pool *pgxpool.Pool) error

DeleteAllData truncates application tables and re-seeds the system user.

func DeleteStorage

func DeleteStorage(ctx context.Context, pool *pgxpool.Pool) error

DeleteStorage truncates the storage table (wipe-all).

func ImportAccount

func ImportAccount(ctx context.Context, pool *pgxpool.Pool, data *AccountExport) error

ImportAccount creates or replaces an account from export data.

func ImportStorageObjects

func ImportStorageObjects(ctx context.Context, pool *pgxpool.Pool, objects []*storage.StorageObject) error

ImportStorageObjects writes a batch of storage objects authoritatively.

func ValidateTOTP

func ValidateTOTP(secret []byte, code string) bool

ValidateTOTP validates a 6-digit TOTP code against a secret key for the current time. It allows a time window of +/- 1 time step (30 seconds) to account for clock drift.

Types

type AccountExport

type AccountExport struct {
	UserID      string                 `json:"user_id"`
	Username    string                 `json:"username"`
	DisplayName string                 `json:"display_name"`
	Metadata    map[string]interface{} `json:"metadata"`
	Wallet      map[string]int64       `json:"wallet"`
	Storage     []StorageExportObject  `json:"storage"`
}

AccountExport is the portable account import blob.

type AuditLogEntry

type AuditLogEntry struct {
	ID              string
	ConsoleUserID   string
	ConsoleUsername string
	Email           string
	Action          string
	Resource        string
	Message         string
	Metadata        map[string]any
	CreateTime      time.Time
}

AuditLogEntry is the queue payload for console_audit_log.

type ConsoleClaims

type ConsoleClaims struct {
	UserID    string                 `json:"user_id"`
	Username  string                 `json:"username"`
	Email     string                 `json:"email"`
	ACL       map[string]interface{} `json:"acl"`        // legacy JSON flags (compat)
	ACLBitmap string                 `json:"acl_bitmap"` // reference-aligned bitmap
	jwt.RegisteredClaims
}

ConsoleClaims defines the JWT claims for authenticated console operators.

func (*ConsoleClaims) Permission

func (c *ConsoleClaims) Permission() acl.Permission

type GRPCConsole

type GRPCConsole struct {
	consolepb.UnimplementedConsoleServer
	Server *Server
}

GRPCConsole implements consolepb.ConsoleServer. HTTP /v2/console is the primary gateway-equivalent surface; gRPC exposes core status and is extended over time.

func NewGRPCConsole

func NewGRPCConsole(s *Server) *GRPCConsole

func (*GRPCConsole) DeleteAllData

func (g *GRPCConsole) DeleteAllData(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

func (*GRPCConsole) DeleteStorage

func (g *GRPCConsole) DeleteStorage(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

func (*GRPCConsole) GetStatus

func (g *GRPCConsole) GetStatus(ctx context.Context, _ *emptypb.Empty) (*consolepb.Status, error)

func (*GRPCConsole) ImportAccount

func (g *GRPCConsole) ImportAccount(ctx context.Context, in *consolepb.AccountImport) (*emptypb.Empty, error)

func (*GRPCConsole) ImportAccountFull

func (g *GRPCConsole) ImportAccountFull(ctx context.Context, in *consolepb.AccountImport) (*emptypb.Empty, error)

func (*GRPCConsole) ImportStorage

func (g *GRPCConsole) ImportStorage(ctx context.Context, in *consolepb.StorageImport) (*emptypb.Empty, error)

type IAPNotificationDeps

type IAPNotificationDeps struct {
	AppleEndpointID  string
	GoogleEndpointID string
	Registry         *runtime.HookRegistry
	NK               runtime.RuntimeModule
	Logger           runtime.Logger
}

IAPNotificationDeps wires store RTDN endpoints on the console mux.

type Logger

type Logger interface {
	Info(msg string, fields ...any)
	Error(msg string, fields ...any)
}

Logger interface matching our requirements.

type MatchLister

type MatchLister interface {
	ListMatches() []map[string]interface{}
}

MatchLister lists active matches for console status/ops.

type MatchStater

type MatchStater interface {
	GetMatchState(matchID string) (map[string]interface{}, error)
}

MatchStater returns match state JSON for a match id.

type RPCDispatcher

type RPCDispatcher interface {
	DispatchRPC(ctx context.Context, id, payload string, userID, username string) (string, error)
}

RPCDispatcher invokes a runtime RPC as an admin.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server encapsulates the Console Admin HTTP server.

func NewServer

func NewServer(logger Logger, pool *pgxpool.Pool, jwtSecret []byte) (*Server, error)

NewServer initializes the Console Admin server.

func (*Server) Close

func (s *Server) Close()

Close gracefully terminates HTTP/gRPC servers and async workers.

func (*Server) SetIAPNotificationDeps

func (s *Server) SetIAPNotificationDeps(d IAPNotificationDeps)

SetIAPNotificationDeps configures Apple/Google notification webhook routes.

func (*Server) SetMatchDeps

func (s *Server) SetMatchDeps(lister MatchLister, stater MatchStater)

SetMatchDeps wires match list/state helpers.

func (*Server) SetRPCDispatcher

func (s *Server) SetRPCDispatcher(d RPCDispatcher)

SetRPCDispatcher wires CallRpc.

func (*Server) SetRuntimeRegistry

func (s *Server) SetRuntimeRegistry(reg *runtime.HookRegistry)

SetRuntimeRegistry enables mounting RegisterConsoleHttp handlers on the console mux.

func (*Server) SetSatoriClient

func (s *Server) SetSatoriClient(c *satori.Client)

SetSatoriClient wires Satori console RPCs.

func (*Server) SetSessionRevoker

func (s *Server) SetSessionRevoker(r SessionRevoker)

SetSessionRevoker configures session revocation on ban/delete.

func (*Server) SetStatusProvider

func (s *Server) SetStatusProvider(p StatusProvider)

SetStatusProvider wires GET /console/api/status.

func (*Server) Start

func (s *Server) Start(addr string) error

Start opens the network listener and starts HTTP (/v2/console + legacy /console) and gRPC Console.

type SessionRevoker

type SessionRevoker interface {
	RevokeAllSessions(userID string)
}

SessionRevoker invalidates player sessions (e.g. on ban).

type StatusProvider

type StatusProvider interface {
	ConsoleStatus() map[string]interface{}
}

StatusProvider supplies node status metrics.

type StorageExportObject

type StorageExportObject struct {
	Collection string `json:"collection"`
	Key        string `json:"key"`
	Value      string `json:"value"`
	Version    string `json:"version"`
}

StorageExportObject is a storage row in import/export.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL