feat: add timestamp to token names for true uniqueness

Token names now include both Pulse server IP and Unix timestamp (e.g. pulse-192-168-0-176-1754816525) ensuring each script run creates a unique token. This completely eliminates 'token already exists' errors when running setup scripts multiple times.
This commit is contained in:
Pulse Monitor 2025-08-10 09:02:52 +00:00
parent 5a98e05cb0
commit 1da7ca4ea7

View file

@ -1573,15 +1573,18 @@ func (h *ConfigHandlers) HandleSetupScript(w http.ResponseWriter, r *http.Reques
}
}
// Create unique token name based on Pulse IP
tokenName := fmt.Sprintf("pulse-%s", pulseIP)
// Create unique token name based on Pulse IP and timestamp
// Adding timestamp ensures truly unique tokens even when running from same Pulse server
timestamp := time.Now().Unix()
tokenName := fmt.Sprintf("pulse-%s-%d", pulseIP, timestamp)
// Log the token name for debugging
log.Info().
Str("pulseURL", pulseURL).
Str("pulseIP", pulseIP).
Str("tokenName", tokenName).
Msg("Generated token name for setup script")
Int64("timestamp", timestamp).
Msg("Generated unique token name for setup script")
var script string