diff options
Diffstat (limited to 'web/service/server.go')
| -rw-r--r-- | web/service/server.go | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/web/service/server.go b/web/service/server.go index 5e6065b5..c73fce57 100644 --- a/web/service/server.go +++ b/web/service/server.go @@ -13,6 +13,7 @@ import ( "runtime" "strings" "time" + "x-ui/config" "x-ui/logger" "x-ui/util/sys" "x-ui/xray" @@ -327,11 +328,11 @@ func (s *ServerService) UpdateXray(version string) error { } -func (s *ServerService) GetLogs() ([]string, error) { +func (s *ServerService) GetLogs(count string) ([]string, error) { // Define the journalctl command and its arguments var cmdArgs []string if runtime.GOOS == "linux" { - cmdArgs = []string{"journalctl", "-u", "x-ui", "--no-pager", "-n", "100"} + cmdArgs = []string{"journalctl", "-u", "x-ui", "--no-pager", "-n", count} } else { return []string{"Unsupported operating system"}, nil } @@ -349,3 +350,43 @@ func (s *ServerService) GetLogs() ([]string, error) { return lines, nil } + +func (s *ServerService) GetConfigJson() (interface{}, error) { + // Open the file for reading + file, err := os.Open(xray.GetConfigPath()) + if err != nil { + return nil, err + } + defer file.Close() + + // Read the file contents + fileContents, err := io.ReadAll(file) + if err != nil { + return nil, err + } + + var jsonData interface{} + err = json.Unmarshal(fileContents, &jsonData) + if err != nil { + return nil, err + } + + return jsonData, nil +} + +func (s *ServerService) GetDb() ([]byte, error) { + // Open the file for reading + file, err := os.Open(config.GetDBPath()) + if err != nil { + return nil, err + } + defer file.Close() + + // Read the file contents + fileContents, err := io.ReadAll(file) + if err != nil { + return nil, err + } + + return fileContents, nil +} |
