From a3109ce30f0de2fec0f5f130761939233cbeee77 Mon Sep 17 00:00:00 2001 From: pg9182 <96569817+pg9182@users.noreply.github.com> Date: Mon, 6 Mar 2023 00:16:04 -0500 Subject: pkg/api/api0: Allow game servers to reject connections with a reason This is backwards-compatible with old clients, since it implements it as a new error type. --- pkg/api/api0/client.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkg/api/api0/client.go') diff --git a/pkg/api/api0/client.go b/pkg/api/api0/client.go index 6e02603..2dbad76 100644 --- a/pkg/api/api0/client.go +++ b/pkg/api/api0/client.go @@ -577,7 +577,11 @@ func (h *Handler) handleClientAuthWithServer(w http.ResponseWriter, r *http.Requ if errors.Is(err, context.DeadlineExceeded) { err = fmt.Errorf("request timed out") } + var rej api0gameserver.ConnectionRejectedError switch { + case errors.As(err, &rej): + h.m().client_authwithserver_requests_total.reject_gameserver.Inc() + respFail(w, r, http.StatusForbidden, ErrorCode_CONNECTION_REJECTED.MessageObjf("%s", rej.Reason())) case errors.Is(err, api0gameserver.ErrAuthFailed): h.m().client_authwithserver_requests_total.reject_gameserverauth.Inc() respFail(w, r, http.StatusInternalServerError, ErrorCode_JSON_PARSE_ERROR.MessageObj()) // this is kind of misleading... but it's what the original master server did -- cgit v1.2.3