diff options
Diffstat (limited to 'pkg/atlas')
-rw-r--r-- | pkg/atlas/config.go | 10 | ||||
-rw-r--r-- | pkg/atlas/server.go | 19 |
2 files changed, 27 insertions, 2 deletions
diff --git a/pkg/atlas/config.go b/pkg/atlas/config.go index e8a42c9..d519094 100644 --- a/pkg/atlas/config.go +++ b/pkg/atlas/config.go @@ -106,6 +106,16 @@ type Config struct { // allowed. API0_MinimumLauncherVersion string `env:"ATLAS_API0_MINIMUM_LAUNCHER_VERSION"` + // Minimum launcher semver to allow for authenticated clients, replacing + // ATLAS_API0_MINIMUM_LAUNCHER_VERSION. Dev versions are always allowed. If + // not provided, API0_MinimumLauncherVersion is used. + API0_MinimumLauncherVersionClient string `env:"ATLAS_API0_MINIMUM_LAUNCHER_VERSION_CLIENT"` + + // Minimum launcher semver to allow for servers, replacing + // ATLAS_API0_MINIMUM_LAUNCHER_VERSION. Dev versions are always allowed. If + // not provided, API0_MinimumLauncherVersion is used. + API0_MinimumLauncherVersionServer string `env:"ATLAS_API0_MINIMUM_LAUNCHER_VERSION_SERVER"` + // Region mapping to use for server list. If set to an empty string or // "none", region maps are disabled. Options: none, default. API0_RegionMap string `env:"ATLAS_API0_REGION_MAP?=default"` diff --git a/pkg/atlas/server.go b/pkg/atlas/server.go index d1f7c7d..145bb45 100644 --- a/pkg/atlas/server.go +++ b/pkg/atlas/server.go @@ -59,6 +59,12 @@ func NewServer(c *Config) (*Server, error) { if c.API0_MinimumLauncherVersion != "" && !semver.IsValid("v"+strings.TrimPrefix(c.API0_MinimumLauncherVersion, "v")) { return nil, fmt.Errorf("invalid minimum launcher version semver %q", c.API0_MinimumLauncherVersion) } + if c.API0_MinimumLauncherVersionClient != "" && !semver.IsValid("v"+strings.TrimPrefix(c.API0_MinimumLauncherVersionClient, "v")) { + return nil, fmt.Errorf("invalid minimum launcher client version semver %q", c.API0_MinimumLauncherVersionClient) + } + if c.API0_MinimumLauncherVersionServer != "" && !semver.IsValid("v"+strings.TrimPrefix(c.API0_MinimumLauncherVersionServer, "v")) { + return nil, fmt.Errorf("invalid minimum launcher server version semver %q", c.API0_MinimumLauncherVersionServer) + } var s Server var success bool @@ -269,10 +275,19 @@ func NewServer(c *Config) (*Server, error) { MaxServers: c.API0_MaxServers, MaxServersPerIP: c.API0_MaxServersPerIP, InsecureDevNoCheckPlayerAuth: c.API0_InsecureDevNoCheckPlayerAuth, - MinimumLauncherVersion: c.API0_MinimumLauncherVersion, + MinimumLauncherVersionClient: c.API0_MinimumLauncherVersionClient, + MinimumLauncherVersionServer: c.API0_MinimumLauncherVersionServer, TokenExpiryTime: c.API0_TokenExpiryTime, AllowGameServerIPv6: c.API0_AllowGameServerIPv6, } + if v := c.API0_MinimumLauncherVersion; v != "" { + if s.API0.MinimumLauncherVersionClient == "" { + s.API0.MinimumLauncherVersionClient = v + } + if s.API0.MinimumLauncherVersionServer == "" { + s.API0.MinimumLauncherVersionServer = v + } + } s.API0.NotFound = new(middlewares). Add(hlog.NewHandler(s.Logger)). @@ -703,7 +718,7 @@ func configureMainMenuPromosUpdateNeeded(c *Config, h *api0.Handler) error { if fn1 != nil { mmp = fn1(r) } - if r == nil || !h.CheckLauncherVersion(r) { + if r == nil || !h.CheckLauncherVersion(r, true) { if buf, err1 := os.ReadFile(p); err1 != nil { err = err1 } else if err = json.Unmarshal(buf, &mmp); err != nil { |