config

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Public  Public
	Private Private
}

func MustLoad

func MustLoad(configFolder string) *Config

func (*Config) JwtKey

func (s *Config) JwtKey() string

func (*Config) JwtTTL

func (s *Config) JwtTTL() time.Duration

type Email

type Email struct {
	SMTPServer string `yaml:"smtp_server" validate:"required"`
	SMTPPort   int    `yaml:"smtp_port" validate:"required"`
	Username   string `yaml:"username" validate:"required"`
	Password   string `yaml:"password" validate:"required"`
	SenderName string `yaml:"sender_name" validate:"required"`
	Timeout    int    `yaml:"timeout"`
}

type MediaConfig

type MediaConfig struct {
	ThumbnailMaxSize      int `yaml:"thumbnail_max_size"`      // Max dimension (px) for generated thumbnails (backend)
	ThumbnailDisplayOp    int `yaml:"thumbnail_display_op"`    // Display size (px) for OP post thumbnails (frontend)
	ThumbnailDisplayReply int `yaml:"thumbnail_display_reply"` // Display size (px) for reply post thumbnails (frontend)
	JpegQualityMain       int `yaml:"jpeg_quality_main"`       // JPEG quality for main images (0-100)
	JpegQualityThumbnail  int `yaml:"jpeg_quality_thumbnail"`  // JPEG quality for thumbnails (0-100)
}

type Pg

type Pg struct {
	Host     string `yaml:"host" validate:"required"`
	Port     int    `yaml:"port" validate:"required"`
	User     string `yaml:"user" validate:"required"`
	Password string `yaml:"password" validate:"required"`
	Dbname   string `yaml:"dbname" validate:"required"`
}

type Private

type Private struct {
	Pg            Pg       `yaml:"pg"`
	Email         Email    `yaml:"email"`
	JwtKey        string   `yaml:"jwt_key" validate:"required"`
	EncryptionKey string   `yaml:"encryption_key" validate:"required"`
	AllowedRefs   []string `yaml:"allowed_refs"` // Allowlist of ref= param values to track; empty = allow all
}

type Public

type Public struct {
	JwtTTL                      time.Duration `yaml:"jwt_ttl" validate:"required"`
	ConfirmationCodeTTL         time.Duration `yaml:"confirmation_code_ttl"` // Time until confirmation code expires
	ThreadsPerPage              int           `yaml:"threads_per_page" validate:"required"`
	MessagesPerThreadPage       int           `yaml:"messages_per_thread_page"` // number of messages per thread page (0 = all)
	MaxThreadCount              *int          `yaml:"max_thread_count"`
	NLastMsg                    int           `yaml:"n_last_msg" validate:"required"` // number of last messages shown in board preview (materialized view)
	BumpLimit                   int           `yaml:"bump_limit" validate:"required"` // if thread have more messages it will not get "bumped"
	BoardPreviewRefreshInterval time.Duration `yaml:"board_preview_refresh_internval" validate:"required"`
	BoardActivityWindow         time.Duration `yaml:"board_activity_window"`                        // How far back to check for board activity (should be > refresh interval)
	BlacklistCacheInterval      int           `yaml:"blacklist_cache_interval" validate:"required"` // Interval in seconds to refresh blacklist cache

	// Security settings
	SecureCookies bool `yaml:"secure_cookies"` // Enable Secure flag on cookies (requires HTTPS)
	CSRFEnabled   bool `yaml:"csrf_enabled"`   // Enable CSRF protection (default: true)

	// Logging settings
	LogLevel  string `yaml:"log_level"`  // Log level: debug, info, warn, error (default: info)
	LogFormat string `yaml:"log_format"` // Log format: text or json (default: text)

	// Validation constants (optional; sensible defaults are used when zero)
	BoardNameMaxLen      int `yaml:"board_name_max_len"`
	BoardShortNameMaxLen int `yaml:"board_short_name_max_len"`
	ThreadTitleMaxLen    int `yaml:"thread_title_max_len"`
	MessageTextMaxLen    int `yaml:"message_text_max_len"`
	MessageTextMinLen    int `yaml:"message_text_min_len"`
	ConfirmationCodeLen  int `yaml:"confirmation_code_len"`
	PasswordMinLen       int `yaml:"password_min_len"`

	// Attachment validation constants (optional; sensible defaults are used when zero)
	MaxAttachmentsPerMessage int      `yaml:"max_attachments_per_message"`
	MaxAttachmentSizeBytes   int64    `yaml:"max_attachment_size_bytes"`
	MaxTotalAttachmentSize   int64    `yaml:"max_total_attachment_size"`
	MaxDecodedImageSize      int64    `yaml:"max_decoded_image_size"` // Max decoded pixel buffer size in bytes (prevents image bomb OOM)
	AllowedImageMimeTypes    []string `yaml:"allowed_image_mime_types"`
	AllowedVideoMimeTypes    []string `yaml:"allowed_video_mime_types"`

	// Invite system configuration
	InviteEnabled           bool          `yaml:"invite_enabled"`
	InviteCodeLength        int           `yaml:"invite_code_length"`
	InviteCodeTTL           time.Duration `yaml:"invite_code_ttl"`
	MaxInvitesPerUser       int           `yaml:"max_invites_per_user"`
	MinAccountAgeForInvites time.Duration `yaml:"min_account_age_for_invites"`

	// User activity page settings
	UserMessagesPageLimit int `yaml:"user_messages_page_limit"` // Number of messages/replies shown on account page

	// Pagination limits
	BlacklistPageLimit int `yaml:"blacklist_page_limit"` // Number of blacklisted users per page on admin panel
	InvitesPageLimit   int `yaml:"invites_page_limit"`   // Number of invite codes per page on invites page

	// Message processing settings
	MaxRepliesPerMessage int `yaml:"max_replies_per_message"` // Maximum number of >>thread#msg reply links per message

	// Static file caching
	StaticCacheMaxAge time.Duration `yaml:"static_cache_max_age"` // Cache duration for static files (CSS, JS, images)
	MediaCacheMaxAge  time.Duration `yaml:"media_cache_max_age"`  // Cache duration for user-uploaded media files

	// Registration restrictions
	AllowedRegistrationDomains []string `yaml:"allowed_registration_domains"` // Empty = allow all domains. Example: ["gmail.com", "company.com"]

	// Media processing settings
	Media MediaConfig `yaml:"media"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL