Skip to content

Commit

Permalink
Merge pull request #314 from inada-s/feature/ban-flycast-version
Browse files Browse the repository at this point in the history
ban flycast-gdxsv 1.7.0 to 1.7.2
  • Loading branch information
inada-s authored Jan 21, 2025
2 parents 47cf913 + c8cac60 commit 277633d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 11 additions & 2 deletions gdxsv/lbs_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ func isOldFlycastVersion(userVersion string, minVersion string) bool {
return false
}

func isBannedFlycastVersion(userVersion string) bool {
if strings.HasPrefix(userVersion, "gdxsv-") {
userVersion = "v" + strings.TrimPrefix(userVersion, "gdxsv-")
}
return bannedFlycastVersions[userVersion]
}

var _ = register(lbsLoginType, func(p *LbsPeer, m *LbsMessage) {
loginType := m.Reader().Read8()

Expand All @@ -296,7 +303,8 @@ var _ = register(lbsLoginType, func(p *LbsPeer, m *LbsMessage) {

switch loginType {
case 0:
if p.PlatformInfo["flycast"] != "" && isOldFlycastVersion(p.PlatformInfo["flycast"], requiredFlycastVersion) {
v := p.PlatformInfo["flycast"]
if v != "" && (isOldFlycastVersion(v, requiredFlycastVersion) || isBannedFlycastVersion(v)) {
p.SendMessage(NewServerNotice(lbsShutDown).Writer().
WriteString("<LF=5><BODY><CENTER>PLEASE UPDATE Flycast<END>").Msg())
return
Expand Down Expand Up @@ -346,7 +354,8 @@ var _ = register(lbsLoginType, func(p *LbsPeer, m *LbsMessage) {
p.SendMessage(NewServerNotice(lbsShutDown).Writer().
WriteString("<LF=5><BODY><CENTER>UNSUPPORTED LOGIN TYPE<END>").Msg())
case 2:
if p.PlatformInfo["flycast"] != "" && isOldFlycastVersion(p.PlatformInfo["flycast"], requiredFlycastVersion) {
v := p.PlatformInfo["flycast"]
if v != "" && (isOldFlycastVersion(v, requiredFlycastVersion) || isBannedFlycastVersion(v)) {
p.SendMessage(NewServerNotice(lbsShutDown).Writer().
WriteString("<LF=5><BODY><CENTER>PLEASE UPDATE Flycast<END>").Msg())
return
Expand Down
2 changes: 1 addition & 1 deletion gdxsv/lbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ us-east4=161
us-west1=94
us-west2=100
us-west3=112
flycast=gdxsv-1.4.7
flycast=gdxsv-1.6.2
build_date=2023-05-30T17:23:27Z
git_hash=abf868a
cpu=x86/64
Expand Down
9 changes: 8 additions & 1 deletion gdxsv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ var (
gdxsvRevision string

// Minimum required flycast version.
requiredFlycastVersion = "v1.2.0"
requiredFlycastVersion = "v1.6.2"

// Released but broken flycast versions.
bannedFlycastVersions = map[string]bool{
"v1.7.0": true,
"v1.7.1": true,
"v1.7.2": true,
}

// Global random
gRand = rand.New(rand.NewSource(time.Now().UnixNano()))
Expand Down

0 comments on commit 277633d

Please sign in to comment.