Merge remote-tracking branch 'origin/master'

pull/1324/head
HFO4 3 years ago
commit 21d2b817f4

@ -5,6 +5,7 @@ import (
"flag" "flag"
"io" "io"
"io/fs" "io/fs"
"os"
"strings" "strings"
"github.com/cloudreve/Cloudreve/v3/bootstrap" "github.com/cloudreve/Cloudreve/v3/bootstrap"
@ -67,6 +68,15 @@ func main() {
// 如果启用了Unix // 如果启用了Unix
if conf.UnixConfig.Listen != "" { if conf.UnixConfig.Listen != "" {
// delete socket file before listening
if _, err := os.Stat(conf.UnixConfig.Listen); err == nil {
if err = os.Remove(conf.UnixConfig.Listen); err != nil {
util.Log().Error("删除 socket 文件错误, %s", err)
return
}
}
api.TrustedPlatform = conf.UnixConfig.ProxyHeader
util.Log().Info("开始监听 %s", conf.UnixConfig.Listen) util.Log().Info("开始监听 %s", conf.UnixConfig.Listen)
if err := api.RunUnix(conf.UnixConfig.Listen); err != nil { if err := api.RunUnix(conf.UnixConfig.Listen); err != nil {
util.Log().Error("无法监听[%s]%s", conf.UnixConfig.Listen, err) util.Log().Error("无法监听[%s]%s", conf.UnixConfig.Listen, err)

@ -35,7 +35,8 @@ type ssl struct {
} }
type unix struct { type unix struct {
Listen string Listen string
ProxyHeader string `validate:"required_with=Listen"`
} }
// slave 作为slave存储端配置 // slave 作为slave存储端配置

@ -45,7 +45,8 @@ var SSLConfig = &ssl{
} }
var UnixConfig = &unix{ var UnixConfig = &unix{
Listen: "", Listen: "",
ProxyHeader: "X-Forwarded-For",
} }
var OptionOverwrite = map[string]interface{}{} var OptionOverwrite = map[string]interface{}{}

@ -10,7 +10,9 @@ import (
"encoding/xml" "encoding/xml"
"errors" "errors"
"fmt" "fmt"
"mime"
"net/http" "net/http"
"path/filepath"
"strconv" "strconv"
"time" "time"
@ -381,7 +383,7 @@ func findContentType(ctx context.Context, fs *filesystem.FileSystem, ls LockSyst
//// Rewind file. //// Rewind file.
//_, err = f.Seek(0, os.SEEK_SET) //_, err = f.Seek(0, os.SEEK_SET)
//return ctype, err //return ctype, err
return "", nil return mime.TypeByExtension(filepath.Ext(name)), nil
} }
// ETager is an optional interface for the os.FileInfo objects // ETager is an optional interface for the os.FileInfo objects

Loading…
Cancel
Save