Browse Source

feat: Add start time in /api/sysinfover

lejianwen 7 months ago
parent
commit
175fdc3bd4
2 changed files with 15 additions and 1 deletions
  1. 3 0
      http/controller/api/peer.go
  2. 12 1
      service/app.go

+ 3 - 0
http/controller/api/peer.go

@@ -1,6 +1,7 @@
1 1
 package api
2 2
 
3 3
 import (
4
+	"fmt"
4 5
 	"github.com/gin-gonic/gin"
5 6
 	"github.com/gin-gonic/gin/binding"
6 7
 	requstform "github.com/lejianwen/rustdesk-api/v2/http/request/api"
@@ -60,5 +61,7 @@ func (p *Peer) SysInfo(c *gin.Context) {
60 61
 func (p *Peer) SysInfoVer(c *gin.Context) {
61 62
 	//读取resources/version文件
62 63
 	v := service.AllService.AppService.GetAppVersion()
64
+	// 加上启动时间,方便client上传信息
65
+	v = fmt.Sprintf("%s\n%s", v, service.AllService.AppService.GetStartTime())
63 66
 	c.String(http.StatusOK, v)
64 67
 }

+ 12 - 1
service/app.go

@@ -3,13 +3,14 @@ package service
3 3
 import (
4 4
 	"os"
5 5
 	"sync"
6
+	"time"
6 7
 )
7 8
 
8 9
 type AppService struct {
9 10
 }
10 11
 
11 12
 var version = ""
12
-
13
+var startTime = ""
13 14
 var once = &sync.Once{}
14 15
 
15 16
 func (a *AppService) GetAppVersion() string {
@@ -26,3 +27,13 @@ func (a *AppService) GetAppVersion() string {
26 27
 	})
27 28
 	return version
28 29
 }
30
+
31
+func init() {
32
+	// Initialize the AppService if needed
33
+	startTime = time.Now().Format("2006-01-02 15:04:05")
34
+}
35
+
36
+// GetStartTime
37
+func (a *AppService) GetStartTime() string {
38
+	return startTime
39
+}