Loading main.go +4 −6 Original line number Diff line number Diff line Loading @@ -105,16 +105,14 @@ func main() { startupLogger.Info("Node", zap.String("name", config.GetName()), zap.String("version", semver), zap.String("runtime", runtime.Version()), zap.Int("cpu", runtime.NumCPU()), zap.Int("proc", runtime.GOMAXPROCS(0))) startupLogger.Info("Data directory", zap.String("path", config.GetDataDir())) addresses := config.GetDatabase().Addresses addressCount := len(addresses) redactedAddresses := make([]string, addressCount) for i := range addresses { rawURL := fmt.Sprintf("postgresql://%s", addresses[i]) redactedAddresses := make([]string, 0, 1) for _, address := range config.GetDatabase().Addresses { rawURL := fmt.Sprintf("postgresql://%s", address) parsedURL, err := url.Parse(rawURL) if err != nil { logger.Fatal("Bad connection URL", zap.Error(err)) } redactedAddresses[i] = parsedURL.Redacted() redactedAddresses = append(redactedAddresses, strings.TrimPrefix(parsedURL.Redacted(), "postgresql://")) } startupLogger.Info("Database connections", zap.Strings("dsns", redactedAddresses)) Loading server/console_config.go +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import ( "google.golang.org/grpc/status" ) const ObfuscationString = "********" const ObfuscationString = "xxxxx" func (s *ConsoleServer) GetConfig(ctx context.Context, in *empty.Empty) (*console.Config, error) { cfg, err := s.config.Clone() Loading server/runtime_lua_localcache.go +9 −5 Original line number Diff line number Diff line Loading @@ -14,27 +14,31 @@ package server import "sync" import ( "sync" lua "github.com/heroiclabs/nakama/v2/internal/gopher-lua" ) type RuntimeLuaLocalCache struct { sync.RWMutex data map[string]string data map[string]lua.LValue } func NewRuntimeLuaLocalCache() *RuntimeLuaLocalCache { return &RuntimeLuaLocalCache{ data: make(map[string]string), data: make(map[string]lua.LValue), } } func (lc *RuntimeLuaLocalCache) Get(key string) (string, bool) { func (lc *RuntimeLuaLocalCache) Get(key string) (lua.LValue, bool) { lc.RLock() value, found := lc.data[key] lc.RUnlock() return value, found } func (lc *RuntimeLuaLocalCache) Put(key, value string) { func (lc *RuntimeLuaLocalCache) Put(key string, value lua.LValue) { lc.Lock() lc.data[key] = value lc.Unlock() Loading server/runtime_lua_nakama.go +4 −9 Original line number Diff line number Diff line Loading @@ -498,15 +498,11 @@ func (n *RuntimeLuaNakamaModule) localcacheGet(l *lua.LState) int { } defaultValue := l.Get(2) if t := defaultValue.Type(); t != lua.LTNil && t != lua.LTString { l.ArgError(2, "expects default value string or nil") return 0 } value, found := n.localCache.Get(key) if found { l.Push(lua.LString(value)) l.Push(value) } else { l.Push(defaultValue) } Loading @@ -520,10 +516,9 @@ func (n *RuntimeLuaNakamaModule) localcachePut(l *lua.LState) int { return 0 } value := l.CheckString(2) if value == "" { l.ArgError(2, "expects value string") return 0 value := l.Get(2) if valueTable, ok := value.(*lua.LTable); ok { valueTable.SetReadOnlyRecursive() } n.localCache.Put(key, value) Loading Loading
main.go +4 −6 Original line number Diff line number Diff line Loading @@ -105,16 +105,14 @@ func main() { startupLogger.Info("Node", zap.String("name", config.GetName()), zap.String("version", semver), zap.String("runtime", runtime.Version()), zap.Int("cpu", runtime.NumCPU()), zap.Int("proc", runtime.GOMAXPROCS(0))) startupLogger.Info("Data directory", zap.String("path", config.GetDataDir())) addresses := config.GetDatabase().Addresses addressCount := len(addresses) redactedAddresses := make([]string, addressCount) for i := range addresses { rawURL := fmt.Sprintf("postgresql://%s", addresses[i]) redactedAddresses := make([]string, 0, 1) for _, address := range config.GetDatabase().Addresses { rawURL := fmt.Sprintf("postgresql://%s", address) parsedURL, err := url.Parse(rawURL) if err != nil { logger.Fatal("Bad connection URL", zap.Error(err)) } redactedAddresses[i] = parsedURL.Redacted() redactedAddresses = append(redactedAddresses, strings.TrimPrefix(parsedURL.Redacted(), "postgresql://")) } startupLogger.Info("Database connections", zap.Strings("dsns", redactedAddresses)) Loading
server/console_config.go +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import ( "google.golang.org/grpc/status" ) const ObfuscationString = "********" const ObfuscationString = "xxxxx" func (s *ConsoleServer) GetConfig(ctx context.Context, in *empty.Empty) (*console.Config, error) { cfg, err := s.config.Clone() Loading
server/runtime_lua_localcache.go +9 −5 Original line number Diff line number Diff line Loading @@ -14,27 +14,31 @@ package server import "sync" import ( "sync" lua "github.com/heroiclabs/nakama/v2/internal/gopher-lua" ) type RuntimeLuaLocalCache struct { sync.RWMutex data map[string]string data map[string]lua.LValue } func NewRuntimeLuaLocalCache() *RuntimeLuaLocalCache { return &RuntimeLuaLocalCache{ data: make(map[string]string), data: make(map[string]lua.LValue), } } func (lc *RuntimeLuaLocalCache) Get(key string) (string, bool) { func (lc *RuntimeLuaLocalCache) Get(key string) (lua.LValue, bool) { lc.RLock() value, found := lc.data[key] lc.RUnlock() return value, found } func (lc *RuntimeLuaLocalCache) Put(key, value string) { func (lc *RuntimeLuaLocalCache) Put(key string, value lua.LValue) { lc.Lock() lc.data[key] = value lc.Unlock() Loading
server/runtime_lua_nakama.go +4 −9 Original line number Diff line number Diff line Loading @@ -498,15 +498,11 @@ func (n *RuntimeLuaNakamaModule) localcacheGet(l *lua.LState) int { } defaultValue := l.Get(2) if t := defaultValue.Type(); t != lua.LTNil && t != lua.LTString { l.ArgError(2, "expects default value string or nil") return 0 } value, found := n.localCache.Get(key) if found { l.Push(lua.LString(value)) l.Push(value) } else { l.Push(defaultValue) } Loading @@ -520,10 +516,9 @@ func (n *RuntimeLuaNakamaModule) localcachePut(l *lua.LState) int { return 0 } value := l.CheckString(2) if value == "" { l.ArgError(2, "expects value string") return 0 value := l.Get(2) if valueTable, ok := value.(*lua.LTable); ok { valueTable.SetReadOnlyRecursive() } n.localCache.Put(key, value) Loading