Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Movaghari <52345697+mohammadmovaghari@users.noreply.github.com>2023-04-12 16:29:17 +0300
committerGitHub <noreply@github.com>2023-04-12 16:29:17 +0300
commitc575425292e2c4c690728174e42a6f34963394c2 (patch)
treec9b033457baa55a98cea23a8769645f8f3dbd476 /web/service/server.go
parent63f71e527ceddc724e0bd2893c4946b01f3a5f6c (diff)
parent82b2809fccb6a131b4f84e2ca236f8bea567beae (diff)
Merge branch 'MHSanaei:main' into main
Diffstat (limited to 'web/service/server.go')
-rw-r--r--web/service/server.go45
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
+}