aboutsummaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2023-02-22 13:03:14 -0500
committerpg9182 <96569817+pg9182@users.noreply.github.com>2023-02-25 07:20:18 -0500
commitd905e4eca49f121dbd374254daa6b506d102045e (patch)
tree69c0c250d4fff5f25189be78269c3817e826cd2c /pkg/api
parent65515ba923039b2a4c84e34822fd7c9e4911786d (diff)
downloadAtlas-d905e4eca49f121dbd374254daa6b506d102045e.tar.gz
Atlas-d905e4eca49f121dbd374254daa6b506d102045e.zip
pkg/atlas, pkg/api/api0: Split minimum launcher version by client/server
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/api0/api.go13
-rw-r--r--pkg/api/api0/client.go6
-rw-r--r--pkg/api/api0/server.go2
3 files changed, 13 insertions, 8 deletions
diff --git a/pkg/api/api0/api.go b/pkg/api/api0/api.go
index 38d1741..1c2683f 100644
--- a/pkg/api/api0/api.go
+++ b/pkg/api/api0/api.go
@@ -70,10 +70,10 @@ type Handler struct {
// @BobTheBob9 for this option even existing in the first place.
InsecureDevNoCheckPlayerAuth bool
- // MinimumLauncherVersion restricts authentication and server registration
+ // MinimumLauncherVersion* restricts authentication and server registration
// to clients with at least this version, which must be valid semver. +dev
// versions are always allowed.
- MinimumLauncherVersion string
+ MinimumLauncherVersionClient, MinimumLauncherVersionServer string
// TokenExpiryTime controls the expiry of player masterserver auth tokens.
// If zero, a reasonable a default is used.
@@ -149,7 +149,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// CheckLauncherVersion checks if the r was made by NorthstarLauncher and if it
// is at least MinimumLauncherVersion.
-func (h *Handler) CheckLauncherVersion(r *http.Request) bool {
+func (h *Handler) CheckLauncherVersion(r *http.Request, client bool) bool {
rver, _, _ := strings.Cut(r.Header.Get("User-Agent"), " ")
if x := strings.TrimPrefix(rver, "R2Northstar/"); rver != x {
if len(x) > 0 && x[0] != 'v' {
@@ -162,7 +162,12 @@ func (h *Handler) CheckLauncherVersion(r *http.Request) bool {
return false // deny: not R2Northstar
}
- mver := h.MinimumLauncherVersion
+ var mver string
+ if client {
+ mver = h.MinimumLauncherVersionClient
+ } else {
+ mver = h.MinimumLauncherVersionServer
+ }
if mver != "" {
if mver[0] != 'v' {
mver = "v" + mver
diff --git a/pkg/api/api0/client.go b/pkg/api/api0/client.go
index b4e80d1..b64659a 100644
--- a/pkg/api/api0/client.go
+++ b/pkg/api/api0/client.go
@@ -88,7 +88,7 @@ func (h *Handler) handleClientOriginAuth(w http.ResponseWriter, r *http.Request)
return
}
- if !h.CheckLauncherVersion(r) {
+ if !h.CheckLauncherVersion(r, true) {
h.m().client_originauth_requests_total.reject_versiongate.Inc()
respFail(w, r, http.StatusBadRequest, ErrorCode_UNSUPPORTED_VERSION.MessageObj())
return
@@ -323,7 +323,7 @@ func (h *Handler) handleClientAuthWithServer(w http.ResponseWriter, r *http.Requ
return
}
- if !h.CheckLauncherVersion(r) {
+ if !h.CheckLauncherVersion(r, true) {
h.m().client_authwithserver_requests_total.reject_versiongate.Inc()
respFail(w, r, http.StatusBadRequest, ErrorCode_UNSUPPORTED_VERSION.MessageObj())
return
@@ -479,7 +479,7 @@ func (h *Handler) handleClientAuthWithSelf(w http.ResponseWriter, r *http.Reques
return
}
- if !h.CheckLauncherVersion(r) {
+ if !h.CheckLauncherVersion(r, true) {
h.m().client_authwithself_requests_total.reject_versiongate.Inc()
respFail(w, r, http.StatusBadRequest, ErrorCode_UNSUPPORTED_VERSION.MessageObj())
return
diff --git a/pkg/api/api0/server.go b/pkg/api/api0/server.go
index 3e02a26..93608b0 100644
--- a/pkg/api/api0/server.go
+++ b/pkg/api/api0/server.go
@@ -54,7 +54,7 @@ func (h *Handler) handleServerUpsert(w http.ResponseWriter, r *http.Request) {
return
}
- if !h.CheckLauncherVersion(r) {
+ if !h.CheckLauncherVersion(r, false) {
h.m().server_upsert_requests_total.reject_versiongate(action).Inc()
respFail(w, r, http.StatusBadRequest, ErrorCode_UNSUPPORTED_VERSION.MessageObj())
return