mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-16 08:10:58 +00:00
fix(logs): limit Xray log growth (#5840)
* Limit Xray log growth * Apply suggestion from @github-actions[bot] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestion from @github-actions[bot] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Mahyar Dana <dana.mahyar76@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -66,8 +66,7 @@ func GetIPLimitBannedPrevLogPath() string {
|
||||
return config.GetLogFolder() + "/3xipl-banned.prev.log"
|
||||
}
|
||||
|
||||
// GetAccessLogPath reads the Xray config and returns the access log file path.
|
||||
func GetAccessLogPath() (string, error) {
|
||||
func getLogPath(key string) (string, error) {
|
||||
config, err := os.ReadFile(GetConfigPath())
|
||||
if err != nil {
|
||||
logger.Warningf("Failed to read configuration file: %s", err)
|
||||
@@ -81,16 +80,25 @@ func GetAccessLogPath() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if jsonConfig["log"] != nil {
|
||||
jsonLog := jsonConfig["log"].(map[string]any)
|
||||
if jsonLog["access"] != nil {
|
||||
accessLogPath := jsonLog["access"].(string)
|
||||
return accessLogPath, nil
|
||||
if jsonLog, ok := jsonConfig["log"].(map[string]any); ok {
|
||||
if logPath, ok := jsonLog[key].(string); ok {
|
||||
return logPath, nil
|
||||
}
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
// GetAccessLogPath reads the Xray config and returns the access log file path.
|
||||
func GetAccessLogPath() (string, error) {
|
||||
return getLogPath("access")
|
||||
}
|
||||
|
||||
// GetErrorLogPath reads the Xray config and returns the error log file path.
|
||||
// GetErrorLogPath reads the Xray config and returns the error log file path.
|
||||
func GetErrorLogPath() (string, error) {
|
||||
return getLogPath("error")
|
||||
}
|
||||
|
||||
// stopProcess calls Stop on the given Process instance.
|
||||
func stopProcess(p *Process) {
|
||||
_ = p.Stop()
|
||||
|
||||
Reference in New Issue
Block a user