Documentation
¶
Index ¶
Constants ¶
const ( // Server configuration ServerUploadLimit = 25 * 1024 * 1024 // 25 MB per file ServerBodyLimit = 150 * 1024 * 1024 // 150 MB total request body (for multiple files + form data) ServerRateLimitMax = 600 ServerRateLimitExp = 1 * time.Minute RegistrationRateLimitMax = 20 // Registration attempts per IP RegistrationRateLimitExp = 15 * time.Minute // Within 15 minutes RecoveryRateLimitMax = 20 // New recovery starts per IP RecoveryRateLimitExp = 15 * time.Minute // Within 15 minutes LoginRateLimitMax = 20 // Allow 20 login POSTs per IP LoginRateLimitExp = 15 * time.Minute // Within 15 minutes LoginUserFailMax = 10 // Failed auths per username LoginUserFailExp = 15 * time.Minute // Username failure window RecoverySessionTTL = 10 * time.Minute // Recover session / code lifetime RegistrationTicketTTL = 10 * time.Minute // Post-OTP registration ticket lifetime OTPStartMinInterval = 60 * time.Second // Min time between OTP starts per phone OTPStartMaxPerHour = 5 // Max OTP starts per phone per hour // MinIO configuration MinIOPresignedPutExpiry = 15 * time.Minute MinIOPresignedGetExpiry = 24 * time.Hour MinIOObjectCacheControl = "public, max-age=86400" // Vector search configuration SearchPageSize = 20 // Number of search results per page SearchThreshold = 0.6 // Max cosine distance for vector search (pgvector <=>) VectorProcessingQueueSize = 100 VectorUserEmbeddingLimit = 8 VectorSiteEmbeddingLimit = 8 VectorSystemEmbeddingLimit = 100 // Embedding cache TTL configuration VectorQueryEmbeddingCacheTTL = 1 * time.Hour // TTL for query embedding cache VectorUserEmbeddingCacheTTL = 1 * time.Hour // TTL for user embedding cache VectorSiteEmbeddingCacheTTL = 1 * time.Hour // TTL for site embedding cache // Grok API configuration GrokAPIURL = "https://api.x.ai/v1/chat/completions" GrokModel = "grok-4.3" GrokReasoningEffort = "none" // Geoapify geocoding GeoapifyGeocodeURL = "https://api.geoapify.com/v1/geocode/search" // Ollama embedding configuration OllamaEmbeddingModel = "nomic-embed-text" OllamaEmbeddingDimensions = 768 // Ad configuration MaxImagesPerAd = 20 MaxFlagCount = 2 // Maximum flag count to allow in search results MaxOutstandingFlags = 3 // Flags granted at signup; max a user can have raised at once DefaultAdCategoryName = "Car & Truck Parts" MaxAdTitleLength = 64 // Maximum length for ad title MaxAdDescriptionLength = 1000 // Maximum length for ad description AdExpireMonths = 12 // create, reactivate, and renew lifetime AdExpireRenewWithinMonths = 1 // show Renew when this little time remains AdExpireWorkerInterval = 1 * time.Hour // Password/Argon2 configuration Argon2Memory = 64 * 1024 // HTMX scripts (self-hosted for privacy browsers that block third-party CDNs) HTMXURL = "/js/htmx.min.js" HTMXSSEURL = "/js/htmx-ext-sse.min.js" // Public links GitHubRepoURL = "https://github.com/partspile/site" // SSE configuration SSEChannelBufferSize = 100 // Buffer size for user event channels // SMS queue configuration SMSSuppressionWindowMinutes = 10 // Suppress SMS if sent within this many minutes SMSWorkerPollInterval = 5 * time.Second // How often worker checks for pending notifications SMSQueueCleanupInterval = 1 * time.Hour // How often to cleanup old records SMSQueueRetentionHours = 24 // How long to keep processed/suppressed records )
Variables ¶
var ( // PublicSiteURL — public base for SMS links and Twilio webhooks PublicSiteURL = trimURLBase(os.Getenv("PUBLIC_SITE_URL")) // Database configuration DatabaseURL = getEnvWithDefault("DATABASE_URL", "postgres://localhost:5432/partspile?sslmode=disable") // Redis (shared rate limits). Required. // Example: redis://localhost:6379 or redis://red-xxx:6379 RedisURL = getEnvWithDefault("REDIS_URL", "") // MinIO configuration MinIOAPIURL = getEnvWithDefault("MINIO_API_URL", "") MinIOPublicURL = getEnvWithDefault("MINIO_PUBLIC_URL", "") MinIORootUser = getEnvWithDefault("MINIO_ROOT_USER", "") MinIORootPassword = getEnvWithDefault("MINIO_ROOT_PASSWORD", "") MinIOBucketName = getEnvWithDefault("MINIO_BUCKET_NAME", "") // AI/ML API configuration GrokAPIKey = getEnvWithDefault("GROK_API_KEY", "") GeoapifyAPIKey = getEnvWithDefault("GEOAPIFY_API_KEY", "") OllamaURL = getEnvWithDefault("OLLAMA_URL", "http://localhost:11434") // SMS/Twilio configuration TwilioAccountSID = getEnvWithDefault("TWILIO_ACCOUNT_SID", "") TwilioAuthToken = getEnvWithDefault("TWILIO_AUTH_TOKEN", "") TwilioFromNumber = getEnvWithDefault("TWILIO_FROM_NUMBER", "") TwilioVerifyServiceSID = getEnvWithDefault("TWILIO_VERIFY_SERVICE_SID", "") // Cloudflare Turnstile (bot gate before OTP start) TurnstileSiteKey = getEnvWithDefault("TURNSTILE_SITE_KEY", "") TurnstileSecretKey = getEnvWithDefault("TURNSTILE_SECRET_KEY", "") // JWT configuration JWTSecret = []byte(getEnvWithDefault("JWT_SECRET", "")) // DB encryption (user name/phone; journals on restore / later at rest) DBEncryptionKey = getEncryptionKey("DB_ENCRYPTION_KEY") // Pepper for name_hash / phone_hash HMAC lookups (not the encryption key) DBHashPepper = getEncryptionKey("DB_HASH_PEPPER") ShareSecret = getEncryptionKey("SHARE_SECRET") // Server configuration ServerPort = getEnvWithDefault("PORT", "10000") // ServerName is the brand. LegalName is the Oregon registered entity. ServerName = os.Getenv("APP_NAME") LegalName = "Parts Pile, LLC" ContactEmail = os.Getenv("CONTACT_EMAIL") // Public Bitcoin address for /donate (on-chain receive address). BitcoinDonateAddress = getEnvWithDefault("BITCOIN_DONATE_ADDRESS", "") // Test port - used when running tests to avoid conflicts with main server TestPort = getEnvWithDefault("PORT_TEST", "10001") // Cookie security - set LOCAL_DEVELOPMENT=true to relax cookie security for local HTTP access // When LOCAL_DEVELOPMENT is set, cookies will work over HTTP even if PUBLIC_SITE_URL is HTTPS CookieSecure = os.Getenv("LOCAL_DEVELOPMENT") != "true" // AllowTestRegistration skips SMS verification for +1555010xxxx phones (dev/test harness). AllowTestRegistration = os.Getenv("ALLOW_TEST_REGISTRATION") == "true" // Logging configuration LogLevel = getEnvWithDefault("LOG_LEVEL", "info") LogFormat = getEnvWithDefault("LOG_FORMAT", "json") LogFile = getEnvWithDefault("LOG_FILE", "") )
Global configuration variables
Functions ¶
func CanonicalURL ¶
CanonicalURL is the absolute public URL for path (no query or fragment).
func EffectiveLoginRateLimitMax ¶
func EffectiveLoginRateLimitMax() int
EffectiveLoginRateLimitMax returns the login IP rate limit max attempts.
func EffectiveLoginUserFailMax ¶
func EffectiveLoginUserFailMax() int
EffectiveLoginUserFailMax returns the per-username failed-login cap.
func EffectiveRecoveryRateLimitMax ¶
func EffectiveRecoveryRateLimitMax() int
EffectiveRecoveryRateLimitMax returns the recovery rate limit max attempts.
func EffectiveRegistrationRateLimitMax ¶
func EffectiveRegistrationRateLimitMax() int
EffectiveRegistrationRateLimitMax returns the registration rate limit max attempts.
func SecurityCheck ¶
func SecurityCheck()
SecurityCheck validates security configuration and logs warnings Logs fatal errors for required configs, warnings for insecure defaults
Types ¶
This section is empty.