From 1da7ca4ea769f98a872210862cb0ec0f46341e29 Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Sun, 10 Aug 2025 09:02:52 +0000 Subject: [PATCH] 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. --- internal/api/config_handlers.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.go index 8aa4e7ea0..8f0caccc9 100644 --- a/internal/api/config_handlers.go +++ b/internal/api/config_handlers.go @@ -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