Fix SCUM RCON runtime profile resolution
This commit is contained in:
@@ -177,21 +177,10 @@ func (svc *CoreService) resolveSourceRCONDispatch(instance domain.ServerInstance
|
||||
if !strings.EqualFold(endpoint.Platform, "windows") || !strings.EqualFold(endpoint.Architecture, "amd64") {
|
||||
return sourceRCONDispatchResolution{}, validationError("unsupported_extension_platform: SCUM Source RCON requires windows/amd64")
|
||||
}
|
||||
binding, err := svc.runtimeBindingForServer(instance.ID)
|
||||
binding, profile, err := svc.sourceRCONRuntimeProfile(instance, plugin, endpoint)
|
||||
if err != nil {
|
||||
return sourceRCONDispatchResolution{}, err
|
||||
}
|
||||
binding, err = normalizeRuntimeBinding(plugin, binding)
|
||||
if err != nil {
|
||||
return sourceRCONDispatchResolution{}, err
|
||||
}
|
||||
if binding.Status != domain.RuntimeBindingStatusComplete || binding.PluginVersion != plugin.Version {
|
||||
return sourceRCONDispatchResolution{}, validationError("runtime binding is incomplete or stale")
|
||||
}
|
||||
profile, exists := runtimeLifecycleProfileForKey(plugin.RuntimeProfiles, binding.ProfileKey)
|
||||
if !exists || !containsString(profile.Capabilities, domain.JobCapabilityRemoteRunRCONCommand) || !runtimePlatformsContain(profile.Platforms, "windows") {
|
||||
return sourceRCONDispatchResolution{}, validationError("selected runtime profile does not support SCUM RCON")
|
||||
}
|
||||
transport, err := sourceRCONTransport(plugin.RuntimeProfiles, profile)
|
||||
if err != nil {
|
||||
return sourceRCONDispatchResolution{}, err
|
||||
@@ -211,6 +200,56 @@ func (svc *CoreService) resolveSourceRCONDispatch(instance domain.ServerInstance
|
||||
return sourceRCONDispatchResolution{plugin: plugin, binding: binding, transport: transport, plan: plan}, nil
|
||||
}
|
||||
|
||||
func (svc *CoreService) sourceRCONRuntimeProfile(instance domain.ServerInstance, plugin domain.GamePlugin, endpoint domain.RunEndpoint) (domain.RuntimeBinding, domain.RuntimeLifecycleProfile, error) {
|
||||
if binding, err := svc.runtimeBindingForServer(instance.ID); err == nil {
|
||||
if normalized, normalizeErr := normalizeRuntimeBinding(plugin, binding); normalizeErr == nil {
|
||||
if profile, exists := runtimeLifecycleProfileForKey(plugin.RuntimeProfiles, normalized.ProfileKey); exists && sourceRCONProfileSupports(plugin.RuntimeProfiles, profile, endpoint) {
|
||||
return normalized, profile, nil
|
||||
}
|
||||
}
|
||||
} else if !errors.Is(err, repo.ErrNotFound) {
|
||||
return domain.RuntimeBinding{}, domain.RuntimeLifecycleProfile{}, err
|
||||
}
|
||||
|
||||
if key := strings.TrimSpace(instance.Deployment.ProfileKey); key != "" {
|
||||
if profile, exists := runtimeLifecycleProfileForKey(plugin.RuntimeProfiles, key); exists && sourceRCONProfileSupports(plugin.RuntimeProfiles, profile, endpoint) {
|
||||
return transientSourceRCONBinding(instance, plugin, profile), profile, nil
|
||||
}
|
||||
}
|
||||
|
||||
var selected domain.RuntimeLifecycleProfile
|
||||
for _, profile := range plugin.RuntimeProfiles.LifecycleProfiles {
|
||||
if !sourceRCONProfileSupports(plugin.RuntimeProfiles, profile, endpoint) {
|
||||
continue
|
||||
}
|
||||
if selected.Key != "" && selected.Key != profile.Key {
|
||||
return domain.RuntimeBinding{}, domain.RuntimeLifecycleProfile{}, validationError("selected runtime profile has multiple SCUM RCON candidates")
|
||||
}
|
||||
selected = profile
|
||||
}
|
||||
if selected.Key == "" {
|
||||
return domain.RuntimeBinding{}, domain.RuntimeLifecycleProfile{}, validationError("selected runtime profile does not support SCUM RCON")
|
||||
}
|
||||
return transientSourceRCONBinding(instance, plugin, selected), selected, nil
|
||||
}
|
||||
|
||||
func sourceRCONProfileSupports(profiles domain.GamePluginRuntimeProfiles, profile domain.RuntimeLifecycleProfile, endpoint domain.RunEndpoint) bool {
|
||||
if !containsString(profile.Capabilities, domain.JobCapabilityRemoteRunRCONCommand) || !runtimePlatformsContain(profile.Platforms, "windows") {
|
||||
return false
|
||||
}
|
||||
if _, err := sourceRCONTransport(profiles, profile); err != nil {
|
||||
return false
|
||||
}
|
||||
if _, err := sourceRCONExtension(profiles, profile, endpoint); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func transientSourceRCONBinding(instance domain.ServerInstance, plugin domain.GamePlugin, profile domain.RuntimeLifecycleProfile) domain.RuntimeBinding {
|
||||
return domain.RuntimeBinding{ID: "runtime-binding-" + instance.ID, ServerInstanceID: instance.ID, PluginID: plugin.ID, PluginVersion: plugin.Version, ProfileKey: profile.Key, Mode: profile.Mode, Status: domain.RuntimeBindingStatusComplete}
|
||||
}
|
||||
|
||||
func sourceRCONTransport(profiles domain.GamePluginRuntimeProfiles, profile domain.RuntimeLifecycleProfile) (domain.RuntimeTransportProfile, error) {
|
||||
return sourceRCONTransportForCapability(profiles, profile, "", domain.JobCapabilityRemoteRunRCONCommand)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user