pre cw with probe and a bunch script to read game behavior
This commit is contained in:
1 parent
5120219ae2
commit
da8a32f60d
310 files changed
+219693
-872
No files matched your search
@@ -15,6 +15,9 @@ import (
|
||||
// RuntimeConfig is shared by both server processes. Deployment values belong
|
||||
// in configuration rather than in handlers or executable entry points.
|
||||
type RuntimeConfig struct {
|
||||
ActivitySchedule ActivityScheduleConfig `json:"activity_schedule"`
|
||||
AccountName string `json:"account_name"`
|
||||
Srtool SrtoolConfig `json:"srtool"`
|
||||
PlayerUID uint32 `json:"player_uid"`
|
||||
BattleDiagnostics BattleDiagnosticsConfig `json:"battle_diagnostics"`
|
||||
ClientVersion string `json:"client_version"`
|
||||
@@ -26,10 +29,18 @@ type RuntimeConfig struct {
|
||||
PublicSDKURL string `json:"public_sdk_url"`
|
||||
}
|
||||
|
||||
// The schedule interval is an explicit operator policy shared by SDK, gateway,
|
||||
// and launcher. A missing interval must never silently advertise expired CW.
|
||||
type ActivityScheduleConfig struct {
|
||||
BeginTime *int64 `json:"begin_time"`
|
||||
EndTime *int64 `json:"end_time"`
|
||||
}
|
||||
|
||||
// The obfuscated protobuf class name is version-specific and comes from the
|
||||
// client's stack trace. Empty disables the read-only client wire probe.
|
||||
type BattleDiagnosticsConfig struct {
|
||||
ClientBattleType string `json:"client_battle_type"`
|
||||
ClientBattleType string `json:"client_battle_type"`
|
||||
LiveReportStaleSeconds uint16 `json:"live_report_stale_seconds"`
|
||||
}
|
||||
|
||||
func LoadRuntimeConfig() (RuntimeConfig, error) {
|
||||
@@ -51,6 +62,7 @@ func LoadRuntimeConfig() (RuntimeConfig, error) {
|
||||
}
|
||||
}
|
||||
for name, dest := range map[string]*string{
|
||||
"GAC_ACCOUNT_NAME": &cfg.AccountName,
|
||||
"GAC_CLIENT_VERSION": &cfg.ClientVersion, "GAC_GAME_HOST": &cfg.GameHost,
|
||||
"GAC_SDK_HOST": &cfg.SDKHost, "GAC_PUBLIC_GAME_HOST": &cfg.PublicGameHost,
|
||||
"GAC_PUBLIC_SDK_URL": &cfg.PublicSDKURL,
|
||||
@@ -68,6 +80,13 @@ func LoadRuntimeConfig() (RuntimeConfig, error) {
|
||||
*dest = uint16(n)
|
||||
}
|
||||
}
|
||||
if value, ok := os.LookupEnv("GAC_LIVE_BATTLE_STALE_SECONDS"); ok {
|
||||
n, err := strconv.ParseUint(value, 10, 16)
|
||||
if err != nil || n == 0 {
|
||||
return cfg, fmt.Errorf("GAC_LIVE_BATTLE_STALE_SECONDS must be an integer between 1 and 65535")
|
||||
}
|
||||
cfg.BattleDiagnostics.LiveReportStaleSeconds = uint16(n)
|
||||
}
|
||||
if value, ok := os.LookupEnv("GAC_PLAYER_UID"); ok {
|
||||
n, err := strconv.ParseUint(value, 10, 32)
|
||||
if err != nil || n == 0 {
|
||||
@@ -75,12 +94,37 @@ func LoadRuntimeConfig() (RuntimeConfig, error) {
|
||||
}
|
||||
cfg.PlayerUID = uint32(n)
|
||||
}
|
||||
for name, dest := range map[string]**int64{
|
||||
"GAC_ACTIVITY_BEGIN_TIME": &cfg.ActivitySchedule.BeginTime,
|
||||
"GAC_ACTIVITY_END_TIME": &cfg.ActivitySchedule.EndTime,
|
||||
} {
|
||||
if value, ok := os.LookupEnv(name); ok {
|
||||
n, err := strconv.ParseInt(value, 10, 64)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("%s must be an int64 Unix timestamp", name)
|
||||
}
|
||||
*dest = &n
|
||||
}
|
||||
}
|
||||
if cfg.ActivitySchedule.BeginTime == nil || cfg.ActivitySchedule.EndTime == nil ||
|
||||
*cfg.ActivitySchedule.BeginTime < 0 || *cfg.ActivitySchedule.EndTime <= *cfg.ActivitySchedule.BeginTime {
|
||||
return cfg, fmt.Errorf("activity_schedule requires nonnegative begin_time and end_time greater than begin_time")
|
||||
}
|
||||
if strings.TrimSpace(cfg.AccountName) == "" {
|
||||
return cfg, fmt.Errorf("runtime config requires account_name")
|
||||
}
|
||||
if strings.TrimSpace(cfg.Srtool.LeaseFile) == "" || cfg.Srtool.LeaseSeconds == 0 {
|
||||
return cfg, fmt.Errorf("runtime config requires srtool.lease_file and nonzero srtool.lease_seconds")
|
||||
}
|
||||
if cfg.PlayerUID == 0 {
|
||||
return cfg, fmt.Errorf("runtime config requires a nonzero player_uid")
|
||||
}
|
||||
if cfg.GamePort == 0 || cfg.SDKPort == 0 || strings.TrimSpace(cfg.ClientVersion) == "" {
|
||||
return cfg, fmt.Errorf("runtime config requires client_version, game_port and sdk_port")
|
||||
}
|
||||
if cfg.BattleDiagnostics.LiveReportStaleSeconds == 0 {
|
||||
return cfg, fmt.Errorf("runtime config requires battle_diagnostics.live_report_stale_seconds")
|
||||
}
|
||||
for name, host := range map[string]string{"game_host": cfg.GameHost, "sdk_host": cfg.SDKHost, "public_game_host": cfg.PublicGameHost} {
|
||||
if strings.TrimSpace(host) == "" || strings.ContainsAny(host, "/\\ \t\r\n") {
|
||||
return cfg, fmt.Errorf("invalid %s", name)
|
||||
|
||||
Reference in new issue
Block a user