mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: remote test ping and ping-back
This commit is contained in:
@@ -22,7 +22,7 @@ type system struct {
|
||||
Listen string `validate:"required"`
|
||||
Debug bool
|
||||
SessionSecret string
|
||||
HashIDSalt string `validate:"required"`
|
||||
HashIDSalt string
|
||||
}
|
||||
|
||||
// slave 作为slave存储端配置
|
||||
@@ -72,8 +72,7 @@ type cors struct {
|
||||
|
||||
var cfg *ini.File
|
||||
|
||||
const defaultConf = `
|
||||
[System]
|
||||
const defaultConf = `[System]
|
||||
Mode = master
|
||||
Listen = :5212
|
||||
SessionSecret = {SessionSecret}
|
||||
|
||||
@@ -215,6 +215,15 @@ func (handler Driver) Source(
|
||||
return "", errors.New("无法解析远程服务端地址")
|
||||
}
|
||||
|
||||
// 是否启用了CDN
|
||||
if handler.Policy.BaseURL != "" {
|
||||
cdnURL, err := url.Parse(handler.Policy.BaseURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
serverURL = cdnURL
|
||||
}
|
||||
|
||||
var (
|
||||
signedURI *url.URL
|
||||
controller = "/api/v3/slave/download"
|
||||
|
||||
@@ -67,8 +67,10 @@ func HookSlaveUploadValidate(ctx context.Context, fs *FileSystem) error {
|
||||
policy := ctx.Value(fsctx.UploadPolicyCtx).(serializer.UploadPolicy)
|
||||
|
||||
// 验证单文件尺寸
|
||||
if file.GetSize() > policy.MaxSize {
|
||||
return ErrFileSizeTooBig
|
||||
if policy.MaxSize > 0 {
|
||||
if file.GetSize() > policy.MaxSize {
|
||||
return ErrFileSizeTooBig
|
||||
}
|
||||
}
|
||||
|
||||
// 验证文件名
|
||||
|
||||
@@ -34,7 +34,7 @@ func (fs *FileSystem) GetThumb(ctx context.Context, id uint) (*response.ContentR
|
||||
ctx = context.WithValue(ctx, fsctx.ThumbSizeCtx, [2]uint{w, h})
|
||||
ctx = context.WithValue(ctx, fsctx.FileModelCtx, fs.FileTarget[0])
|
||||
res, err := fs.Handler.Thumb(ctx, fs.FileTarget[0].SourceName)
|
||||
if err == nil {
|
||||
if err == nil && conf.SystemConfig.Mode == "master" {
|
||||
res.MaxAge = model.GetIntSetting("preview_timeout", 60)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user