feat(dragonwilds): MATCH_PUBLIC so the join code works behind a relay #29

Merged
git_pipeline merged 2 commits from feat/dragonwilds-match-public into main 2026-11-08 01:48:01 +00:00
2 changed files with 23 additions and 1 deletions
Showing only changes of commit bb4fd3e11c - Show all commits

No files matched your search

+8 -1
View File
@@ -153,6 +153,13 @@ func bootTestPayload(gamesDir, id string, fillBlank bool) (map[string]any, error
} }
} }
// The panel fills {PUBLIC_IP}, {PUBLIC_HOST} and {PUBLIC_PORT_n} in the startup command too
startup := g["defaultStartupCommand"]
if cmd, ok := startup.(string); ok {
cmd = strings.NewReplacer("{PUBLIC_IP}", "127.0.0.1", "{PUBLIC_HOST}", "127.0.0.1").Replace(cmd)
startup = publicPort.ReplaceAllString(cmd, "$1")
}
return map[string]any{ return map[string]any{
"command": "DEPLOY_SERVER", "command": "DEPLOY_SERVER",
"serverId": "boottest-" + id, "serverId": "boottest-" + id,
@@ -166,7 +173,7 @@ func bootTestPayload(gamesDir, id string, fillBlank bool) (map[string]any, error
"configFilePath": g["configFilePath"], "configFilePath": g["configFilePath"],
"configFileFormat": g["configFileFormat"], "configFileFormat": g["configFileFormat"],
"configFormatOptions": g["configFormatOptions"], "configFormatOptions": g["configFormatOptions"],
"startupCommand": g["defaultStartupCommand"], "startupCommand": startup,
"memoryLimitMb": g["requiredMemoryMb"], "memoryLimitMb": g["requiredMemoryMb"],
"containerUser": g["containerUser"], "containerUser": g["containerUser"],
"dockerNetwork": bootTestNetwork, "dockerNetwork": bootTestNetwork,
+15
View File
@@ -132,3 +132,18 @@ func TestSteamCacheStampAge(t *testing.T) {
t.Error("old, missing or garbled stamps are not fresh") t.Error("old, missing or garbled stamps are not fresh")
} }
} }
func TestBootTestPayloadFillsPublicPlaceholdersInStartupCommand(t *testing.T) {
dir := t.TempDir()
game := filepath.Join(dir, "example")
os.MkdirAll(game, 0o755)
os.WriteFile(filepath.Join(game, "game.yaml"), []byte("id: example\nname: Example\ndefaultDockerImage: x\n"+
"defaultStartupCommand: ./server -Port={PUBLIC_PORT_7777} -ip={PUBLIC_IP}\ndefaultPorts:\n - 7777/udp\n"), 0o644)
p, err := bootTestPayload(dir, "example", false)
if err != nil {
t.Fatal(err)
}
if p["startupCommand"] != "./server -Port=7777 -ip=127.0.0.1" {
t.Errorf("startupCommand %v", p["startupCommand"])
}
}