aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2023-06-17 19:46:32 -0400
committerpg9182 <96569817+pg9182@users.noreply.github.com>2023-06-17 19:46:32 -0400
commit6c4c55369862c69bff64c0cb5f937e458c5e9266 (patch)
treee7f48ed2f4e0104883d195e797e322bb8dc41670
parent4ca91ad422b455a9ef44df10cc5ccde2e2c67c12 (diff)
downloadAtlas-6c4c55369862c69bff64c0cb5f937e458c5e9266.tar.gz
Atlas-6c4c55369862c69bff64c0cb5f937e458c5e9266.zip
pkg/api/api0: Separate error message for missing gameserver
This happens frequently enough to justify it.
-rw-r--r--pkg/api/api0/client.go7
-rw-r--r--pkg/api/api0/errors.go3
-rw-r--r--pkg/api/api0/metrics.go30
3 files changed, 25 insertions, 15 deletions
diff --git a/pkg/api/api0/client.go b/pkg/api/api0/client.go
index 6d90bc2..b62107d 100644
--- a/pkg/api/api0/client.go
+++ b/pkg/api/api0/client.go
@@ -519,7 +519,12 @@ func (h *Handler) handleClientAuthWithServer(w http.ResponseWriter, r *http.Requ
password := r.URL.Query().Get("password")
srv := h.ServerList.GetServerByID(server)
- if srv == nil || srv.Password != password {
+ if srv == nil {
+ h.m().client_authwithserver_requests_total.reject_gameserver_not_found.Inc()
+ respFail(w, r, http.StatusUnauthorized, ErrorCode_GAMESERVER_NOT_FOUND.MessageObj())
+ return
+ }
+ if srv.Password != password {
h.m().client_authwithserver_requests_total.reject_password.Inc()
respFail(w, r, http.StatusUnauthorized, ErrorCode_UNAUTHORIZED_PWD.MessageObj())
return
diff --git a/pkg/api/api0/errors.go b/pkg/api/api0/errors.go
index 244200b..d424d33 100644
--- a/pkg/api/api0/errors.go
+++ b/pkg/api/api0/errors.go
@@ -17,6 +17,7 @@ const (
ErrorCode_STRYDER_RESPONSE ErrorCode = "STRYDER_RESPONSE" // Got bad response from stryder
ErrorCode_STRYDER_PARSE ErrorCode = "STRYDER_PARSE" // Couldn't parse stryder response
ErrorCode_PLAYER_NOT_FOUND ErrorCode = "PLAYER_NOT_FOUND" // Couldn't find player account
+ ErrorCode_GAMESERVER_NOT_FOUND ErrorCode = "GAMESERVER_NOT_FOUND" // Couldn't find game server
ErrorCode_INVALID_MASTERSERVER_TOKEN ErrorCode = "INVALID_MASTERSERVER_TOKEN" // Invalid or expired masterserver token
ErrorCode_JSON_PARSE_ERROR ErrorCode = "JSON_PARSE_ERROR" // Error parsing json response
ErrorCode_UNSUPPORTED_VERSION ErrorCode = "UNSUPPORTED_VERSION" // The version you are using is no longer supported
@@ -77,6 +78,8 @@ func (n ErrorCode) Message() string {
return "Couldn't parse stryder response"
case ErrorCode_PLAYER_NOT_FOUND:
return "Couldn't find player account"
+ case ErrorCode_GAMESERVER_NOT_FOUND:
+ return "Couldn't find game server"
case ErrorCode_INVALID_MASTERSERVER_TOKEN:
return "Invalid or expired masterserver token"
case ErrorCode_JSON_PARSE_ERROR:
diff --git a/pkg/api/api0/metrics.go b/pkg/api/api0/metrics.go
index 33c47b6..ac54944 100644
--- a/pkg/api/api0/metrics.go
+++ b/pkg/api/api0/metrics.go
@@ -87,20 +87,21 @@ type apiMetrics struct {
fail_other_error *metrics.Counter
}
client_authwithserver_requests_total struct {
- success *metrics.Counter
- reject_bad_request *metrics.Counter
- reject_versiongate *metrics.Counter
- reject_player_not_found *metrics.Counter
- reject_masterserver_token *metrics.Counter
- reject_password *metrics.Counter
- reject_gameserverauth *metrics.Counter
- reject_gameserver *metrics.Counter
- fail_gameserverauth *metrics.Counter
- fail_gameserverauthudp *metrics.Counter
- fail_storage_error_account *metrics.Counter
- fail_storage_error_pdata *metrics.Counter
- fail_other_error *metrics.Counter
- http_method_not_allowed *metrics.Counter
+ success *metrics.Counter
+ reject_bad_request *metrics.Counter
+ reject_versiongate *metrics.Counter
+ reject_gameserver_not_found *metrics.Counter
+ reject_player_not_found *metrics.Counter
+ reject_masterserver_token *metrics.Counter
+ reject_password *metrics.Counter
+ reject_gameserverauth *metrics.Counter
+ reject_gameserver *metrics.Counter
+ fail_gameserverauth *metrics.Counter
+ fail_gameserverauthudp *metrics.Counter
+ fail_storage_error_account *metrics.Counter
+ fail_storage_error_pdata *metrics.Counter
+ fail_other_error *metrics.Counter
+ http_method_not_allowed *metrics.Counter
}
client_authwithserver_gameserverauth_duration_seconds *metrics.Histogram
client_authwithserver_gameserverauthudp_duration_seconds *metrics.Histogram
@@ -277,6 +278,7 @@ func (h *Handler) m() *apiMetrics {
mo.client_authwithserver_requests_total.success = mo.set.NewCounter(`atlas_api0_client_authwithserver_requests_total{result="success"}`)
mo.client_authwithserver_requests_total.reject_bad_request = mo.set.NewCounter(`atlas_api0_client_authwithserver_requests_total{result="reject_bad_request"}`)
mo.client_authwithserver_requests_total.reject_versiongate = mo.set.NewCounter(`atlas_api0_client_authwithserver_requests_total{result="reject_versiongate"}`)
+ mo.client_authwithserver_requests_total.reject_gameserver_not_found = mo.set.NewCounter(`atlas_api0_client_authwithserver_requests_total{result="reject_gameserver_not_found"}`)
mo.client_authwithserver_requests_total.reject_player_not_found = mo.set.NewCounter(`atlas_api0_client_authwithserver_requests_total{result="reject_player_not_found"}`)
mo.client_authwithserver_requests_total.reject_masterserver_token = mo.set.NewCounter(`atlas_api0_client_authwithserver_requests_total{result="reject_masterserver_token"}`)
mo.client_authwithserver_requests_total.reject_password = mo.set.NewCounter(`atlas_api0_client_authwithserver_requests_total{result="reject_password"}`)