mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
fix: validate Agones assigned endpoints
This commit is contained in:
@@ -145,11 +145,11 @@ func (s *Supervisor) assignedEndpoint(ctx context.Context) (int, string, error)
|
||||
if err := s.sdkGet(ctx, "/gameserver", &server); err != nil {
|
||||
return 0, "", err
|
||||
}
|
||||
if len(server.Status.Ports) == 0 || server.Status.Address == "" {
|
||||
if len(server.Status.Ports) == 0 || strings.TrimSpace(server.Status.Address) == "" || strings.ContainsAny(server.Status.Address, " \t\r\n") {
|
||||
return 0, "", fmt.Errorf("Agones returned no assigned endpoint")
|
||||
}
|
||||
for _, port := range server.Status.Ports {
|
||||
if port.Port > 0 && (port.Name == "game" || len(server.Status.Ports) == 1) {
|
||||
if port.Port > 0 && port.Port <= 65535 && (port.Name == "game" || len(server.Status.Ports) == 1) {
|
||||
return port.Port, server.Status.Address, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user