2022-06-06 21:48:53 +08:00
|
|
|
package conf
|
|
|
|
|
|
2022-06-25 21:34:44 +08:00
|
|
|
import (
|
2024-03-24 15:16:00 +08:00
|
|
|
"path/filepath"
|
|
|
|
|
|
2022-11-01 19:14:49 +08:00
|
|
|
"github.com/alist-org/alist/v3/cmd/flags"
|
2022-06-25 21:34:44 +08:00
|
|
|
"github.com/alist-org/alist/v3/pkg/utils/random"
|
|
|
|
|
)
|
|
|
|
|
|
2022-06-06 21:48:53 +08:00
|
|
|
type Database struct {
|
2023-11-21 15:51:08 +08:00
|
|
|
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"`
|
2024-02-23 15:28:48 +08:00
|
|
|
DSN string `json:"dsn" env:"DSN"`
|
2022-06-06 21:48:53 +08:00
|
|
|
}
|
|
|
|
|
|
2024-02-23 15:37:40 +08:00
|
|
|
type Meilisearch struct {
|
|
|
|
|
Host string `json:"host" env:"HOST"`
|
|
|
|
|
APIKey string `json:"api_key" env:"API_KEY"`
|
|
|
|
|
IndexPrefix string `json:"index_prefix" env:"INDEX_PREFIX"`
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-06 21:48:53 +08:00
|
|
|
type Scheme struct {
|
2023-07-08 20:17:05 +08:00
|
|
|
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"`
|
2025-04-12 17:02:51 +08:00
|
|
|
EnableH2c bool `json:"enable_h2c" env:"ENABLE_H2C"`
|
2022-06-06 21:48:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type LogConfig struct {
|
2022-09-25 17:41:04 +08:00
|
|
|
Enable bool `json:"enable" env:"LOG_ENABLE"`
|
2022-08-30 15:22:54 +08:00
|
|
|
Name string `json:"name" env:"LOG_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"`
|
2022-06-06 21:48:53 +08:00
|
|
|
}
|
|
|
|
|
|
2023-11-21 15:51:08 +08:00
|
|
|
type TaskConfig struct {
|
2024-08-07 12:16:21 +08:00
|
|
|
Workers int `json:"workers" env:"WORKERS"`
|
|
|
|
|
MaxRetry int `json:"max_retry" env:"MAX_RETRY"`
|
|
|
|
|
TaskPersistant bool `json:"task_persistant" env:"TASK_PERSISTANT"`
|
2023-11-21 15:51:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type TasksConfig struct {
|
2025-01-27 20:18:10 +08:00
|
|
|
Download TaskConfig `json:"download" envPrefix:"DOWNLOAD_"`
|
|
|
|
|
Transfer TaskConfig `json:"transfer" envPrefix:"TRANSFER_"`
|
|
|
|
|
Upload TaskConfig `json:"upload" envPrefix:"UPLOAD_"`
|
|
|
|
|
Copy TaskConfig `json:"copy" envPrefix:"COPY_"`
|
|
|
|
|
Decompress TaskConfig `json:"decompress" envPrefix:"DECOMPRESS_"`
|
|
|
|
|
DecompressUpload TaskConfig `json:"decompress_upload" envPrefix:"DECOMPRESS_UPLOAD_"`
|
feat(driver/s3): Add OSS Archive Support (#9350)
* feat(s3): Add support for S3 object storage classes
Introduces a new 'storage_class' configuration option for S3 providers. Users can now specify the desired storage class (e.g., Standard, GLACIER, DEEP_ARCHIVE) for objects uploaded to S3-compatible services like AWS S3 and Tencent COS.
The input storage class string is normalized to match AWS SDK constants, supporting various common aliases. If an unknown storage class is provided, it will be used as a raw value with a warning. This enhancement provides greater control over storage costs and data access patterns.
* feat(storage): Support for displaying file storage classes
Adds storage class information to file metadata and API responses.
This change introduces the ability to store file storage classes in file metadata and display them in API responses. This allows users to view a file's storage tier (e.g., S3 Standard, Glacier), enhancing data management capabilities.
Implementation details include:
- Introducing the StorageClassProvider interface and the ObjWrapStorageClass structure to uniformly handle and communicate object storage class information.
- Updated file metadata structures (e.g., ArchiveObj, FileInfo, RespFile) to include a StorageClass field.
- Modified relevant API response functions (e.g., GetFileInfo, GetFileList) to populate and return storage classes.
- Integrated functionality for retrieving object storage classes from underlying storage systems (e.g., S3) and wrapping them in lists.
* feat(driver/s3): Added the "Other" interface and implemented it by the S3 driver.
A new `driver.Other` interface has been added and defined in the `other.go` file.
The S3 driver has been updated to implement this new interface, extending its functionality.
* feat(s3): Add S3 object archive and thaw task management
This commit introduces comprehensive support for S3 object archive and thaw operations, managed asynchronously through a new task system.
- **S3 Transition Task System**:
- Adds a new `S3Transition` task configuration, including workers, max retries, and persistence options.
- Initializes `S3TransitionTaskManager` to handle asynchronous S3 archive/thaw requests.
- Registers dedicated API routes for monitoring S3 transition tasks.
- **Integrate S3 Archive/Thaw with Other API**:
- Modifies the `Other` API handler to intercept `archive` and `thaw` methods for S3 storage drivers.
- Dispatches these operations as `S3TransitionTask` instances to the task manager for background processing.
- Returns a task ID to the client for tracking the status of the dispatched operation.
- **Refactor `other` package for improved API consistency**:
- Exports previously internal structs such as `archiveRequest`, `thawRequest`, `objectDescriptor`, `archiveResponse`, `thawResponse`, and `restoreStatus` by making their names public.
- Makes helper functions like `decodeOtherArgs`, `normalizeStorageClass`, and `normalizeRestoreTier` public.
- Introduces new constants for various S3 `Other` API methods.
2025-10-16 02:22:54 -07:00
|
|
|
S3Transition TaskConfig `json:"s3_transition" envPrefix:"S3_TRANSITION_"`
|
2025-01-27 20:18:10 +08:00
|
|
|
AllowRetryCanceled bool `json:"allow_retry_canceled" env:"ALLOW_RETRY_CANCELED"`
|
2023-11-21 15:51:08 +08:00
|
|
|
}
|
|
|
|
|
|
2023-11-24 19:17:37 +08:00
|
|
|
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"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-24 15:16:00 +08:00
|
|
|
type S3 struct {
|
|
|
|
|
Enable bool `json:"enable" env:"ENABLE"`
|
|
|
|
|
Port int `json:"port" env:"PORT"`
|
|
|
|
|
SSL bool `json:"ssl" env:"SSL"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-10 20:17:46 +08:00
|
|
|
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"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-12 20:51:43 +08:00
|
|
|
type SFTP struct {
|
|
|
|
|
Enable bool `json:"enable" env:"ENABLE"`
|
|
|
|
|
Listen string `json:"listen" env:"LISTEN"`
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-06 21:48:53 +08:00
|
|
|
type Config struct {
|
2023-11-21 15:51:08 +08:00
|
|
|
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_"`
|
2024-04-08 18:35:23 +08:00
|
|
|
Meilisearch Meilisearch `json:"meilisearch" envPrefix:"MEILISEARCH_"`
|
2023-11-21 15:51:08 +08:00
|
|
|
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"`
|
|
|
|
|
DelayedStart int `json:"delayed_start" env:"DELAYED_START"`
|
|
|
|
|
MaxConnections int `json:"max_connections" env:"MAX_CONNECTIONS"`
|
2025-01-27 20:08:39 +08:00
|
|
|
MaxConcurrency int `json:"max_concurrency" env:"MAX_CONCURRENCY"`
|
2023-11-21 15:51:08 +08:00
|
|
|
TlsInsecureSkipVerify bool `json:"tls_insecure_skip_verify" env:"TLS_INSECURE_SKIP_VERIFY"`
|
|
|
|
|
Tasks TasksConfig `json:"tasks" envPrefix:"TASKS_"`
|
2023-11-24 19:17:37 +08:00
|
|
|
Cors Cors `json:"cors" envPrefix:"CORS_"`
|
2024-03-24 15:16:00 +08:00
|
|
|
S3 S3 `json:"s3" envPrefix:"S3_"`
|
2024-12-10 20:17:46 +08:00
|
|
|
FTP FTP `json:"ftp" envPrefix:"FTP_"`
|
2024-12-12 20:51:43 +08:00
|
|
|
SFTP SFTP `json:"sftp" envPrefix:"SFTP_"`
|
2024-12-30 22:48:33 +08:00
|
|
|
LastLaunchedVersion string `json:"last_launched_version"`
|
2022-06-06 21:48:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func DefaultConfig() *Config {
|
2022-11-01 19:14:49 +08:00
|
|
|
tempDir := filepath.Join(flags.DataDir, "temp")
|
2022-11-28 13:45:25 +08:00
|
|
|
indexDir := filepath.Join(flags.DataDir, "bleve")
|
2022-11-01 19:14:49 +08:00
|
|
|
logPath := filepath.Join(flags.DataDir, "log/log.log")
|
|
|
|
|
dbPath := filepath.Join(flags.DataDir, "data.db")
|
2022-06-06 21:48:53 +08:00
|
|
|
return &Config{
|
2023-07-04 17:56:02 +08:00
|
|
|
Scheme: Scheme{
|
|
|
|
|
Address: "0.0.0.0",
|
|
|
|
|
UnixFile: "",
|
|
|
|
|
HttpPort: 5244,
|
|
|
|
|
HttpsPort: -1,
|
|
|
|
|
ForceHttps: false,
|
|
|
|
|
CertFile: "",
|
|
|
|
|
KeyFile: "",
|
|
|
|
|
},
|
2022-09-27 14:05:00 +08:00
|
|
|
JwtSecret: random.String(16),
|
|
|
|
|
TokenExpiresIn: 48,
|
2022-11-01 19:14:49 +08:00
|
|
|
TempDir: tempDir,
|
2022-06-06 21:48:53 +08:00
|
|
|
Database: Database{
|
|
|
|
|
Type: "sqlite3",
|
|
|
|
|
Port: 0,
|
|
|
|
|
TablePrefix: "x_",
|
2022-11-01 19:14:49 +08:00
|
|
|
DBFile: dbPath,
|
2022-06-06 21:48:53 +08:00
|
|
|
},
|
2024-02-23 15:37:40 +08:00
|
|
|
Meilisearch: Meilisearch{
|
|
|
|
|
Host: "http://localhost:7700",
|
|
|
|
|
},
|
2022-11-28 13:45:25 +08:00
|
|
|
BleveDir: indexDir,
|
2022-06-06 21:48:53 +08:00
|
|
|
Log: LogConfig{
|
2022-08-30 15:22:54 +08:00
|
|
|
Enable: true,
|
2022-11-01 19:14:49 +08:00
|
|
|
Name: logPath,
|
2023-08-08 20:37:40 +08:00
|
|
|
MaxSize: 50,
|
|
|
|
|
MaxBackups: 30,
|
2022-08-30 15:22:54 +08:00
|
|
|
MaxAge: 28,
|
2022-06-06 21:48:53 +08:00
|
|
|
},
|
2023-02-08 22:01:26 +08:00
|
|
|
MaxConnections: 0,
|
2025-01-27 20:08:39 +08:00
|
|
|
MaxConcurrency: 64,
|
2023-02-23 22:33:54 +08:00
|
|
|
TlsInsecureSkipVerify: true,
|
2023-11-21 15:51:08 +08:00
|
|
|
Tasks: TasksConfig{
|
|
|
|
|
Download: TaskConfig{
|
2024-11-08 22:07:35 +08:00
|
|
|
Workers: 5,
|
|
|
|
|
MaxRetry: 1,
|
|
|
|
|
// TaskPersistant: true,
|
2023-11-21 15:51:08 +08:00
|
|
|
},
|
|
|
|
|
Transfer: TaskConfig{
|
2024-11-08 22:07:35 +08:00
|
|
|
Workers: 5,
|
|
|
|
|
MaxRetry: 2,
|
|
|
|
|
// TaskPersistant: true,
|
2023-11-21 15:51:08 +08:00
|
|
|
},
|
|
|
|
|
Upload: TaskConfig{
|
|
|
|
|
Workers: 5,
|
|
|
|
|
},
|
|
|
|
|
Copy: TaskConfig{
|
2024-11-08 22:07:35 +08:00
|
|
|
Workers: 5,
|
|
|
|
|
MaxRetry: 2,
|
|
|
|
|
// TaskPersistant: true,
|
2023-11-21 15:51:08 +08:00
|
|
|
},
|
2025-01-18 23:28:12 +08:00
|
|
|
Decompress: TaskConfig{
|
|
|
|
|
Workers: 5,
|
|
|
|
|
MaxRetry: 2,
|
|
|
|
|
// TaskPersistant: true,
|
|
|
|
|
},
|
|
|
|
|
DecompressUpload: TaskConfig{
|
|
|
|
|
Workers: 5,
|
|
|
|
|
MaxRetry: 2,
|
|
|
|
|
},
|
feat(driver/s3): Add OSS Archive Support (#9350)
* feat(s3): Add support for S3 object storage classes
Introduces a new 'storage_class' configuration option for S3 providers. Users can now specify the desired storage class (e.g., Standard, GLACIER, DEEP_ARCHIVE) for objects uploaded to S3-compatible services like AWS S3 and Tencent COS.
The input storage class string is normalized to match AWS SDK constants, supporting various common aliases. If an unknown storage class is provided, it will be used as a raw value with a warning. This enhancement provides greater control over storage costs and data access patterns.
* feat(storage): Support for displaying file storage classes
Adds storage class information to file metadata and API responses.
This change introduces the ability to store file storage classes in file metadata and display them in API responses. This allows users to view a file's storage tier (e.g., S3 Standard, Glacier), enhancing data management capabilities.
Implementation details include:
- Introducing the StorageClassProvider interface and the ObjWrapStorageClass structure to uniformly handle and communicate object storage class information.
- Updated file metadata structures (e.g., ArchiveObj, FileInfo, RespFile) to include a StorageClass field.
- Modified relevant API response functions (e.g., GetFileInfo, GetFileList) to populate and return storage classes.
- Integrated functionality for retrieving object storage classes from underlying storage systems (e.g., S3) and wrapping them in lists.
* feat(driver/s3): Added the "Other" interface and implemented it by the S3 driver.
A new `driver.Other` interface has been added and defined in the `other.go` file.
The S3 driver has been updated to implement this new interface, extending its functionality.
* feat(s3): Add S3 object archive and thaw task management
This commit introduces comprehensive support for S3 object archive and thaw operations, managed asynchronously through a new task system.
- **S3 Transition Task System**:
- Adds a new `S3Transition` task configuration, including workers, max retries, and persistence options.
- Initializes `S3TransitionTaskManager` to handle asynchronous S3 archive/thaw requests.
- Registers dedicated API routes for monitoring S3 transition tasks.
- **Integrate S3 Archive/Thaw with Other API**:
- Modifies the `Other` API handler to intercept `archive` and `thaw` methods for S3 storage drivers.
- Dispatches these operations as `S3TransitionTask` instances to the task manager for background processing.
- Returns a task ID to the client for tracking the status of the dispatched operation.
- **Refactor `other` package for improved API consistency**:
- Exports previously internal structs such as `archiveRequest`, `thawRequest`, `objectDescriptor`, `archiveResponse`, `thawResponse`, and `restoreStatus` by making their names public.
- Makes helper functions like `decodeOtherArgs`, `normalizeStorageClass`, and `normalizeRestoreTier` public.
- Introduces new constants for various S3 `Other` API methods.
2025-10-16 02:22:54 -07:00
|
|
|
S3Transition: TaskConfig{
|
|
|
|
|
Workers: 5,
|
|
|
|
|
MaxRetry: 2,
|
|
|
|
|
// TaskPersistant: true,
|
|
|
|
|
},
|
2025-01-27 20:18:10 +08:00
|
|
|
AllowRetryCanceled: false,
|
2023-11-21 15:51:08 +08:00
|
|
|
},
|
2023-11-24 19:17:37 +08:00
|
|
|
Cors: Cors{
|
|
|
|
|
AllowOrigins: []string{"*"},
|
|
|
|
|
AllowMethods: []string{"*"},
|
|
|
|
|
AllowHeaders: []string{"*"},
|
|
|
|
|
},
|
2024-03-24 15:16:00 +08:00
|
|
|
S3: S3{
|
|
|
|
|
Enable: false,
|
|
|
|
|
Port: 5246,
|
|
|
|
|
SSL: false,
|
|
|
|
|
},
|
2024-12-10 20:17:46 +08:00
|
|
|
FTP: FTP{
|
2024-12-12 21:04:14 +08:00
|
|
|
Enable: false,
|
2024-12-10 20:17:46 +08:00
|
|
|
Listen: ":5221",
|
|
|
|
|
FindPasvPortAttempts: 50,
|
|
|
|
|
ActiveTransferPortNon20: false,
|
|
|
|
|
IdleTimeout: 900,
|
|
|
|
|
ConnectionTimeout: 30,
|
|
|
|
|
DisableActiveMode: false,
|
|
|
|
|
DefaultTransferBinary: false,
|
|
|
|
|
EnableActiveConnIPCheck: true,
|
|
|
|
|
EnablePasvConnIPCheck: true,
|
|
|
|
|
},
|
2024-12-12 20:51:43 +08:00
|
|
|
SFTP: SFTP{
|
2024-12-12 21:04:14 +08:00
|
|
|
Enable: false,
|
2024-12-12 20:51:43 +08:00
|
|
|
Listen: ":5222",
|
|
|
|
|
},
|
2024-12-30 22:48:33 +08:00
|
|
|
LastLaunchedVersion: "",
|
2022-06-06 21:48:53 +08:00
|
|
|
}
|
|
|
|
|
}
|