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

Update script context variables. Merge #100

parent e57b5d95
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -4,8 +4,11 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/).

## [Unreleased]
### Changed
### Added
- New storage partial update feature.
- Log warning messages at startup when using insecure default parameter values.

### Changed
- Use Lua table for Content field when creating new notifications.
- Use Lua table for Metadata field for new groups.
- Use Lua table for Metadata field when updating a user.
@@ -13,6 +16,8 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p
- Moved all `nakamax` functions into `nakama`.
- Invalid config file, or invalid command line config option prevents server from starting.
- Matchmake token expiry increased from 15 seconds to 30 seconds.
- Script runtime `os.date()` function now returns correct day of year.
- Script runtime contexts passed to function hooks now use `PascalCase` naming for fields. For example `context.user_id` must now be `context.UserId`.

## [1.0.0-rc.1] - 2017-07-18
### Added
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ imports:
- name: github.com/satori/go.uuid
  version: b061729afc07e77a8aa4fad0a2fd840958f1942a
- name: github.com/yuin/gopher-lua
  version: b402f3114ec730d8bddb074a6c137309f561aa78
  version: 2243d714d6c94951d8ccca8c851836ff47d401c9
  subpackages:
  - ast
  - parse
+11 −0
Original line number Diff line number Diff line
@@ -91,6 +91,17 @@ func ParseArgs(logger *zap.Logger, args []string) Config {
		mainConfig.GetRuntime().Path = filepath.Join(mainConfig.GetDataDir(), "modules")
	}

	// Log warnings for insecure default parameter values.
	if mainConfig.GetSocket().ServerKey == "defaultkey" {
		logger.Warn("WARNING: insecure default parameter value, change this for production!", zap.String("param", "socket.server_key"))
	}
	if mainConfig.GetSession().EncryptionKey == "defaultencryptionkey" {
		logger.Warn("WARNING: insecure default parameter value, change this for production!", zap.String("param", "session.encryption_key"))
	}
	if mainConfig.GetRuntime().HTTPKey == "defaultkey" {
		logger.Warn("WARNING: insecure default parameter value, change this for production!", zap.String("param", "runtime.http_key"))
	}

	return mainConfig
}

+7 −7
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import (
	"net/http"

	"nakama/build/generated/dashboard"
	"os"
	"runtime"

	"github.com/elazarl/go-bindata-assetfs"
@@ -57,7 +56,8 @@ func NewDashboardService(logger *zap.Logger, multiLogger *zap.Logger, version st
	service.mux.HandleFunc("/v0/cluster/stats", service.statusHandler).Methods("GET")
	service.mux.HandleFunc("/v0/config", service.configHandler).Methods("GET")
	service.mux.HandleFunc("/v0/info", service.infoHandler).Methods("GET")
	service.mux.PathPrefix("/").Handler(http.FileServer(service.dashboardFilesystem)).Methods("GET") //needs to be last
	// TODO coming soon
	// service.mux.PathPrefix("/").Handler(http.FileServer(service.dashboardFilesystem)).Methods("GET") // Needs to be last.

	go func() {
		bindAddr := fmt.Sprintf(":%d", config.GetDashboard().Port)
@@ -67,11 +67,11 @@ func NewDashboardService(logger *zap.Logger, multiLogger *zap.Logger, version st
			multiLogger.Fatal("Dashboard listener failed", zap.Error(err))
		}
	}()
	hostname, err := os.Hostname()
	if err != nil {
		hostname = "127.0.0.1"
	}
	multiLogger.Info("Dashboard", zap.String("address", fmt.Sprintf("http://%s:%d", hostname, config.GetDashboard().Port)))
	// hostname, err := os.Hostname()
	// if err != nil {
	// 	 hostname = "127.0.0.1"
	// }
	// multiLogger.Info("Dashboard", zap.String("address", fmt.Sprintf("http://%s:%d", hostname, config.GetDashboard().Port)))

	return service
}
+5 −5
Original line number Diff line number Diff line
@@ -52,11 +52,11 @@ func (e ExecutionMode) String() string {
}

const (
	__CTX_ENV              = "env"
	__CTX_MODE             = "execution_mode"
	__CTX_USER_ID          = "user_id"
	__CTX_USER_HANDLE      = "user_handle"
	__CTX_USER_SESSION_EXP = "user_session_exp"
	__CTX_ENV              = "Env"
	__CTX_MODE             = "ExecutionMode"
	__CTX_USER_ID          = "UserId"
	__CTX_USER_HANDLE      = "UserHandle"
	__CTX_USER_SESSION_EXP = "UserSessionExp"
)

func NewLuaContext(l *lua.LState, env *lua.LTable, mode ExecutionMode, uid uuid.UUID, handle string, sessionExpiry int64) *lua.LTable {
Loading