diff options
author | pg9182 <96569817+pg9182@users.noreply.github.com> | 2023-03-06 00:16:04 -0500 |
---|---|---|
committer | pg9182 <96569817+pg9182@users.noreply.github.com> | 2023-03-07 20:04:20 -0500 |
commit | a3109ce30f0de2fec0f5f130761939233cbeee77 (patch) | |
tree | ad3a3d794fa3429f2eb9a3bfedfb3113a0677e66 /pkg/api/api0/client.go | |
parent | 18f4f61f0af62edd095da7b87533972e3f2b35fa (diff) | |
download | Atlas-a3109ce30f0de2fec0f5f130761939233cbeee77.tar.gz Atlas-a3109ce30f0de2fec0f5f130761939233cbeee77.zip |
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.
Diffstat (limited to 'pkg/api/api0/client.go')
-rw-r--r-- | pkg/api/api0/client.go | 4 |
1 files changed, 4 insertions, 0 deletions
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 |