mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 17:56:37 +08:00
[优化] 增强流量可观测性,添加请求长度和字节发送字段;更新支持文件权限设置
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -529,7 +530,7 @@ func (m *Manager) restore(state *backupState) error {
|
||||
if err := os.MkdirAll(filepath.Dir(targetPath), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(targetPath, []byte(file.Content), 0o600); err != nil {
|
||||
if err := os.WriteFile(targetPath, []byte(file.Content), supportFileMode(file.Path)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -554,7 +555,7 @@ func (m *Manager) writeSupportFiles(supportFiles []protocol.SupportFile) error {
|
||||
if err := os.MkdirAll(filepath.Dir(targetPath), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(targetPath, []byte(file.Content), 0o600); err != nil {
|
||||
if err := os.WriteFile(targetPath, []byte(file.Content), supportFileMode(file.Path)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -628,6 +629,17 @@ func (m *Manager) supportFileTargetPath(relativePath string) (string, error) {
|
||||
return targetPath, nil
|
||||
}
|
||||
|
||||
func supportFileMode(relativePath string) fs.FileMode {
|
||||
switch strings.ToLower(filepath.Ext(strings.TrimSpace(relativePath))) {
|
||||
case ".lua", ".crt", ".pem":
|
||||
return 0o644
|
||||
case ".key":
|
||||
return 0o600
|
||||
default:
|
||||
return 0o644
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) renderRouteConfig(content string) string {
|
||||
if m.NginxSupportDir == "" {
|
||||
return content
|
||||
|
||||
Reference in New Issue
Block a user