conf

package
v4.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeString = "string"
	TypeSelect = "select"
	TypeBool   = "bool"
	TypeText   = "text"
	TypeNumber = "number"
)
View Source
const (
	// site
	VERSION      = "version"
	SiteTitle    = "site_title"
	Announcement = "announcement"
	AllowIndexed = "allow_indexed"
	AllowMounted = "allow_mounted"
	RobotsTxt    = "robots_txt"

	Favicon                        = "favicon"
	MainColor                      = "main_color"
	HideStorageDetails             = "hide_storage_details"
	HideStorageDetailsInManagePage = "hide_storage_details_in_manage_page"

	// preview
	TextTypes                     = "text_types"
	AudioTypes                    = "audio_types"
	VideoTypes                    = "video_types"
	ImageTypes                    = "image_types"
	ProxyTypes                    = "proxy_types"
	ProxyIgnoreHeaders            = "proxy_ignore_headers"
	AudioAutoplay                 = "audio_autoplay"
	VideoAutoplay                 = "video_autoplay"
	PreviewDownloadByDefault      = "preview_download_by_default"
	PreviewArchivesByDefault      = "preview_archives_by_default"
	SharePreviewDownloadByDefault = "share_preview_download_by_default"
	SharePreviewArchivesByDefault = "share_preview_archives_by_default"
	ReadMeAutoRender              = "readme_autorender"
	FilterReadMeScripts           = "filter_readme_scripts"
	NonEFSZipEncoding             = "non_efs_zip_encoding"

	// global
	HideFiles               = "hide_files"
	CustomizeHead           = "customize_head"
	CustomizeBody           = "customize_body"
	LinkExpiration          = "link_expiration"
	SignAll                 = "sign_all"
	PrivacyRegs             = "privacy_regs"
	OcrApi                  = "ocr_api"
	FilenameCharMapping     = "filename_char_mapping"
	ForwardDirectLinkParams = "forward_direct_link_params"
	IgnoreDirectLinkParams  = "ignore_direct_link_params"
	WebauthnLoginEnabled    = "webauthn_login_enabled"
	SharePreview            = "share_preview"
	ShareArchivePreview     = "share_archive_preview"
	ShareForceProxy         = "share_force_proxy"
	ShareSummaryContent     = "share_summary_content"
	HandleHookAfterWriting  = "handle_hook_after_writing"
	HandleHookRateLimit     = "handle_hook_rate_limit"
	IgnoreSystemFiles       = "ignore_system_files"

	// index
	SearchIndex     = "search_index"
	AutoUpdateIndex = "auto_update_index"
	IgnorePaths     = "ignore_paths"
	MaxIndexDepth   = "max_index_depth"

	// aria2
	Aria2Uri    = "aria2_uri"
	Aria2Secret = "aria2_secret"

	// transmission
	TransmissionUri      = "transmission_uri"
	TransmissionSeedtime = "transmission_seedtime"

	// 115
	Pan115TempDir = "115_temp_dir"

	// 123
	Pan123TempDir = "123_temp_dir"

	// 115_open
	Pan115OpenTempDir = "115_open_temp_dir"

	// pikpak
	PikPakTempDir = "pikpak_temp_dir"

	// thunder
	ThunderTempDir = "thunder_temp_dir"

	// thunderx
	ThunderXTempDir = "thunderx_temp_dir"

	// thunder_browser
	ThunderBrowserTempDir = "thunder_browser_temp_dir"

	// guangyapan
	GuangYaPanTempDir = "guangyapan_temp_dir"

	// single
	Token         = "token"
	IndexProgress = "index_progress"

	// SSO
	SSOClientId          = "sso_client_id"
	SSOClientSecret      = "sso_client_secret"
	SSOLoginEnabled      = "sso_login_enabled"
	SSOLoginPlatform     = "sso_login_platform"
	SSOOIDCUsernameKey   = "sso_oidc_username_key"
	SSOOrganizationName  = "sso_organization_name"
	SSOApplicationName   = "sso_application_name"
	SSOEndpointName      = "sso_endpoint_name"
	SSOJwtPublicKey      = "sso_jwt_public_key"
	SSOExtraScopes       = "sso_extra_scopes"
	SSOAutoRegister      = "sso_auto_register"
	SSODefaultDir        = "sso_default_dir"
	SSODefaultPermission = "sso_default_permission"
	SSOCompatibilityMode = "sso_compatibility_mode"
	SSOPostMessageOrigin = "sso_postmessage_origin"

	// ldap
	LdapLoginEnabled      = "ldap_login_enabled"
	LdapServer            = "ldap_server"
	LdapSkipTlsVerify     = "ldap_skip_tls_verify"
	LdapManagerDN         = "ldap_manager_dn"
	LdapManagerPassword   = "ldap_manager_password"
	LdapUserSearchBase    = "ldap_user_search_base"
	LdapUserSearchFilter  = "ldap_user_search_filter"
	LdapDefaultPermission = "ldap_default_permission"
	LdapDefaultDir        = "ldap_default_dir"
	LdapLoginTips         = "ldap_login_tips"

	// s3
	S3Buckets         = "s3_buckets"
	S3AccessKeyId     = "s3_access_key_id"
	S3SecretAccessKey = "s3_secret_access_key"

	// qbittorrent
	QbittorrentUrl      = "qbittorrent_url"
	QbittorrentSeedtime = "qbittorrent_seedtime"

	// 123 open offline download
	Pan123OpenOfflineDownloadCallbackUrl = "123_open_callback_url"
	Pan123OpenTempDir                    = "123_open_temp_dir"

	// ftp
	FTPPublicHost            = "ftp_public_host"
	FTPPasvPortMap           = "ftp_pasv_port_map"
	FTPMandatoryTLS          = "ftp_mandatory_tls"
	FTPImplicitTLS           = "ftp_implicit_tls"
	FTPTLSPrivateKeyPath     = "ftp_tls_private_key_path"
	FTPTLSPublicCertPath     = "ftp_tls_public_cert_path"
	SFTPDisablePasswordLogin = "sftp_disable_password_login"

	// traffic
	TaskOfflineDownloadThreadsNum         = "offline_download_task_threads_num"
	TaskOfflineDownloadTransferThreadsNum = "offline_download_transfer_task_threads_num"
	TaskUploadThreadsNum                  = "upload_task_threads_num"
	TaskCopyThreadsNum                    = "copy_task_threads_num"
	TaskMoveThreadsNum                    = "move_task_threads_num"
	TaskDecompressDownloadThreadsNum      = "decompress_download_task_threads_num"
	TaskDecompressUploadThreadsNum        = "decompress_upload_task_threads_num"
	StreamMaxClientDownloadSpeed          = "max_client_download_speed"
	StreamMaxClientUploadSpeed            = "max_client_upload_speed"
	StreamMaxServerDownloadSpeed          = "max_server_download_speed"
	StreamMaxServerUploadSpeed            = "max_server_upload_speed"
	MultipartEnabled                      = "multipart_enabled"
	MultipartChunkSize                    = "multipart_chunk_size"
)
View Source
const (
	UNKNOWN = iota
	FOLDER
	// OFFICE
	VIDEO
	AUDIO
	TEXT
	IMAGE
)

Variables

View Source
var (
	BuiltAt    string = "unknown"
	GitAuthor  string = "unknown"
	GitCommit  string = "unknown"
	Version    string = "dev"
	WebVersion string = "rolling"
)
View Source
var (
	Conf       *Config
	URL        *url.URL
	ConfigPath string
)
View Source
var (
	// 在HybridCache中使用[]byte缓存数据流的限制,内存为Go自动管理,直到GC
	AutoMemoryLimit uint64 = 4 * 1024 * 1024
	// 最小空闲内存,当内存不足时,HybridCache会回退到文件缓存。
	// 如果为0,HybridCache会使用文件缓存,不占用内存。
	MinFreeMemory uint64 = 16 * 1024 * 1024
	// 限制HybridCache手动管理内存单次的扩容大小,超过该阈值将分多次扩容。
	// MinFreeMemory大于0时,也限制 Downloader 的PartSize
	MaxBlockLimit uint64 = 16 * 1024 * 1024
)
View Source
var (
	RawIndexHtml string
	ManageHtml   string
	IndexHtml    string
)
View Source
var FilenameCharMap = make(map[string]string)
View Source
var PrivacyReg []*regexp.Regexp
View Source
var SlicesMap = make(map[string][]string)
View Source
var (
	// StoragesLoaded loaded success if empty
	StoragesLoaded = false
)

Functions

func GetApiUrl added in v4.2.7

func GetApiUrl(ctx context.Context) string

func ResetStoragesLoadSignal added in v4.1.5

func ResetStoragesLoadSignal()

func SendStoragesLoadedSignal added in v4.1.5

func SendStoragesLoadedSignal()

func StoragesLoadSignal added in v4.1.5

func StoragesLoadSignal() <-chan struct{}

Types

type Config

type Config struct {
	Force                 bool        `json:"force" env:"FORCE"`
	SiteURL               string      `json:"site_url" env:"SITE_URL"`
	Cdn                   string      `json:"cdn" env:"CDN"`
	JwtSecret             string      `json:"jwt_secret" env:"JWT_SECRET"`
	TokenExpiresIn        int         `json:"token_expires_in" env:"TOKEN_EXPIRES_IN"`
	Database              Database    `json:"database" envPrefix:"DB_"`
	Meilisearch           Meilisearch `json:"meilisearch" envPrefix:"MEILISEARCH_"`
	Scheme                Scheme      `json:"scheme"`
	TempDir               string      `json:"temp_dir" env:"TEMP_DIR"`
	BleveDir              string      `json:"bleve_dir" env:"BLEVE_DIR"`
	DistDir               string      `json:"dist_dir"`
	Log                   LogConfig   `json:"log" envPrefix:"LOG_"`
	DelayedStart          int         `json:"delayed_start" env:"DELAYED_START"`
	AutoMemoryLimit       int         `json:"auto_memory_limit" env:"AUTO_MEMORY_LIMIT"`
	MinFreeMemory         int         `json:"min_free_memory" env:"MIN_FREE_MEMORY"`
	MaxBlockLimit         int         `json:"max_block_limit" env:"MAX_BLOCK_LIMIT"`
	MaxConnections        int         `json:"max_connections" env:"MAX_CONNECTIONS"`
	MaxConcurrency        int         `json:"max_concurrency" env:"MAX_CONCURRENCY"`
	TlsInsecureSkipVerify bool        `json:"tls_insecure_skip_verify" env:"TLS_INSECURE_SKIP_VERIFY"`
	Tasks                 TasksConfig `json:"tasks" envPrefix:"TASKS_"`
	Cors                  Cors        `json:"cors" envPrefix:"CORS_"`
	S3                    S3          `json:"s3" envPrefix:"S3_"`
	FTP                   FTP         `json:"ftp" envPrefix:"FTP_"`
	SFTP                  SFTP        `json:"sftp" envPrefix:"SFTP_"`
	MCP                   MCP         `json:"mcp" envPrefix:"MCP_"`
	LastLaunchedVersion   string      `json:"last_launched_version"`
	ProxyAddress          string      `json:"proxy_address" env:"PROXY_ADDRESS"`
}

func DefaultConfig

func DefaultConfig(dataDir string) *Config

type ContextKey added in v4.0.9

type ContextKey int8

ContextKey is the type of context keys.

const (
	NoTaskKey ContextKey
	ApiUrlKey
	UserKey
	MetaKey
	MetaPassKey
	ClientIPKey
	ProxyHeaderKey
	RequestHeaderKey
	UserAgentKey
	PathKey
	SharingIDKey
	SkipHookKey
	DirectUploadContentTypeKey
)

type Cors

type Cors struct {
	AllowOrigins []string `json:"allow_origins" env:"ALLOW_ORIGINS"`
	AllowMethods []string `json:"allow_methods" env:"ALLOW_METHODS"`
	AllowHeaders []string `json:"allow_headers" env:"ALLOW_HEADERS"`
}

type Database

type Database struct {
	Type        string `json:"type" env:"TYPE"`
	Host        string `json:"host" env:"HOST"`
	Port        int    `json:"port" env:"PORT"`
	User        string `json:"user" env:"USER"`
	Password    string `json:"password" env:"PASS"`
	Name        string `json:"name" env:"NAME"`
	DBFile      string `json:"db_file" env:"FILE"`
	TablePrefix string `json:"table_prefix" env:"TABLE_PREFIX"`
	SSLMode     string `json:"ssl_mode" env:"SSL_MODE"`
	DSN         string `json:"dsn" env:"DSN"`
}

type FTP

type FTP struct {
	Enable                  bool   `json:"enable" env:"ENABLE"`
	Listen                  string `json:"listen" env:"LISTEN"`
	FindPasvPortAttempts    int    `json:"find_pasv_port_attempts" env:"FIND_PASV_PORT_ATTEMPTS"`
	ActiveTransferPortNon20 bool   `json:"active_transfer_port_non_20" env:"ACTIVE_TRANSFER_PORT_NON_20"`
	IdleTimeout             int    `json:"idle_timeout" env:"IDLE_TIMEOUT"`
	ConnectionTimeout       int    `json:"connection_timeout" env:"CONNECTION_TIMEOUT"`
	DisableActiveMode       bool   `json:"disable_active_mode" env:"DISABLE_ACTIVE_MODE"`
	DefaultTransferBinary   bool   `json:"default_transfer_binary" env:"DEFAULT_TRANSFER_BINARY"`
	EnableActiveConnIPCheck bool   `json:"enable_active_conn_ip_check" env:"ENABLE_ACTIVE_CONN_IP_CHECK"`
	EnablePasvConnIPCheck   bool   `json:"enable_pasv_conn_ip_check" env:"ENABLE_PASV_CONN_IP_CHECK"`
}

type Filter added in v4.1.0

type Filter struct {
	CIDR   string `json:"cidr"`
	Path   string `json:"path"`
	Method string `json:"method"`
}

type LogConfig

type LogConfig struct {
	Enable     bool            `json:"enable" env:"ENABLE"`
	Name       string          `json:"name" env:"NAME"`
	MaxSize    int             `json:"max_size" env:"MAX_SIZE"`
	MaxBackups int             `json:"max_backups" env:"MAX_BACKUPS"`
	MaxAge     int             `json:"max_age" env:"MAX_AGE"`
	Compress   bool            `json:"compress" env:"COMPRESS"`
	Filter     LogFilterConfig `json:"filter" envPrefix:"FILTER_"`
}

type LogFilterConfig added in v4.0.9

type LogFilterConfig struct {
	Enable  bool     `json:"enable" env:"ENABLE"`
	Filters []Filter `json:"filters"`
}

type MCP added in v4.2.3

type MCP struct {
	Enable bool `json:"enable" env:"ENABLE"`
}

type Meilisearch

type Meilisearch struct {
	Host   string `json:"host" env:"HOST"`
	APIKey string `json:"api_key" env:"API_KEY"`
	Index  string `json:"index" env:"INDEX"`
}

type S3

type S3 struct {
	Enable       bool   `json:"enable" env:"ENABLE"`
	Port         int    `json:"port" env:"PORT"`
	SSL          bool   `json:"ssl" env:"SSL"`
	MultipartTTL string `json:"multipart_ttl" env:"MULTIPART_TTL"`
}

type SFTP

type SFTP struct {
	Enable bool   `json:"enable" env:"ENABLE"`
	Listen string `json:"listen" env:"LISTEN"`
}

type Scheme

type Scheme struct {
	Address      string `json:"address" env:"ADDR"`
	HttpPort     int    `json:"http_port" env:"HTTP_PORT"`
	HttpsPort    int    `json:"https_port" env:"HTTPS_PORT"`
	ForceHttps   bool   `json:"force_https" env:"FORCE_HTTPS"`
	CertFile     string `json:"cert_file" env:"CERT_FILE"`
	KeyFile      string `json:"key_file" env:"KEY_FILE"`
	UnixFile     string `json:"unix_file" env:"UNIX_FILE"`
	UnixFilePerm string `json:"unix_file_perm" env:"UNIX_FILE_PERM"`
	EnableH2c    bool   `json:"enable_h2c" env:"ENABLE_H2C"`
	EnableH3     bool   `json:"enable_h3" env:"ENABLE_H3"`
}

type TaskConfig

type TaskConfig struct {
	Workers        int  `json:"workers" env:"WORKERS"`
	MaxRetry       int  `json:"max_retry" env:"MAX_RETRY"`
	TaskPersistant bool `json:"task_persistant" env:"TASK_PERSISTANT"`
}

type TasksConfig

type TasksConfig struct {
	Download           TaskConfig `json:"download" envPrefix:"DOWNLOAD_"`
	Transfer           TaskConfig `json:"transfer" envPrefix:"TRANSFER_"`
	Upload             TaskConfig `json:"upload" envPrefix:"UPLOAD_"`
	Copy               TaskConfig `json:"copy" envPrefix:"COPY_"`
	Move               TaskConfig `json:"move" envPrefix:"MOVE_"`
	Decompress         TaskConfig `json:"decompress" envPrefix:"DECOMPRESS_"`
	DecompressUpload   TaskConfig `json:"decompress_upload" envPrefix:"DECOMPRESS_UPLOAD_"`
	AllowRetryCanceled bool       `json:"allow_retry_canceled" env:"ALLOW_RETRY_CANCELED"`
}

Jump to

Keyboard shortcuts

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