# Unified Blossom-BitTorrent Gateway Configuration
# Mode: unified (all services), gateway-only, blossom-only, dht-only
mode: unified

# Gateway HTTP API server
gateway:
  enabled: true
  port: 9877
  max_upload_size: 10GB
  public_url: "https://gateway.sovbit.host"  # Public URL for BitTorrent/DHT bootstrap

# Embedded Blossom server
blossom_server:
  enabled: true
  port: 8082
  storage_path: "./data/blobs"
  max_blob_size: 100MB
  rate_limit:
    requests_per_minute: 100
    burst_size: 20

# DHT node configuration
dht:
  enabled: true
  port: 6883
  node_id: ""  # auto-generate if empty
  bootstrap_self: true
  bootstrap_nodes:
    - "router.bittorrent.com:6881"
    - "dht.transmissionbt.com:6881"
    - "router.utorrent.com:6881"
    - "dht.libtorrent.org:25401"
  announce_interval: 900s  # 15 minutes
  cleanup_interval: 3600s  # 1 hour
  max_torrents: 10000
  max_nodes: 5000
  max_peers_per_torrent: 200

# Shared storage configuration
storage:
  blob_threshold: 104857600    # 100MB in bytes
  chunk_size: 2097152          # 2MB chunks for large files  
  metadata_db: "./data/metadata.db"
  blob_storage: "./data/blobs"
  chunk_storage: "./data/chunks"
  strategy:
    small_files: "blob"        # <100MB use Blossom directly
    large_files: "torrent"     # >=100MB use chunking

# External Blossom servers (currently not implemented - using local storage only)
# blossom:
#   servers:
#     - "https://cdn.sovbit.host"

# BitTorrent configuration
torrent:
  trackers:
    - "udp://tracker.opentrackr.org:1337"
    - "udp://tracker.openbittorrent.com:6969"

# Built-in BitTorrent tracker configuration
tracker:
  enabled: true
  announce_interval: 1800      # 30 minutes
  min_interval: 900            # 15 minutes  
  default_numwant: 50          # peers to return
  max_numwant: 100             # maximum peers
  cleanup_interval: 300s       # cleanup every 5 minutes
  peer_timeout: 2700s          # 45 minutes

# Nostr relay configuration  
nostr:
  relays:
    - "wss://freelay.sovbit.host"
  publish_nip35: true          # Publish NIP-35 torrent events for DTAN compatibility
  publish_nip71: true          # Publish NIP-71 video events for social clients
  video_relays:                # Specific relays for video content (optional)
    - "wss://relay.damus.io"
    - "wss://nos.lol"
    - "wss://relay.nostr.band"
  private_key: ""              # Hex-encoded private key (leave empty to auto-generate)
  auto_publish: true           # Auto-publish video files on upload
  thumbnails_dir: "data/thumbnails"  # Directory for video thumbnails

# Video transcoding configuration
transcoding:
  enabled: true                # Enable/disable transcoding (requires ffmpeg)
  concurrent_jobs: 2           # Number of parallel transcoding jobs
  work_dir: "./data/transcoded"  # Directory for transcoded files
  
  # When to transcode
  auto_transcode: true         # Automatically transcode uploaded videos
  min_file_size: 50MB          # Don't transcode files smaller than this
  
  # Output settings
  qualities:
    - name: "1080p"
      width: 1920
      height: 1080
      bitrate: "5000k"
    - name: "720p"  
      width: 1280
      height: 720
      bitrate: "2500k"
    - name: "480p"
      width: 854
      height: 480
      bitrate: "1000k"
  
  # Storage management
  retention:
    transcoded_files: "30d"    # Delete transcoded files after this time if not accessed
    failed_jobs: "7d"          # Clean up failed job records after this time
  
  # Resource limits
  max_cpu_percent: 80          # Limit CPU usage (not implemented yet)
  nice_level: 10               # Process priority (lower = higher priority)

# Smart proxy configuration
proxy:
  enabled: true
  cache_size: 100              # Maximum number of cached reassembled files
  cache_max_age: 1h            # Maximum age for cached files

# Admin configuration
admin:
  enabled: true
  pubkeys:
    - "44dc1c2db9c3fbd7bee9257eceb52be3cf8c40baf7b63f46e56b58a131c74f0b"  # Replace with actual admin pubkey
  auto_cleanup: true
  cleanup_age: "90d"
  max_file_age: "365d"
  report_threshold: 3
  default_user_storage_limit: "10GB"  # Default storage limit per user

# Rate limiting configuration - tune these values based on your server capacity
rate_limiting:
  upload:
    requests_per_second: 1.0    # Max uploads per second per IP address
    burst_size: 5               # Allow burst of 5 uploads
    max_file_size: "3GB"      # Maximum individual file size
  download:
    requests_per_second: 50.0   # Global download rate limit (all users combined)
    burst_size: 100             # Global download burst allowance
  stream:
    requests_per_second: 10.0   # Max streaming requests per second per file
    burst_size: 20              # Stream burst allowance per file
    max_concurrent: 50          # Maximum concurrent streaming connections
  auth:
    login_attempts_per_minute: 10  # Login attempts per IP per minute
    burst_size: 5                  # Login burst allowance per IP

# Site branding configuration
branding:
  site_name: "Sovbit Gateway"           # Site name shown in headers/titles
  logo_url: "https://files.sovbit.host/media/44dc1c2db9c3fbd7bee9257eceb52be3cf8c40baf7b63f46e56b58a131c74f0b/7c96148e8244bfdb0294f44824267b6b08f2dcc29db8c6571d88ab8e22a1abf1.webp"                              # URL to your logo image (optional)
  logo_width: "auto"                        # Logo width (e.g., "150px", "auto")
  logo_height: "32px"                       # Logo height (e.g., "32px", "auto")  
  favicon_url: ""                           # URL to your favicon (optional)
  description: "Decentralized file sharing gateway"  # Site description
  footer_text: ""                           # Footer text (optional)
  support_url: ""                           # Support/contact URL (optional)

# Example sovbit.host configuration:
# branding:
#   site_name: "sovbit.host"
#   logo_url: "https://sovbit.host/logo.png"
#   logo_width: "120px"
#   logo_height: "30px"
#   favicon_url: "https://sovbit.host/favicon.ico"
#   description: "Sovereign Bitcoin hosting services"
#   footer_text: "Powered by sovbit.host"
#   support_url: "https://sovbit.host/support"
