mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-10 19:20:15 +08:00
update format
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/xjasonlyu/tun2socks/common/queue"
|
"github.com/xjasonlyu/tun2socks/common/queue"
|
||||||
C "github.com/xjasonlyu/tun2socks/constant"
|
C "github.com/xjasonlyu/tun2socks/constant"
|
||||||
@@ -96,11 +97,11 @@ table, th, td {
|
|||||||
// Statistics table
|
// Statistics table
|
||||||
_, _ = fmt.Fprintf(w, "<p>Statistics</p>")
|
_, _ = fmt.Fprintf(w, "<p>Statistics</p>")
|
||||||
_, _ = fmt.Fprintf(w, "<table style=\"border=4px solid\">")
|
_, _ = fmt.Fprintf(w, "<table style=\"border=4px solid\">")
|
||||||
_, _ = fmt.Fprintf(w, "<tr><th>Last Refresh</th><th>Uptime</th><th>Upload</th><th>Download</th><th>Total Traffic</th></tr>\n")
|
_, _ = fmt.Fprintf(w, "<tr><th align=\"center\">Latest Refresh</th><th>Uptime</th><th>Total Traffic</th><th>Upload</th><th>Download</th></tr>\n")
|
||||||
trafficUp := atomic.LoadInt64(&s.trafficUp)
|
trafficUp := atomic.LoadInt64(&s.trafficUp)
|
||||||
trafficDown := atomic.LoadInt64(&s.trafficDown)
|
trafficDown := atomic.LoadInt64(&s.trafficDown)
|
||||||
_, _ = fmt.Fprintf(w, "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
|
_, _ = fmt.Fprintf(w, "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
|
||||||
now(),
|
date(time.Now()),
|
||||||
uptime(),
|
uptime(),
|
||||||
byteCountSI(trafficUp+trafficDown),
|
byteCountSI(trafficUp+trafficDown),
|
||||||
byteCountSI(trafficUp),
|
byteCountSI(trafficUp),
|
||||||
|
@@ -16,10 +16,6 @@ func date(t time.Time) string {
|
|||||||
return t.Format("Mon Jan 2 15:04:05")
|
return t.Format("Mon Jan 2 15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
func now() string {
|
|
||||||
return time.Now().Format("2006-01-02 15:04:05")
|
|
||||||
}
|
|
||||||
|
|
||||||
func duration(start, end time.Time) string {
|
func duration(start, end time.Time) string {
|
||||||
var t time.Duration
|
var t time.Duration
|
||||||
if end.IsZero() {
|
if end.IsZero() {
|
||||||
|
Reference in New Issue
Block a user