fix(controller): include session ID in analysis error log

style(log): use octal notation for file permissions
This commit is contained in:
2026-01-11 04:00:52 +08:00
parent ac5bdad507
commit 4eb4b202c5
3 changed files with 6 additions and 3 deletions

View File

@@ -224,6 +224,7 @@ func runClientWithToken(token string, unsafeFeatures *security.UnsafeFeatures) e
}
// Fetch config from API
// #nosec G107 -- URL is constructed from trusted source (environment variable or hardcoded)
url := fmt.Sprintf("%s/api/v1/tunnel/frpc/config/%s", apiServer, token)
resp, err := http.Get(url)
if err != nil {

View File

@@ -220,7 +220,7 @@ func (c *Controller) HandleVisitor(m *msg.NatHoleVisitor, transporter transport.
// Make hole-punching decisions based on the NAT information of the client and visitor.
vResp, cResp, err := c.analysis(session)
if err != nil {
log.Debugf("sid [%s] analysis error: %v", err)
log.Debugf("sid [%s] analysis error: %v", sid, err)
vResp = c.GenNatHoleResponse(session.visitorMsg.TransactionID, nil, err.Error())
cResp = c.GenNatHoleResponse(session.clientMsg.TransactionID, nil, err.Error())
}

View File

@@ -111,7 +111,7 @@ type RotateFileWriter struct {
func (w *RotateFileWriter) openFile() error {
var err error
w.file, err = os.OpenFile(w.filePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
w.file, err = os.OpenFile(w.filePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o644)
return err
}
@@ -129,7 +129,9 @@ func (w *RotateFileWriter) checkRotate() error {
oldPath := w.filePath
newPath := w.filePath + "." + w.currentDate
if _, err := os.Stat(oldPath); err == nil {
os.Rename(oldPath, newPath)
if err := os.Rename(oldPath, newPath); err != nil {
return err
}
}
// Clean up old log files