From e00c3f1823a4ff80daf8290e2dfec4474e7f9173 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Wed, 9 Aug 2023 00:37:05 +0330 Subject: add panel usage to main page --- xray/process.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'xray') diff --git a/xray/process.go b/xray/process.go index b860360f..315d3ed0 100644 --- a/xray/process.go +++ b/xray/process.go @@ -13,6 +13,7 @@ import ( "strings" "sync" "syscall" + "time" "x-ui/config" "x-ui/logger" @@ -101,16 +102,18 @@ type process struct { version string apiPort int - config *Config - lines *queue.Queue - exitErr error + config *Config + lines *queue.Queue + exitErr error + startTime time.Time } func newProcess(config *Config) *process { return &process{ - version: "Unknown", - config: config, - lines: queue.New(100), + version: "Unknown", + config: config, + lines: queue.New(100), + startTime: time.Now(), } } @@ -154,6 +157,10 @@ func (p *Process) GetConfig() *Config { return p.config } +func (p *Process) GetUptime() uint64 { + return uint64(time.Since(p.startTime).Seconds()) +} + func (p *process) refreshAPIPort() { for _, inbound := range p.config.InboundConfigs { if inbound.Tag == "api" { -- cgit v1.2.3