Loading CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr ## [Unreleased] ### Added - Add tournament record delete runtime functions and API. - Add insecure flag to runtime http functions to optionally skip TLS checks. ### Changed - Improve graceful shutdown of Google IAP receipt processor. Loading server/runtime_javascript_nakama.go +15 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import ( "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/tls" "crypto/x509" "database/sql" "encoding/base64" Loading Loading @@ -63,6 +64,7 @@ type runtimeJavascriptNakamaModule struct { protojsonMarshaler *protojson.MarshalOptions protojsonUnmarshaler *protojson.UnmarshalOptions httpClient *http.Client httpClientInsecure *http.Client socialClient *social.Client leaderboardCache LeaderboardCache rankCache LeaderboardRankCache Loading Loading @@ -104,6 +106,7 @@ func NewRuntimeJavascriptNakamaModule(logger *zap.Logger, db *sql.DB, protojsonM localCache: localCache, leaderboardScheduler: leaderboardScheduler, httpClient: &http.Client{}, httpClientInsecure: &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}, node: config.GetName(), eventFn: eventFn, Loading Loading @@ -555,6 +558,7 @@ func (n *runtimeJavascriptNakamaModule) sqlQuery(r *goja.Runtime) func(goja.Func // @param headers(type=string) A table of headers used with the request. // @param content(type=string) The bytes to send with the request. // @param timeout(type=number, optional=true, default=5000) Timeout of the request in milliseconds. // @param insecure(type=bool, optional=true, default=false) Set to true to skip request TLS validations. // @return returnVal(nkruntime.httpResponse) Code, Headers, and Body response values for the HTTP response. // @return error(error) An optional error value if an error occurred. func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.FunctionCall) goja.Value { Loading @@ -581,6 +585,11 @@ func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.F timeoutMs = 5_000 } var insecure bool if !goja.IsUndefined(f.Argument(5)) && !goja.IsNull(f.Argument(5)) { insecure = getJsBool(r, f.Argument(5)) } if url == "" { panic(r.NewTypeError("URL string cannot be empty.")) } Loading Loading @@ -614,7 +623,12 @@ func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.F req.Header.Add(h, v) } resp, err := n.httpClient.Do(req) var resp *http.Response if insecure { resp, err = n.httpClientInsecure.Do(req) } else { resp, err = n.httpClient.Do(req) } if err != nil { panic(r.NewGoError(fmt.Errorf("HTTP request error: %v", err.Error()))) } Loading server/runtime_lua_nakama.go +16 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import ( "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/tls" "crypto/x509" "database/sql" "encoding/base64" Loading Loading @@ -81,7 +82,8 @@ type RuntimeLuaNakamaModule struct { localCache *RuntimeLuaLocalCache registerCallbackFn func(RuntimeExecutionMode, string, *lua.LFunction) announceCallbackFn func(RuntimeExecutionMode, string) client *http.Client httpClient *http.Client httpClientInsecure *http.Client node string matchCreateFn RuntimeMatchCreateFunction Loading Loading @@ -112,7 +114,8 @@ func NewRuntimeLuaNakamaModule(logger *zap.Logger, db *sql.DB, protojsonMarshale localCache: localCache, registerCallbackFn: registerCallbackFn, announceCallbackFn: announceCallbackFn, client: &http.Client{}, httpClient: &http.Client{}, httpClientInsecure: &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}, node: config.GetName(), matchCreateFn: matchCreateFn, Loading Loading @@ -920,6 +923,7 @@ func (n *RuntimeLuaNakamaModule) uuidStringToBytes(l *lua.LState) int { // @param headers(type=table, optional=true) A table of headers used with the request. // @param content(type=string, optional=true) The bytes to send with the request. // @param timeout(type=number, optional=true, default=5000) Timeout of the request in milliseconds. // @param insecure(type=bool, optional=true, default=false) Set to true to skip request TLS validations. // @return returnVal(table) Code, Headers, and Body response values for the HTTP response. // @return error(error) An optional error value if an error occurred. func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { Loading Loading @@ -951,6 +955,8 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { timeoutMs = 5_000 } insecure := l.OptBool(6, false) // Prepare request body, if any. var requestBody io.Reader if body != "" { Loading @@ -966,6 +972,7 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { l.RaiseError("HTTP request error: %v", err.Error()) return 0 } // Apply any request headers. httpHeaders := RuntimeLuaConvertLuaTable(headers) for k, v := range httpHeaders { Loading @@ -976,8 +983,14 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { } req.Header.Add(k, vs) } // Execute the request. resp, err := n.client.Do(req) var resp *http.Response if insecure { resp, err = n.httpClientInsecure.Do(req) } else { resp, err = n.httpClient.Do(req) } if err != nil { l.RaiseError("HTTP request error: %v", err.Error()) return 0 Loading Loading
CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr ## [Unreleased] ### Added - Add tournament record delete runtime functions and API. - Add insecure flag to runtime http functions to optionally skip TLS checks. ### Changed - Improve graceful shutdown of Google IAP receipt processor. Loading
server/runtime_javascript_nakama.go +15 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import ( "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/tls" "crypto/x509" "database/sql" "encoding/base64" Loading Loading @@ -63,6 +64,7 @@ type runtimeJavascriptNakamaModule struct { protojsonMarshaler *protojson.MarshalOptions protojsonUnmarshaler *protojson.UnmarshalOptions httpClient *http.Client httpClientInsecure *http.Client socialClient *social.Client leaderboardCache LeaderboardCache rankCache LeaderboardRankCache Loading Loading @@ -104,6 +106,7 @@ func NewRuntimeJavascriptNakamaModule(logger *zap.Logger, db *sql.DB, protojsonM localCache: localCache, leaderboardScheduler: leaderboardScheduler, httpClient: &http.Client{}, httpClientInsecure: &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}, node: config.GetName(), eventFn: eventFn, Loading Loading @@ -555,6 +558,7 @@ func (n *runtimeJavascriptNakamaModule) sqlQuery(r *goja.Runtime) func(goja.Func // @param headers(type=string) A table of headers used with the request. // @param content(type=string) The bytes to send with the request. // @param timeout(type=number, optional=true, default=5000) Timeout of the request in milliseconds. // @param insecure(type=bool, optional=true, default=false) Set to true to skip request TLS validations. // @return returnVal(nkruntime.httpResponse) Code, Headers, and Body response values for the HTTP response. // @return error(error) An optional error value if an error occurred. func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.FunctionCall) goja.Value { Loading @@ -581,6 +585,11 @@ func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.F timeoutMs = 5_000 } var insecure bool if !goja.IsUndefined(f.Argument(5)) && !goja.IsNull(f.Argument(5)) { insecure = getJsBool(r, f.Argument(5)) } if url == "" { panic(r.NewTypeError("URL string cannot be empty.")) } Loading Loading @@ -614,7 +623,12 @@ func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.F req.Header.Add(h, v) } resp, err := n.httpClient.Do(req) var resp *http.Response if insecure { resp, err = n.httpClientInsecure.Do(req) } else { resp, err = n.httpClient.Do(req) } if err != nil { panic(r.NewGoError(fmt.Errorf("HTTP request error: %v", err.Error()))) } Loading
server/runtime_lua_nakama.go +16 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import ( "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/tls" "crypto/x509" "database/sql" "encoding/base64" Loading Loading @@ -81,7 +82,8 @@ type RuntimeLuaNakamaModule struct { localCache *RuntimeLuaLocalCache registerCallbackFn func(RuntimeExecutionMode, string, *lua.LFunction) announceCallbackFn func(RuntimeExecutionMode, string) client *http.Client httpClient *http.Client httpClientInsecure *http.Client node string matchCreateFn RuntimeMatchCreateFunction Loading Loading @@ -112,7 +114,8 @@ func NewRuntimeLuaNakamaModule(logger *zap.Logger, db *sql.DB, protojsonMarshale localCache: localCache, registerCallbackFn: registerCallbackFn, announceCallbackFn: announceCallbackFn, client: &http.Client{}, httpClient: &http.Client{}, httpClientInsecure: &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}, node: config.GetName(), matchCreateFn: matchCreateFn, Loading Loading @@ -920,6 +923,7 @@ func (n *RuntimeLuaNakamaModule) uuidStringToBytes(l *lua.LState) int { // @param headers(type=table, optional=true) A table of headers used with the request. // @param content(type=string, optional=true) The bytes to send with the request. // @param timeout(type=number, optional=true, default=5000) Timeout of the request in milliseconds. // @param insecure(type=bool, optional=true, default=false) Set to true to skip request TLS validations. // @return returnVal(table) Code, Headers, and Body response values for the HTTP response. // @return error(error) An optional error value if an error occurred. func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { Loading Loading @@ -951,6 +955,8 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { timeoutMs = 5_000 } insecure := l.OptBool(6, false) // Prepare request body, if any. var requestBody io.Reader if body != "" { Loading @@ -966,6 +972,7 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { l.RaiseError("HTTP request error: %v", err.Error()) return 0 } // Apply any request headers. httpHeaders := RuntimeLuaConvertLuaTable(headers) for k, v := range httpHeaders { Loading @@ -976,8 +983,14 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { } req.Header.Add(k, vs) } // Execute the request. resp, err := n.client.Do(req) var resp *http.Response if insecure { resp, err = n.httpClientInsecure.Do(req) } else { resp, err = n.httpClient.Do(req) } if err != nil { l.RaiseError("HTTP request error: %v", err.Error()) return 0 Loading