aboutsummaryrefslogtreecommitdiff
path: root/pkg/api/api0/client.go
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2023-03-06 00:16:04 -0500
committerpg9182 <96569817+pg9182@users.noreply.github.com>2023-03-07 20:04:20 -0500
commita3109ce30f0de2fec0f5f130761939233cbeee77 (patch)
treead3a3d794fa3429f2eb9a3bfedfb3113a0677e66 /pkg/api/api0/client.go
parent18f4f61f0af62edd095da7b87533972e3f2b35fa (diff)
downloadAtlas-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.go4
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