From 8ef89eaa995a8085ae6916539b8c183fbf89d4c9 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami <70919649+hamid-gh98@users.noreply.github.com> Date: Tue, 27 Jun 2023 19:03:59 +0430 Subject: [PATCH] move paths to xray process --- xray/process.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/xray/process.go b/xray/process.go index 42b2ee5c..cc76e78a 100644 --- a/xray/process.go +++ b/xray/process.go @@ -14,6 +14,7 @@ import ( "sync" "syscall" "x-ui/config" + "x-ui/logger" "x-ui/util/common" "github.com/Workiva/go-datastructures/queue" @@ -47,10 +48,47 @@ func GetBlockedIPsPath() string { return config.GetBinFolderPath() + "/BlockedIps" } +func GetIPLimitLogPath() string { + return config.GetLogFolder() + "/3xipl.log" +} + +func GetIPLimitBannedLogPath() string { + return config.GetLogFolder() + "/3xipl-banned.log" +} + +func GetAccessPersistentLogPath() string { + return config.GetLogFolder() + "/3xui-access-persistent.log" +} + +func GetAccessLogPath() string { + config, err := os.ReadFile(GetConfigPath()) + if err != nil { + logger.Warningf("Something went wrong: %s", err) + } + + jsonConfig := map[string]interface{}{} + err = json.Unmarshal([]byte(config), &jsonConfig) + if err != nil { + logger.Warningf("Something went wrong: %s", err) + } + + if jsonConfig["log"] != nil { + jsonLog := jsonConfig["log"].(map[string]interface{}) + if jsonLog["access"] != nil { + + accessLogPath := jsonLog["access"].(string) + + return accessLogPath + } + } + return "" +} + func stopProcess(p *Process) { p.Stop() } + type Process struct { *process }