Пример #1
0
        private static bool HandleTeapot(IStatusHandlerContext context)
        {
            if (!context.IsGetLike || context.Url !.AbsolutePath != "/teapot")
            {
                return(false);
            }

            context.Respond("I am a teapot.", (HttpStatusCode)418);
            return(true);
        }
Пример #2
0
        private async Task <bool> HandleInfo(IStatusHandlerContext context)
        {
            if (!context.IsGetLike || context.Url !.AbsolutePath != "/info")
            {
                return(false);
            }

            var downloadUrl = _configurationManager.GetCVar(CVars.BuildDownloadUrl);

            JsonObject?buildInfo;

            if (string.IsNullOrEmpty(downloadUrl))
            {
                buildInfo = await PrepareACZBuildInfo();
            }
            else
            {
                var hash = _configurationManager.GetCVar(CVars.BuildHash);
                if (hash == "")
                {
                    hash = null;
                }

                buildInfo = new JsonObject
                {
                    ["engine_version"] = _configurationManager.GetCVar(CVars.BuildEngineVersion),
                    ["fork_id"]        = _configurationManager.GetCVar(CVars.BuildForkId),
                    ["version"]        = _configurationManager.GetCVar(CVars.BuildVersion),
                    ["download_url"]   = downloadUrl,
                    ["hash"]           = hash,
                };
            }

            var authInfo = new JsonObject
            {
                ["mode"]       = _netManager.Auth.ToString(),
                ["public_key"] = _netManager.RsaPublicKey != null
                    ? Convert.ToBase64String(_netManager.RsaPublicKey)
                    : null
            };

            var jObject = new JsonObject
            {
                ["connect_address"] = _configurationManager.GetCVar(CVars.StatusConnectAddress),
                ["auth"]            = authInfo,
                ["build"]           = buildInfo
            };

            OnInfoRequest?.Invoke(jObject);

            await context.RespondJsonAsync(jObject);

            return(true);
        }
Пример #3
0
        private async Task <bool> HandleStatus(IStatusHandlerContext context)
        {
            if (!context.IsGetLike || context.Url !.AbsolutePath != "/status")
            {
                return(false);
            }

            var jObject = new JsonObject
            {
                // We need to send at LEAST name and player count to have the launcher work with us.
                // Content can override these if it wants (e.g. stealthmins).
                ["name"]    = _serverNameCache,
                ["players"] = _playerManager.PlayerCount
            };

            OnStatusRequest?.Invoke(jObject);

            await context.RespondJsonAsync(jObject);

            return(true);
        }