mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Fix: concurrent logging lock / Feat: listen SSL (#287)
This commit is contained in:
@@ -27,6 +27,12 @@ type system struct {
|
||||
HashIDSalt string
|
||||
}
|
||||
|
||||
type ssl struct {
|
||||
CertPath string `validate:"omitempty,required"`
|
||||
KeyPath string `validate:"omitempty,required"`
|
||||
Listen string `validate:"required"`
|
||||
}
|
||||
|
||||
// slave 作为slave存储端配置
|
||||
type slave struct {
|
||||
Secret string `validate:"omitempty,gte=64"`
|
||||
@@ -113,6 +119,7 @@ func Init(path string) {
|
||||
sections := map[string]interface{}{
|
||||
"Database": DatabaseConfig,
|
||||
"System": SystemConfig,
|
||||
"SSL": SSLConfig,
|
||||
"Captcha": CaptchaConfig,
|
||||
"Redis": RedisConfig,
|
||||
"Thumbnail": ThumbConfig,
|
||||
|
||||
@@ -59,3 +59,9 @@ var SlaveConfig = &slave{
|
||||
CallbackTimeout: 20,
|
||||
SignatureTTL: 60,
|
||||
}
|
||||
|
||||
var SSLConfig = &ssl{
|
||||
Listen: ":443",
|
||||
CertPath: "",
|
||||
KeyPath: "",
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package util
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fatih/color"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -23,6 +24,7 @@ var Level = LevelDebug
|
||||
// Logger 日志
|
||||
type Logger struct {
|
||||
level int
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// 日志颜色
|
||||
@@ -49,6 +51,10 @@ func (ll *Logger) Println(prefix string, msg string) {
|
||||
// color.NoColor = false
|
||||
|
||||
c := color.New()
|
||||
|
||||
ll.mu.Lock()
|
||||
defer ll.mu.Unlock()
|
||||
|
||||
_, _ = c.Printf(
|
||||
"%s%s %s %s\n",
|
||||
colors[prefix]("["+prefix+"]"),
|
||||
|
||||
Reference in New Issue
Block a user