update format

This commit is contained in:
Jason
2019-08-16 16:22:46 +08:00
parent 15951a725e
commit b2450e7d1d
2 changed files with 3 additions and 6 deletions

View File

@@ -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),

View File

@@ -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() {