| package executor |
|
|
| import ( |
| "crypto/rand" |
| "encoding/hex" |
| "regexp" |
| "strings" |
|
|
| "github.com/google/uuid" |
| ) |
|
|
| |
| var userIDPattern = regexp.MustCompile(`^user_[a-fA-F0-9]{64}_account__session_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`) |
|
|
| |
| |
| func generateFakeUserID() string { |
| hexBytes := make([]byte, 32) |
| _, _ = rand.Read(hexBytes) |
| hexPart := hex.EncodeToString(hexBytes) |
| uuidPart := uuid.New().String() |
| return "user_" + hexPart + "_account__session_" + uuidPart |
| } |
|
|
| |
| func isValidUserID(userID string) bool { |
| return userIDPattern.MatchString(userID) |
| } |
|
|
| |
| |
| func shouldCloak(cloakMode string, userAgent string) bool { |
| switch strings.ToLower(cloakMode) { |
| case "always": |
| return true |
| case "never": |
| return false |
| default: |
| |
| return !strings.HasPrefix(userAgent, "claude-cli") |
| } |
| } |
|
|
| |
| func isClaudeCodeClient(userAgent string) bool { |
| return strings.HasPrefix(userAgent, "claude-cli") |
| } |
|
|