Feat: remote test ping and ping-back

This commit is contained in:
HFO4
2020-02-27 11:17:59 +08:00
parent f1ef21e195
commit bd643fa2d5
9 changed files with 129 additions and 8 deletions

View File

@@ -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}

View File

@@ -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"

View File

@@ -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
}
}
// 验证文件名

View File

@@ -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)
}